repo
stringlengths 5
54
| path
stringlengths 4
155
| func_name
stringlengths 1
118
| original_string
stringlengths 52
85.5k
| language
stringclasses 1
value | code
stringlengths 52
85.5k
| code_tokens
list | docstring
stringlengths 6
2.61k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
gopasspw/gopass
|
pkg/store/root/store.go
|
Path
|
func (r *Store) Path() string {
if r.url == nil {
return ""
}
return r.url.Path
}
|
go
|
func (r *Store) Path() string {
if r.url == nil {
return ""
}
return r.url.Path
}
|
[
"func",
"(",
"r",
"*",
"Store",
")",
"Path",
"(",
")",
"string",
"{",
"if",
"r",
".",
"url",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"r",
".",
"url",
".",
"Path",
"\n",
"}"
] |
// Path returns the store path
|
[
"Path",
"returns",
"the",
"store",
"path"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/store.go#L66-L71
|
train
|
gopasspw/gopass
|
pkg/store/root/store.go
|
URL
|
func (r *Store) URL() string {
if r.url == nil {
return ""
}
return r.url.String()
}
|
go
|
func (r *Store) URL() string {
if r.url == nil {
return ""
}
return r.url.String()
}
|
[
"func",
"(",
"r",
"*",
"Store",
")",
"URL",
"(",
")",
"string",
"{",
"if",
"r",
".",
"url",
"==",
"nil",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"r",
".",
"url",
".",
"String",
"(",
")",
"\n",
"}"
] |
// URL returns the store URL
|
[
"URL",
"returns",
"the",
"store",
"URL"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/store.go#L74-L79
|
train
|
gopasspw/gopass
|
pkg/store/root/store.go
|
Storage
|
func (r *Store) Storage(ctx context.Context, name string) backend.Storage {
_, sub, _ := r.getStore(ctx, name)
if sub == nil || !sub.Valid() {
return nil
}
return sub.Storage()
}
|
go
|
func (r *Store) Storage(ctx context.Context, name string) backend.Storage {
_, sub, _ := r.getStore(ctx, name)
if sub == nil || !sub.Valid() {
return nil
}
return sub.Storage()
}
|
[
"func",
"(",
"r",
"*",
"Store",
")",
"Storage",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"backend",
".",
"Storage",
"{",
"_",
",",
"sub",
",",
"_",
":=",
"r",
".",
"getStore",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"sub",
"==",
"nil",
"||",
"!",
"sub",
".",
"Valid",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"sub",
".",
"Storage",
"(",
")",
"\n",
"}"
] |
// Storage returns the storage backend for the given mount point
|
[
"Storage",
"returns",
"the",
"storage",
"backend",
"for",
"the",
"given",
"mount",
"point"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/store.go#L87-L93
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
New
|
func New(host, prefix, datacenter, token string) (*Store, error) {
if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
if strings.HasPrefix(prefix, "/") {
prefix = strings.TrimPrefix(prefix, "/")
}
client, err := api.NewClient(&api.Config{
Address: host,
Datacenter: datacenter,
Token: token,
})
if err != nil {
return nil, err
}
return &Store{
api: client,
prefix: prefix,
}, nil
}
|
go
|
func New(host, prefix, datacenter, token string) (*Store, error) {
if !strings.HasSuffix(prefix, "/") {
prefix += "/"
}
if strings.HasPrefix(prefix, "/") {
prefix = strings.TrimPrefix(prefix, "/")
}
client, err := api.NewClient(&api.Config{
Address: host,
Datacenter: datacenter,
Token: token,
})
if err != nil {
return nil, err
}
return &Store{
api: client,
prefix: prefix,
}, nil
}
|
[
"func",
"New",
"(",
"host",
",",
"prefix",
",",
"datacenter",
",",
"token",
"string",
")",
"(",
"*",
"Store",
",",
"error",
")",
"{",
"if",
"!",
"strings",
".",
"HasSuffix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"{",
"prefix",
"+=",
"\"",
"\"",
"\n",
"}",
"\n",
"if",
"strings",
".",
"HasPrefix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"{",
"prefix",
"=",
"strings",
".",
"TrimPrefix",
"(",
"prefix",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"client",
",",
"err",
":=",
"api",
".",
"NewClient",
"(",
"&",
"api",
".",
"Config",
"{",
"Address",
":",
"host",
",",
"Datacenter",
":",
"datacenter",
",",
"Token",
":",
"token",
",",
"}",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"Store",
"{",
"api",
":",
"client",
",",
"prefix",
":",
"prefix",
",",
"}",
",",
"nil",
"\n",
"}"
] |
// New creates a new consul store
|
[
"New",
"creates",
"a",
"new",
"consul",
"store"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L21-L40
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
Get
|
func (s *Store) Get(ctx context.Context, name string) ([]byte, error) {
name = s.prefix + name
out.Debug(ctx, "consul.Get(%s)", name)
p, _, err := s.api.KV().Get(name, nil)
if err != nil {
return nil, err
}
if p == nil || p.Value == nil {
return nil, nil
}
return p.Value, nil
}
|
go
|
func (s *Store) Get(ctx context.Context, name string) ([]byte, error) {
name = s.prefix + name
out.Debug(ctx, "consul.Get(%s)", name)
p, _, err := s.api.KV().Get(name, nil)
if err != nil {
return nil, err
}
if p == nil || p.Value == nil {
return nil, nil
}
return p.Value, nil
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Get",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"name",
"=",
"s",
".",
"prefix",
"+",
"name",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"p",
",",
"_",
",",
"err",
":=",
"s",
".",
"api",
".",
"KV",
"(",
")",
".",
"Get",
"(",
"name",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"if",
"p",
"==",
"nil",
"||",
"p",
".",
"Value",
"==",
"nil",
"{",
"return",
"nil",
",",
"nil",
"\n",
"}",
"\n",
"return",
"p",
".",
"Value",
",",
"nil",
"\n",
"}"
] |
// Get retrieves a single entry
|
[
"Get",
"retrieves",
"a",
"single",
"entry"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L43-L54
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
Set
|
func (s *Store) Set(ctx context.Context, name string, value []byte) error {
name = s.prefix + name
out.Debug(ctx, "consul.Set(%s)", name)
p := &api.KVPair{
Key: name,
Value: value,
}
_, err := s.api.KV().Put(p, nil)
return err
}
|
go
|
func (s *Store) Set(ctx context.Context, name string, value []byte) error {
name = s.prefix + name
out.Debug(ctx, "consul.Set(%s)", name)
p := &api.KVPair{
Key: name,
Value: value,
}
_, err := s.api.KV().Put(p, nil)
return err
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"value",
"[",
"]",
"byte",
")",
"error",
"{",
"name",
"=",
"s",
".",
"prefix",
"+",
"name",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"p",
":=",
"&",
"api",
".",
"KVPair",
"{",
"Key",
":",
"name",
",",
"Value",
":",
"value",
",",
"}",
"\n",
"_",
",",
"err",
":=",
"s",
".",
"api",
".",
"KV",
"(",
")",
".",
"Put",
"(",
"p",
",",
"nil",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// Set writes a single entry
|
[
"Set",
"writes",
"a",
"single",
"entry"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L57-L66
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
Exists
|
func (s *Store) Exists(ctx context.Context, name string) bool {
out.Debug(ctx, "consul.Exists(%s)", name)
v, err := s.Get(ctx, name)
if err == nil && v != nil {
return true
}
return false
}
|
go
|
func (s *Store) Exists(ctx context.Context, name string) bool {
out.Debug(ctx, "consul.Exists(%s)", name)
v, err := s.Get(ctx, name)
if err == nil && v != nil {
return true
}
return false
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Exists",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"v",
",",
"err",
":=",
"s",
".",
"Get",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"==",
"nil",
"&&",
"v",
"!=",
"nil",
"{",
"return",
"true",
"\n",
"}",
"\n",
"return",
"false",
"\n",
"}"
] |
// Exists checks if a given entry exists
|
[
"Exists",
"checks",
"if",
"a",
"given",
"entry",
"exists"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L77-L84
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
List
|
func (s *Store) List(ctx context.Context, _ string) ([]string, error) {
prefix := s.prefix
out.Debug(ctx, "consul.List(%s)", prefix)
pairs, _, err := s.api.KV().List(prefix, nil)
if err != nil {
return nil, err
}
res := make([]string, len(pairs))
for _, kvp := range pairs {
res = append(res, strings.TrimPrefix(kvp.Key, s.prefix))
}
return res, nil
}
|
go
|
func (s *Store) List(ctx context.Context, _ string) ([]string, error) {
prefix := s.prefix
out.Debug(ctx, "consul.List(%s)", prefix)
pairs, _, err := s.api.KV().List(prefix, nil)
if err != nil {
return nil, err
}
res := make([]string, len(pairs))
for _, kvp := range pairs {
res = append(res, strings.TrimPrefix(kvp.Key, s.prefix))
}
return res, nil
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"List",
"(",
"ctx",
"context",
".",
"Context",
",",
"_",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"prefix",
":=",
"s",
".",
"prefix",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"prefix",
")",
"\n",
"pairs",
",",
"_",
",",
"err",
":=",
"s",
".",
"api",
".",
"KV",
"(",
")",
".",
"List",
"(",
"prefix",
",",
"nil",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"res",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"pairs",
")",
")",
"\n",
"for",
"_",
",",
"kvp",
":=",
"range",
"pairs",
"{",
"res",
"=",
"append",
"(",
"res",
",",
"strings",
".",
"TrimPrefix",
"(",
"kvp",
".",
"Key",
",",
"s",
".",
"prefix",
")",
")",
"\n",
"}",
"\n",
"return",
"res",
",",
"nil",
"\n",
"}"
] |
// List lists all entries matching the given prefix
|
[
"List",
"lists",
"all",
"entries",
"matching",
"the",
"given",
"prefix"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L87-L99
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
IsDir
|
func (s *Store) IsDir(ctx context.Context, name string) bool {
name = s.prefix + name
out.Debug(ctx, "consul.IsDir(%s)", name)
count := 0
ls, err := s.List(ctx, name)
if err != nil {
return false
}
for _, e := range ls {
if strings.HasPrefix(e, name) {
count++
}
}
return count > 1
}
|
go
|
func (s *Store) IsDir(ctx context.Context, name string) bool {
name = s.prefix + name
out.Debug(ctx, "consul.IsDir(%s)", name)
count := 0
ls, err := s.List(ctx, name)
if err != nil {
return false
}
for _, e := range ls {
if strings.HasPrefix(e, name) {
count++
}
}
return count > 1
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"IsDir",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
")",
"bool",
"{",
"name",
"=",
"s",
".",
"prefix",
"+",
"name",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"count",
":=",
"0",
"\n",
"ls",
",",
"err",
":=",
"s",
".",
"List",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"false",
"\n",
"}",
"\n",
"for",
"_",
",",
"e",
":=",
"range",
"ls",
"{",
"if",
"strings",
".",
"HasPrefix",
"(",
"e",
",",
"name",
")",
"{",
"count",
"++",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"count",
">",
"1",
"\n",
"}"
] |
// IsDir checks if the given entry is a directory
|
[
"IsDir",
"checks",
"if",
"the",
"given",
"entry",
"is",
"a",
"directory"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L102-L116
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
Prune
|
func (s *Store) Prune(ctx context.Context, prefix string) error {
prefix = s.prefix + prefix
out.Debug(ctx, "consul.Prune(%s)", prefix)
return s.Delete(ctx, prefix)
}
|
go
|
func (s *Store) Prune(ctx context.Context, prefix string) error {
prefix = s.prefix + prefix
out.Debug(ctx, "consul.Prune(%s)", prefix)
return s.Delete(ctx, prefix)
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Prune",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"error",
"{",
"prefix",
"=",
"s",
".",
"prefix",
"+",
"prefix",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"prefix",
")",
"\n",
"return",
"s",
".",
"Delete",
"(",
"ctx",
",",
"prefix",
")",
"\n",
"}"
] |
// Prune removes the given tree
|
[
"Prune",
"removes",
"the",
"given",
"tree"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L119-L123
|
train
|
gopasspw/gopass
|
pkg/backend/storage/kv/consul/store.go
|
Version
|
func (s *Store) Version(context.Context) semver.Version {
return semver.Version{Major: 1}
}
|
go
|
func (s *Store) Version(context.Context) semver.Version {
return semver.Version{Major: 1}
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Version",
"(",
"context",
".",
"Context",
")",
"semver",
".",
"Version",
"{",
"return",
"semver",
".",
"Version",
"{",
"Major",
":",
"1",
"}",
"\n",
"}"
] |
// Version returns 1.0.0
|
[
"Version",
"returns",
"1",
".",
"0",
".",
"0"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/kv/consul/store.go#L131-L133
|
train
|
gopasspw/gopass
|
pkg/backend/storage/fs/fsck.go
|
Fsck
|
func (s *Store) Fsck(ctx context.Context) error {
pcb := ctxutil.GetProgressCallback(ctx)
entries, err := s.List(ctx, "")
if err != nil {
return err
}
dirs := make(map[string]struct{}, len(entries))
for _, entry := range entries {
pcb()
out.Debug(ctx, "file.Fsck() - Checking %s", entry)
filename := filepath.Join(s.path, entry)
dirs[filepath.Dir(filename)] = struct{}{}
if err := s.fsckCheckFile(ctx, filename); err != nil {
return err
}
}
for dir := range dirs {
if err := s.fsckCheckDir(ctx, dir); err != nil {
return err
}
}
return nil
}
|
go
|
func (s *Store) Fsck(ctx context.Context) error {
pcb := ctxutil.GetProgressCallback(ctx)
entries, err := s.List(ctx, "")
if err != nil {
return err
}
dirs := make(map[string]struct{}, len(entries))
for _, entry := range entries {
pcb()
out.Debug(ctx, "file.Fsck() - Checking %s", entry)
filename := filepath.Join(s.path, entry)
dirs[filepath.Dir(filename)] = struct{}{}
if err := s.fsckCheckFile(ctx, filename); err != nil {
return err
}
}
for dir := range dirs {
if err := s.fsckCheckDir(ctx, dir); err != nil {
return err
}
}
return nil
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Fsck",
"(",
"ctx",
"context",
".",
"Context",
")",
"error",
"{",
"pcb",
":=",
"ctxutil",
".",
"GetProgressCallback",
"(",
"ctx",
")",
"\n\n",
"entries",
",",
"err",
":=",
"s",
".",
"List",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"dirs",
":=",
"make",
"(",
"map",
"[",
"string",
"]",
"struct",
"{",
"}",
",",
"len",
"(",
"entries",
")",
")",
"\n",
"for",
"_",
",",
"entry",
":=",
"range",
"entries",
"{",
"pcb",
"(",
")",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"entry",
")",
"\n\n",
"filename",
":=",
"filepath",
".",
"Join",
"(",
"s",
".",
"path",
",",
"entry",
")",
"\n",
"dirs",
"[",
"filepath",
".",
"Dir",
"(",
"filename",
")",
"]",
"=",
"struct",
"{",
"}",
"{",
"}",
"\n\n",
"if",
"err",
":=",
"s",
".",
"fsckCheckFile",
"(",
"ctx",
",",
"filename",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"for",
"dir",
":=",
"range",
"dirs",
"{",
"if",
"err",
":=",
"s",
".",
"fsckCheckDir",
"(",
"ctx",
",",
"dir",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Fsck checks the storage integrity
|
[
"Fsck",
"checks",
"the",
"storage",
"integrity"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/storage/fs/fsck.go#L15-L41
|
train
|
gopasspw/gopass
|
pkg/config/legacy.go
|
StoreConfig
|
func (c *Pre182StoreConfig) StoreConfig() *StoreConfig {
sc := &StoreConfig{
AskForMore: c.AskForMore,
AutoClip: c.AutoClip,
AutoImport: c.AutoImport,
AutoSync: c.AutoSync,
CheckRecpHash: c.CheckRecpHash,
ClipTimeout: c.ClipTimeout,
Concurrency: c.Concurrency,
EditRecipients: c.EditRecipients,
NoColor: c.NoColor,
NoConfirm: c.NoConfirm,
NoPager: c.NoPager,
Notifications: c.Notifications,
Path: c.Path,
RecipientHash: c.RecipientHash,
SafeContent: c.SafeContent,
UseSymbols: c.UseSymbols,
}
return sc
}
|
go
|
func (c *Pre182StoreConfig) StoreConfig() *StoreConfig {
sc := &StoreConfig{
AskForMore: c.AskForMore,
AutoClip: c.AutoClip,
AutoImport: c.AutoImport,
AutoSync: c.AutoSync,
CheckRecpHash: c.CheckRecpHash,
ClipTimeout: c.ClipTimeout,
Concurrency: c.Concurrency,
EditRecipients: c.EditRecipients,
NoColor: c.NoColor,
NoConfirm: c.NoConfirm,
NoPager: c.NoPager,
Notifications: c.Notifications,
Path: c.Path,
RecipientHash: c.RecipientHash,
SafeContent: c.SafeContent,
UseSymbols: c.UseSymbols,
}
return sc
}
|
[
"func",
"(",
"c",
"*",
"Pre182StoreConfig",
")",
"StoreConfig",
"(",
")",
"*",
"StoreConfig",
"{",
"sc",
":=",
"&",
"StoreConfig",
"{",
"AskForMore",
":",
"c",
".",
"AskForMore",
",",
"AutoClip",
":",
"c",
".",
"AutoClip",
",",
"AutoImport",
":",
"c",
".",
"AutoImport",
",",
"AutoSync",
":",
"c",
".",
"AutoSync",
",",
"CheckRecpHash",
":",
"c",
".",
"CheckRecpHash",
",",
"ClipTimeout",
":",
"c",
".",
"ClipTimeout",
",",
"Concurrency",
":",
"c",
".",
"Concurrency",
",",
"EditRecipients",
":",
"c",
".",
"EditRecipients",
",",
"NoColor",
":",
"c",
".",
"NoColor",
",",
"NoConfirm",
":",
"c",
".",
"NoConfirm",
",",
"NoPager",
":",
"c",
".",
"NoPager",
",",
"Notifications",
":",
"c",
".",
"Notifications",
",",
"Path",
":",
"c",
".",
"Path",
",",
"RecipientHash",
":",
"c",
".",
"RecipientHash",
",",
"SafeContent",
":",
"c",
".",
"SafeContent",
",",
"UseSymbols",
":",
"c",
".",
"UseSymbols",
",",
"}",
"\n",
"return",
"sc",
"\n",
"}"
] |
// StoreConfig returns a current StoreConfig
|
[
"StoreConfig",
"returns",
"a",
"current",
"StoreConfig"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/config/legacy.go#L37-L57
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
New
|
func New(password, body string) *Secret {
return &Secret{
password: password,
body: body,
}
}
|
go
|
func New(password, body string) *Secret {
return &Secret{
password: password,
body: body,
}
}
|
[
"func",
"New",
"(",
"password",
",",
"body",
"string",
")",
"*",
"Secret",
"{",
"return",
"&",
"Secret",
"{",
"password",
":",
"password",
",",
"body",
":",
"body",
",",
"}",
"\n",
"}"
] |
// New creates a new secret
|
[
"New",
"creates",
"a",
"new",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L30-L35
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Parse
|
func Parse(buf []byte) (*Secret, error) {
s := &Secret{}
lines := bytes.SplitN(buf, []byte("\n"), 2)
if len(lines) > 0 {
s.password = string(bytes.TrimSpace(lines[0]))
}
if len(lines) > 1 {
s.body = string(bytes.TrimSpace(lines[1]))
}
if err := s.decode(); err != nil {
return s, err
}
return s, nil
}
|
go
|
func Parse(buf []byte) (*Secret, error) {
s := &Secret{}
lines := bytes.SplitN(buf, []byte("\n"), 2)
if len(lines) > 0 {
s.password = string(bytes.TrimSpace(lines[0]))
}
if len(lines) > 1 {
s.body = string(bytes.TrimSpace(lines[1]))
}
if err := s.decode(); err != nil {
return s, err
}
return s, nil
}
|
[
"func",
"Parse",
"(",
"buf",
"[",
"]",
"byte",
")",
"(",
"*",
"Secret",
",",
"error",
")",
"{",
"s",
":=",
"&",
"Secret",
"{",
"}",
"\n",
"lines",
":=",
"bytes",
".",
"SplitN",
"(",
"buf",
",",
"[",
"]",
"byte",
"(",
"\"",
"\\n",
"\"",
")",
",",
"2",
")",
"\n",
"if",
"len",
"(",
"lines",
")",
">",
"0",
"{",
"s",
".",
"password",
"=",
"string",
"(",
"bytes",
".",
"TrimSpace",
"(",
"lines",
"[",
"0",
"]",
")",
")",
"\n",
"}",
"\n",
"if",
"len",
"(",
"lines",
")",
">",
"1",
"{",
"s",
".",
"body",
"=",
"string",
"(",
"bytes",
".",
"TrimSpace",
"(",
"lines",
"[",
"1",
"]",
")",
")",
"\n",
"}",
"\n",
"if",
"err",
":=",
"s",
".",
"decode",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"s",
",",
"err",
"\n",
"}",
"\n",
"return",
"s",
",",
"nil",
"\n",
"}"
] |
// Parse decodes an secret. It will always return a valid secret. If decoding
// the body to YAML is may return an error which can be ignored.
|
[
"Parse",
"decodes",
"an",
"secret",
".",
"It",
"will",
"always",
"return",
"a",
"valid",
"secret",
".",
"If",
"decoding",
"the",
"body",
"to",
"YAML",
"is",
"may",
"return",
"an",
"error",
"which",
"can",
"be",
"ignored",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L39-L52
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Bytes
|
func (s *Secret) Bytes() ([]byte, error) {
buf := &bytes.Buffer{}
_, _ = buf.WriteString(s.password)
if s.body != "" {
_, _ = buf.WriteString("\n")
_, _ = buf.WriteString(s.body)
}
return buf.Bytes(), nil
}
|
go
|
func (s *Secret) Bytes() ([]byte, error) {
buf := &bytes.Buffer{}
_, _ = buf.WriteString(s.password)
if s.body != "" {
_, _ = buf.WriteString("\n")
_, _ = buf.WriteString(s.body)
}
return buf.Bytes(), nil
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"Bytes",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"buf",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"s",
".",
"password",
")",
"\n",
"if",
"s",
".",
"body",
"!=",
"\"",
"\"",
"{",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"s",
".",
"body",
")",
"\n",
"}",
"\n",
"return",
"buf",
".",
"Bytes",
"(",
")",
",",
"nil",
"\n",
"}"
] |
// Bytes encodes an secret
|
[
"Bytes",
"encodes",
"an",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L55-L63
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
String
|
func (s *Secret) String() string {
var buf strings.Builder
_, _ = buf.WriteString(s.password)
if s.body != "" {
_, _ = buf.WriteString("\n")
_, _ = buf.WriteString(s.body)
}
return buf.String()
}
|
go
|
func (s *Secret) String() string {
var buf strings.Builder
_, _ = buf.WriteString(s.password)
if s.body != "" {
_, _ = buf.WriteString("\n")
_, _ = buf.WriteString(s.body)
}
return buf.String()
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"String",
"(",
")",
"string",
"{",
"var",
"buf",
"strings",
".",
"Builder",
"\n",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"s",
".",
"password",
")",
"\n\n",
"if",
"s",
".",
"body",
"!=",
"\"",
"\"",
"{",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"\"",
"\\n",
"\"",
")",
"\n",
"_",
",",
"_",
"=",
"buf",
".",
"WriteString",
"(",
"s",
".",
"body",
")",
"\n",
"}",
"\n\n",
"return",
"buf",
".",
"String",
"(",
")",
"\n",
"}"
] |
// String encodes and returns a string representation of a secret
|
[
"String",
"encodes",
"and",
"returns",
"a",
"string",
"representation",
"of",
"a",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L66-L76
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Password
|
func (s *Secret) Password() string {
s.Lock()
defer s.Unlock()
return s.password
}
|
go
|
func (s *Secret) Password() string {
s.Lock()
defer s.Unlock()
return s.password
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"Password",
"(",
")",
"string",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"password",
"\n",
"}"
] |
// Password returns the first line from a secret
|
[
"Password",
"returns",
"the",
"first",
"line",
"from",
"a",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L79-L84
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Body
|
func (s *Secret) Body() string {
s.Lock()
defer s.Unlock()
return s.body
}
|
go
|
func (s *Secret) Body() string {
s.Lock()
defer s.Unlock()
return s.body
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"Body",
"(",
")",
"string",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"body",
"\n",
"}"
] |
// Body returns the body of a secret. If the body was valid YAML it returns an
// empty string
|
[
"Body",
"returns",
"the",
"body",
"of",
"a",
"secret",
".",
"If",
"the",
"body",
"was",
"valid",
"YAML",
"it",
"returns",
"an",
"empty",
"string"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L96-L101
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Data
|
func (s *Secret) Data() map[string]interface{} {
s.Lock()
defer s.Unlock()
return s.data
}
|
go
|
func (s *Secret) Data() map[string]interface{} {
s.Lock()
defer s.Unlock()
return s.data
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"Data",
"(",
")",
"map",
"[",
"string",
"]",
"interface",
"{",
"}",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"return",
"s",
".",
"data",
"\n",
"}"
] |
// Data returns the data of a secret. Unless the body was valid YAML, it returns
// an map
|
[
"Data",
"returns",
"the",
"data",
"of",
"a",
"secret",
".",
"Unless",
"the",
"body",
"was",
"valid",
"YAML",
"it",
"returns",
"an",
"map"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L105-L110
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
SetBody
|
func (s *Secret) SetBody(b string) error {
s.Lock()
defer s.Unlock()
s.body = b
s.data = nil
err := s.decode()
return err
}
|
go
|
func (s *Secret) SetBody(b string) error {
s.Lock()
defer s.Unlock()
s.body = b
s.data = nil
err := s.decode()
return err
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"SetBody",
"(",
"b",
"string",
")",
"error",
"{",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"s",
".",
"body",
"=",
"b",
"\n",
"s",
".",
"data",
"=",
"nil",
"\n\n",
"err",
":=",
"s",
".",
"decode",
"(",
")",
"\n",
"return",
"err",
"\n",
"}"
] |
// SetBody sets a new body possibly erasing an decoded YAML map
|
[
"SetBody",
"sets",
"a",
"new",
"body",
"possibly",
"erasing",
"an",
"decoded",
"YAML",
"map"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L113-L122
|
train
|
gopasspw/gopass
|
pkg/store/secret/secret.go
|
Equal
|
func (s *Secret) Equal(other store.Secret) bool {
if s == nil && (other == nil || reflect.ValueOf(other).IsNil()) {
return true
}
if s == nil || other == nil || reflect.ValueOf(other).IsNil() {
return false
}
s.Lock()
defer s.Unlock()
if s.password != other.Password() {
return false
}
if s.body != other.Body() {
return false
}
return true
}
|
go
|
func (s *Secret) Equal(other store.Secret) bool {
if s == nil && (other == nil || reflect.ValueOf(other).IsNil()) {
return true
}
if s == nil || other == nil || reflect.ValueOf(other).IsNil() {
return false
}
s.Lock()
defer s.Unlock()
if s.password != other.Password() {
return false
}
if s.body != other.Body() {
return false
}
return true
}
|
[
"func",
"(",
"s",
"*",
"Secret",
")",
"Equal",
"(",
"other",
"store",
".",
"Secret",
")",
"bool",
"{",
"if",
"s",
"==",
"nil",
"&&",
"(",
"other",
"==",
"nil",
"||",
"reflect",
".",
"ValueOf",
"(",
"other",
")",
".",
"IsNil",
"(",
")",
")",
"{",
"return",
"true",
"\n",
"}",
"\n",
"if",
"s",
"==",
"nil",
"||",
"other",
"==",
"nil",
"||",
"reflect",
".",
"ValueOf",
"(",
"other",
")",
".",
"IsNil",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"s",
".",
"Lock",
"(",
")",
"\n",
"defer",
"s",
".",
"Unlock",
"(",
")",
"\n\n",
"if",
"s",
".",
"password",
"!=",
"other",
".",
"Password",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"if",
"s",
".",
"body",
"!=",
"other",
".",
"Body",
"(",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] |
// Equal returns true if two secrets are equal
|
[
"Equal",
"returns",
"true",
"if",
"two",
"secrets",
"are",
"equal"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/secret/secret.go#L125-L145
|
train
|
gopasspw/gopass
|
pkg/pwgen/xkcdgen/pwgen.go
|
RandomLength
|
func RandomLength(length int, lang string) (string, error) {
return RandomLengthDelim(length, " ", lang)
}
|
go
|
func RandomLength(length int, lang string) (string, error) {
return RandomLengthDelim(length, " ", lang)
}
|
[
"func",
"RandomLength",
"(",
"length",
"int",
",",
"lang",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"return",
"RandomLengthDelim",
"(",
"length",
",",
"\"",
"\"",
",",
"lang",
")",
"\n",
"}"
] |
// RandomLength returns a random passphrase combined from the desired number
// of words
|
[
"RandomLength",
"returns",
"a",
"random",
"passphrase",
"combined",
"from",
"the",
"desired",
"number",
"of",
"words"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pwgen/xkcdgen/pwgen.go#L13-L15
|
train
|
gopasspw/gopass
|
pkg/pwgen/xkcdgen/pwgen.go
|
RandomLengthDelim
|
func RandomLengthDelim(length int, delim, lang string) (string, error) {
g := xkcdpwgen.NewGenerator()
g.SetNumWords(length)
g.SetDelimiter(delim)
g.SetCapitalize(delim == "")
if err := g.UseLangWordlist(lang); err != nil {
return "", err
}
return string(g.GeneratePassword()), nil
}
|
go
|
func RandomLengthDelim(length int, delim, lang string) (string, error) {
g := xkcdpwgen.NewGenerator()
g.SetNumWords(length)
g.SetDelimiter(delim)
g.SetCapitalize(delim == "")
if err := g.UseLangWordlist(lang); err != nil {
return "", err
}
return string(g.GeneratePassword()), nil
}
|
[
"func",
"RandomLengthDelim",
"(",
"length",
"int",
",",
"delim",
",",
"lang",
"string",
")",
"(",
"string",
",",
"error",
")",
"{",
"g",
":=",
"xkcdpwgen",
".",
"NewGenerator",
"(",
")",
"\n",
"g",
".",
"SetNumWords",
"(",
"length",
")",
"\n",
"g",
".",
"SetDelimiter",
"(",
"delim",
")",
"\n",
"g",
".",
"SetCapitalize",
"(",
"delim",
"==",
"\"",
"\"",
")",
"\n",
"if",
"err",
":=",
"g",
".",
"UseLangWordlist",
"(",
"lang",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"\"",
"\"",
",",
"err",
"\n",
"}",
"\n",
"return",
"string",
"(",
"g",
".",
"GeneratePassword",
"(",
")",
")",
",",
"nil",
"\n",
"}"
] |
// RandomLengthDelim returns a random passphrase combined from the desired number
// of words and the given delimiter. Words are drawn from lang
|
[
"RandomLengthDelim",
"returns",
"a",
"random",
"passphrase",
"combined",
"from",
"the",
"desired",
"number",
"of",
"words",
"and",
"the",
"given",
"delimiter",
".",
"Words",
"are",
"drawn",
"from",
"lang"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pwgen/xkcdgen/pwgen.go#L19-L28
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
WithForce
|
func WithForce(ctx context.Context, force bool) context.Context {
return context.WithValue(ctx, ctxKeyForce, force)
}
|
go
|
func WithForce(ctx context.Context, force bool) context.Context {
return context.WithValue(ctx, ctxKeyForce, force)
}
|
[
"func",
"WithForce",
"(",
"ctx",
"context",
".",
"Context",
",",
"force",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyForce",
",",
"force",
")",
"\n",
"}"
] |
// WithForce returns a context with the value for force set
|
[
"WithForce",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"force",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L31-L33
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
WithPasswordOnly
|
func WithPasswordOnly(ctx context.Context, pw bool) context.Context {
return context.WithValue(ctx, ctxKeyPasswordOnly, pw)
}
|
go
|
func WithPasswordOnly(ctx context.Context, pw bool) context.Context {
return context.WithValue(ctx, ctxKeyPasswordOnly, pw)
}
|
[
"func",
"WithPasswordOnly",
"(",
"ctx",
"context",
".",
"Context",
",",
"pw",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyPasswordOnly",
",",
"pw",
")",
"\n",
"}"
] |
// WithPasswordOnly returns a context with the value of password only set
|
[
"WithPasswordOnly",
"returns",
"a",
"context",
"with",
"the",
"value",
"of",
"password",
"only",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L45-L47
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
WithPrintQR
|
func WithPrintQR(ctx context.Context, qr bool) context.Context {
return context.WithValue(ctx, ctxKeyPrintQR, qr)
}
|
go
|
func WithPrintQR(ctx context.Context, qr bool) context.Context {
return context.WithValue(ctx, ctxKeyPrintQR, qr)
}
|
[
"func",
"WithPrintQR",
"(",
"ctx",
"context",
".",
"Context",
",",
"qr",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyPrintQR",
",",
"qr",
")",
"\n",
"}"
] |
// WithPrintQR returns a context with the value of print QR set
|
[
"WithPrintQR",
"returns",
"a",
"context",
"with",
"the",
"value",
"of",
"print",
"QR",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L59-L61
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
WithRevision
|
func WithRevision(ctx context.Context, rev string) context.Context {
return context.WithValue(ctx, ctxKeyRevision, rev)
}
|
go
|
func WithRevision(ctx context.Context, rev string) context.Context {
return context.WithValue(ctx, ctxKeyRevision, rev)
}
|
[
"func",
"WithRevision",
"(",
"ctx",
"context",
".",
"Context",
",",
"rev",
"string",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyRevision",
",",
"rev",
")",
"\n",
"}"
] |
// WithRevision returns a context withe the value of revision set
|
[
"WithRevision",
"returns",
"a",
"context",
"withe",
"the",
"value",
"of",
"revision",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L73-L75
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
HasRevision
|
func HasRevision(ctx context.Context) bool {
sv, ok := ctx.Value(ctxKeyRevision).(string)
return ok && sv != ""
}
|
go
|
func HasRevision(ctx context.Context) bool {
sv, ok := ctx.Value(ctxKeyRevision).(string)
return ok && sv != ""
}
|
[
"func",
"HasRevision",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"sv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyRevision",
")",
".",
"(",
"string",
")",
"\n",
"return",
"ok",
"&&",
"sv",
"!=",
"\"",
"\"",
"\n",
"}"
] |
// HasRevision returns true if a value for revision was set in this context
|
[
"HasRevision",
"returns",
"true",
"if",
"a",
"value",
"for",
"revision",
"was",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L78-L81
|
train
|
gopasspw/gopass
|
pkg/action/context.go
|
GetRevision
|
func GetRevision(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyRevision).(string)
if !ok {
return ""
}
return sv
}
|
go
|
func GetRevision(ctx context.Context) string {
sv, ok := ctx.Value(ctxKeyRevision).(string)
if !ok {
return ""
}
return sv
}
|
[
"func",
"GetRevision",
"(",
"ctx",
"context",
".",
"Context",
")",
"string",
"{",
"sv",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyRevision",
")",
".",
"(",
"string",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"sv",
"\n",
"}"
] |
// GetRevision returns the revison set in this context or an empty string
|
[
"GetRevision",
"returns",
"the",
"revison",
"set",
"in",
"this",
"context",
"or",
"an",
"empty",
"string"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/context.go#L84-L90
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
RegisterCrypto
|
func RegisterCrypto(id CryptoBackend, name string, loader CryptoLoader) {
cryptoRegistry[id] = loader
cryptoNameToBackendMap[name] = id
cryptoBackendToNameMap[id] = name
}
|
go
|
func RegisterCrypto(id CryptoBackend, name string, loader CryptoLoader) {
cryptoRegistry[id] = loader
cryptoNameToBackendMap[name] = id
cryptoBackendToNameMap[id] = name
}
|
[
"func",
"RegisterCrypto",
"(",
"id",
"CryptoBackend",
",",
"name",
"string",
",",
"loader",
"CryptoLoader",
")",
"{",
"cryptoRegistry",
"[",
"id",
"]",
"=",
"loader",
"\n",
"cryptoNameToBackendMap",
"[",
"name",
"]",
"=",
"id",
"\n",
"cryptoBackendToNameMap",
"[",
"id",
"]",
"=",
"name",
"\n",
"}"
] |
// RegisterCrypto registers a new crypto backend with the backend registry.
|
[
"RegisterCrypto",
"registers",
"a",
"new",
"crypto",
"backend",
"with",
"the",
"backend",
"registry",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L41-L45
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
NewCrypto
|
func NewCrypto(ctx context.Context, id CryptoBackend) (Crypto, error) {
if be, found := cryptoRegistry[id]; found {
return be.New(ctx)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
go
|
func NewCrypto(ctx context.Context, id CryptoBackend) (Crypto, error) {
if be, found := cryptoRegistry[id]; found {
return be.New(ctx)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
[
"func",
"NewCrypto",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"CryptoBackend",
")",
"(",
"Crypto",
",",
"error",
")",
"{",
"if",
"be",
",",
"found",
":=",
"cryptoRegistry",
"[",
"id",
"]",
";",
"found",
"{",
"return",
"be",
".",
"New",
"(",
"ctx",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNotFound",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}"
] |
// NewCrypto instantiates a new crypto backend.
|
[
"NewCrypto",
"instantiates",
"a",
"new",
"crypto",
"backend",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L48-L53
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
RegisterRCS
|
func RegisterRCS(id RCSBackend, name string, loader RCSLoader) {
rcsRegistry[id] = loader
rcsNameToBackendMap[name] = id
rcsBackendToNameMap[id] = name
}
|
go
|
func RegisterRCS(id RCSBackend, name string, loader RCSLoader) {
rcsRegistry[id] = loader
rcsNameToBackendMap[name] = id
rcsBackendToNameMap[id] = name
}
|
[
"func",
"RegisterRCS",
"(",
"id",
"RCSBackend",
",",
"name",
"string",
",",
"loader",
"RCSLoader",
")",
"{",
"rcsRegistry",
"[",
"id",
"]",
"=",
"loader",
"\n",
"rcsNameToBackendMap",
"[",
"name",
"]",
"=",
"id",
"\n",
"rcsBackendToNameMap",
"[",
"id",
"]",
"=",
"name",
"\n",
"}"
] |
// RegisterRCS registers a new RCS backend with the backend registry.
|
[
"RegisterRCS",
"registers",
"a",
"new",
"RCS",
"backend",
"with",
"the",
"backend",
"registry",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L56-L60
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
OpenRCS
|
func OpenRCS(ctx context.Context, id RCSBackend, path string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
return be.Open(ctx, path)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
go
|
func OpenRCS(ctx context.Context, id RCSBackend, path string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
return be.Open(ctx, path)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
[
"func",
"OpenRCS",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"RCSBackend",
",",
"path",
"string",
")",
"(",
"RCS",
",",
"error",
")",
"{",
"if",
"be",
",",
"found",
":=",
"rcsRegistry",
"[",
"id",
"]",
";",
"found",
"{",
"return",
"be",
".",
"Open",
"(",
"ctx",
",",
"path",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNotFound",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}"
] |
// OpenRCS opens an existing repository.
|
[
"OpenRCS",
"opens",
"an",
"existing",
"repository",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L63-L68
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
CloneRCS
|
func CloneRCS(ctx context.Context, id RCSBackend, repo, path string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
out.Debug(ctx, "Cloning with %s", be.String())
return be.Clone(ctx, repo, path)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
go
|
func CloneRCS(ctx context.Context, id RCSBackend, repo, path string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
out.Debug(ctx, "Cloning with %s", be.String())
return be.Clone(ctx, repo, path)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
[
"func",
"CloneRCS",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"RCSBackend",
",",
"repo",
",",
"path",
"string",
")",
"(",
"RCS",
",",
"error",
")",
"{",
"if",
"be",
",",
"found",
":=",
"rcsRegistry",
"[",
"id",
"]",
";",
"found",
"{",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"be",
".",
"String",
"(",
")",
")",
"\n",
"return",
"be",
".",
"Clone",
"(",
"ctx",
",",
"repo",
",",
"path",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNotFound",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}"
] |
// CloneRCS clones an existing repository from a remote.
|
[
"CloneRCS",
"clones",
"an",
"existing",
"repository",
"from",
"a",
"remote",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L71-L77
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
InitRCS
|
func InitRCS(ctx context.Context, id RCSBackend, path, name, email string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
return be.Init(ctx, path, name, email)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
go
|
func InitRCS(ctx context.Context, id RCSBackend, path, name, email string) (RCS, error) {
if be, found := rcsRegistry[id]; found {
return be.Init(ctx, path, name, email)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %d", id)
}
|
[
"func",
"InitRCS",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"RCSBackend",
",",
"path",
",",
"name",
",",
"email",
"string",
")",
"(",
"RCS",
",",
"error",
")",
"{",
"if",
"be",
",",
"found",
":=",
"rcsRegistry",
"[",
"id",
"]",
";",
"found",
"{",
"return",
"be",
".",
"Init",
"(",
"ctx",
",",
"path",
",",
"name",
",",
"email",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNotFound",
",",
"\"",
"\"",
",",
"id",
")",
"\n",
"}"
] |
// InitRCS initializes a new repository.
|
[
"InitRCS",
"initializes",
"a",
"new",
"repository",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L80-L85
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
RegisterStorage
|
func RegisterStorage(id StorageBackend, name string, loader StorageLoader) {
storageRegistry[id] = loader
storageNameToBackendMap[name] = id
storageBackendToNameMap[id] = name
}
|
go
|
func RegisterStorage(id StorageBackend, name string, loader StorageLoader) {
storageRegistry[id] = loader
storageNameToBackendMap[name] = id
storageBackendToNameMap[id] = name
}
|
[
"func",
"RegisterStorage",
"(",
"id",
"StorageBackend",
",",
"name",
"string",
",",
"loader",
"StorageLoader",
")",
"{",
"storageRegistry",
"[",
"id",
"]",
"=",
"loader",
"\n",
"storageNameToBackendMap",
"[",
"name",
"]",
"=",
"id",
"\n",
"storageBackendToNameMap",
"[",
"id",
"]",
"=",
"name",
"\n",
"}"
] |
// RegisterStorage registers a new storage backend with the registry.
|
[
"RegisterStorage",
"registers",
"a",
"new",
"storage",
"backend",
"with",
"the",
"registry",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L88-L92
|
train
|
gopasspw/gopass
|
pkg/backend/registry.go
|
NewStorage
|
func NewStorage(ctx context.Context, id StorageBackend, url *URL) (Storage, error) {
if be, found := storageRegistry[id]; found {
return be.New(ctx, url)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %s", url.String())
}
|
go
|
func NewStorage(ctx context.Context, id StorageBackend, url *URL) (Storage, error) {
if be, found := storageRegistry[id]; found {
return be.New(ctx, url)
}
return nil, errors.Wrapf(ErrNotFound, "unknown backend: %s", url.String())
}
|
[
"func",
"NewStorage",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"StorageBackend",
",",
"url",
"*",
"URL",
")",
"(",
"Storage",
",",
"error",
")",
"{",
"if",
"be",
",",
"found",
":=",
"storageRegistry",
"[",
"id",
"]",
";",
"found",
"{",
"return",
"be",
".",
"New",
"(",
"ctx",
",",
"url",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"errors",
".",
"Wrapf",
"(",
"ErrNotFound",
",",
"\"",
"\"",
",",
"url",
".",
"String",
"(",
")",
")",
"\n",
"}"
] |
// NewStorage initializes a new storage backend.
|
[
"NewStorage",
"initializes",
"a",
"new",
"storage",
"backend",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/registry.go#L95-L100
|
train
|
gopasspw/gopass
|
pkg/action/templates.go
|
TemplatesPrint
|
func (s *Action) TemplatesPrint(ctx context.Context, c *cli.Context) error {
tree, err := s.Store.TemplateTree(ctx)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to list templates: %s", err)
}
fmt.Fprintln(stdout, tree.Format(0))
return nil
}
|
go
|
func (s *Action) TemplatesPrint(ctx context.Context, c *cli.Context) error {
tree, err := s.Store.TemplateTree(ctx)
if err != nil {
return ExitError(ctx, ExitList, err, "failed to list templates: %s", err)
}
fmt.Fprintln(stdout, tree.Format(0))
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"TemplatesPrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"tree",
",",
"err",
":=",
"s",
".",
"Store",
".",
"TemplateTree",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitList",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"fmt",
".",
"Fprintln",
"(",
"stdout",
",",
"tree",
".",
"Format",
"(",
"0",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// TemplatesPrint will pretty-print a tree of templates
|
[
"TemplatesPrint",
"will",
"pretty",
"-",
"print",
"a",
"tree",
"of",
"templates"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/templates.go#L38-L45
|
train
|
gopasspw/gopass
|
pkg/action/templates.go
|
TemplatePrint
|
func (s *Action) TemplatePrint(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
content, err := s.Store.GetTemplate(ctx, name)
if err != nil {
return ExitError(ctx, ExitIO, err, "failed to retrieve template: %s", err)
}
fmt.Fprintln(stdout, string(content))
return nil
}
|
go
|
func (s *Action) TemplatePrint(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
content, err := s.Store.GetTemplate(ctx, name)
if err != nil {
return ExitError(ctx, ExitIO, err, "failed to retrieve template: %s", err)
}
fmt.Fprintln(stdout, string(content))
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"TemplatePrint",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n\n",
"content",
",",
"err",
":=",
"s",
".",
"Store",
".",
"GetTemplate",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitIO",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"fmt",
".",
"Fprintln",
"(",
"stdout",
",",
"string",
"(",
"content",
")",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// TemplatePrint will lookup and print a single template
|
[
"TemplatePrint",
"will",
"lookup",
"and",
"print",
"a",
"single",
"template"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/templates.go#L48-L58
|
train
|
gopasspw/gopass
|
pkg/action/templates.go
|
TemplateEdit
|
func (s *Action) TemplateEdit(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
var content []byte
if s.Store.HasTemplate(ctx, name) {
var err error
content, err = s.Store.GetTemplate(ctx, name)
if err != nil {
return ExitError(ctx, ExitIO, err, "failed to retrieve template: %s", err)
}
} else {
content = []byte(templateExample)
}
ed := editor.Path(c)
nContent, err := editor.Invoke(ctx, ed, content)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "failed to invoke editor %s: %s", ed, err)
}
// If content is equal, nothing changed, exiting
if bytes.Equal(content, nContent) {
return nil
}
return s.Store.SetTemplate(ctx, name, nContent)
}
|
go
|
func (s *Action) TemplateEdit(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
var content []byte
if s.Store.HasTemplate(ctx, name) {
var err error
content, err = s.Store.GetTemplate(ctx, name)
if err != nil {
return ExitError(ctx, ExitIO, err, "failed to retrieve template: %s", err)
}
} else {
content = []byte(templateExample)
}
ed := editor.Path(c)
nContent, err := editor.Invoke(ctx, ed, content)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "failed to invoke editor %s: %s", ed, err)
}
// If content is equal, nothing changed, exiting
if bytes.Equal(content, nContent) {
return nil
}
return s.Store.SetTemplate(ctx, name, nContent)
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"TemplateEdit",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n\n",
"var",
"content",
"[",
"]",
"byte",
"\n",
"if",
"s",
".",
"Store",
".",
"HasTemplate",
"(",
"ctx",
",",
"name",
")",
"{",
"var",
"err",
"error",
"\n",
"content",
",",
"err",
"=",
"s",
".",
"Store",
".",
"GetTemplate",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitIO",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"else",
"{",
"content",
"=",
"[",
"]",
"byte",
"(",
"templateExample",
")",
"\n",
"}",
"\n\n",
"ed",
":=",
"editor",
".",
"Path",
"(",
"c",
")",
"\n",
"nContent",
",",
"err",
":=",
"editor",
".",
"Invoke",
"(",
"ctx",
",",
"ed",
",",
"content",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUnknown",
",",
"err",
",",
"\"",
"\"",
",",
"ed",
",",
"err",
")",
"\n",
"}",
"\n\n",
"// If content is equal, nothing changed, exiting",
"if",
"bytes",
".",
"Equal",
"(",
"content",
",",
"nContent",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"Store",
".",
"SetTemplate",
"(",
"ctx",
",",
"name",
",",
"nContent",
")",
"\n",
"}"
] |
// TemplateEdit will load and existing or new template into an
// editor
|
[
"TemplateEdit",
"will",
"load",
"and",
"existing",
"or",
"new",
"template",
"into",
"an",
"editor"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/templates.go#L62-L88
|
train
|
gopasspw/gopass
|
pkg/action/templates.go
|
TemplateRemove
|
func (s *Action) TemplateRemove(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "usage: %s templates remove [name]", s.Name)
}
if !s.Store.HasTemplate(ctx, name) {
return ExitError(ctx, ExitNotFound, nil, "template '%s' not found", name)
}
return s.Store.RemoveTemplate(ctx, name)
}
|
go
|
func (s *Action) TemplateRemove(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
if name == "" {
return ExitError(ctx, ExitUsage, nil, "usage: %s templates remove [name]", s.Name)
}
if !s.Store.HasTemplate(ctx, name) {
return ExitError(ctx, ExitNotFound, nil, "template '%s' not found", name)
}
return s.Store.RemoveTemplate(ctx, name)
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"TemplateRemove",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUsage",
",",
"nil",
",",
"\"",
"\"",
",",
"s",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"Store",
".",
"HasTemplate",
"(",
"ctx",
",",
"name",
")",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitNotFound",
",",
"nil",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"Store",
".",
"RemoveTemplate",
"(",
"ctx",
",",
"name",
")",
"\n",
"}"
] |
// TemplateRemove will remove a single template
|
[
"TemplateRemove",
"will",
"remove",
"a",
"single",
"template"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/templates.go#L91-L102
|
train
|
gopasspw/gopass
|
pkg/action/templates.go
|
TemplatesComplete
|
func (s *Action) TemplatesComplete(ctx context.Context, c *cli.Context) {
tree, err := s.Store.TemplateTree(ctx)
if err != nil {
fmt.Fprintln(stdout, err)
return
}
for _, v := range tree.List(0) {
fmt.Fprintln(stdout, v)
}
}
|
go
|
func (s *Action) TemplatesComplete(ctx context.Context, c *cli.Context) {
tree, err := s.Store.TemplateTree(ctx)
if err != nil {
fmt.Fprintln(stdout, err)
return
}
for _, v := range tree.List(0) {
fmt.Fprintln(stdout, v)
}
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"TemplatesComplete",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"{",
"tree",
",",
"err",
":=",
"s",
".",
"Store",
".",
"TemplateTree",
"(",
"ctx",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Fprintln",
"(",
"stdout",
",",
"err",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"tree",
".",
"List",
"(",
"0",
")",
"{",
"fmt",
".",
"Fprintln",
"(",
"stdout",
",",
"v",
")",
"\n",
"}",
"\n",
"}"
] |
// TemplatesComplete prints a list of all templates for bash completion
|
[
"TemplatesComplete",
"prints",
"a",
"list",
"of",
"all",
"templates",
"for",
"bash",
"completion"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/templates.go#L105-L115
|
train
|
gopasspw/gopass
|
pkg/backend/crypto/gpg/cli/version.go
|
Version
|
func (g *GPG) Version(ctx context.Context) semver.Version {
return version(ctx, g.Binary())
}
|
go
|
func (g *GPG) Version(ctx context.Context) semver.Version {
return version(ctx, g.Binary())
}
|
[
"func",
"(",
"g",
"*",
"GPG",
")",
"Version",
"(",
"ctx",
"context",
".",
"Context",
")",
"semver",
".",
"Version",
"{",
"return",
"version",
"(",
"ctx",
",",
"g",
".",
"Binary",
"(",
")",
")",
"\n",
"}"
] |
// Version will returns GPG version information
|
[
"Version",
"will",
"returns",
"GPG",
"version",
"information"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/gpg/cli/version.go#L33-L35
|
train
|
gopasspw/gopass
|
pkg/backend/crypto/xc/xcpb/identity.go
|
ID
|
func (i Identity) ID() string {
out := i.Name
if i.Comment != "" {
out += " (" + i.Comment + ")"
}
out += " <" + i.Email + ">"
return out
}
|
go
|
func (i Identity) ID() string {
out := i.Name
if i.Comment != "" {
out += " (" + i.Comment + ")"
}
out += " <" + i.Email + ">"
return out
}
|
[
"func",
"(",
"i",
"Identity",
")",
"ID",
"(",
")",
"string",
"{",
"out",
":=",
"i",
".",
"Name",
"\n",
"if",
"i",
".",
"Comment",
"!=",
"\"",
"\"",
"{",
"out",
"+=",
"\"",
"\"",
"+",
"i",
".",
"Comment",
"+",
"\"",
"\"",
"\n",
"}",
"\n",
"out",
"+=",
"\"",
"\"",
"+",
"i",
".",
"Email",
"+",
"\"",
"\"",
"\n",
"return",
"out",
"\n",
"}"
] |
// ID returns the GPG ID format
|
[
"ID",
"returns",
"the",
"GPG",
"ID",
"format"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/xcpb/identity.go#L4-L11
|
train
|
gopasspw/gopass
|
pkg/store/root/write.go
|
Set
|
func (r *Store) Set(ctx context.Context, name string, sec store.Secret) error {
ctx, store, name := r.getStore(ctx, name)
return store.Set(ctx, name, sec)
}
|
go
|
func (r *Store) Set(ctx context.Context, name string, sec store.Secret) error {
ctx, store, name := r.getStore(ctx, name)
return store.Set(ctx, name, sec)
}
|
[
"func",
"(",
"r",
"*",
"Store",
")",
"Set",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
"string",
",",
"sec",
"store",
".",
"Secret",
")",
"error",
"{",
"ctx",
",",
"store",
",",
"name",
":=",
"r",
".",
"getStore",
"(",
"ctx",
",",
"name",
")",
"\n",
"return",
"store",
".",
"Set",
"(",
"ctx",
",",
"name",
",",
"sec",
")",
"\n",
"}"
] |
// Set encodes and write the ciphertext of one entry to disk
|
[
"Set",
"encodes",
"and",
"write",
"the",
"ciphertext",
"of",
"one",
"entry",
"to",
"disk"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/root/write.go#L10-L13
|
train
|
gopasspw/gopass
|
pkg/agent/client/context.go
|
WithClient
|
func WithClient(ctx context.Context, c *Client) context.Context {
return context.WithValue(ctx, ctxKeyClient, c)
}
|
go
|
func WithClient(ctx context.Context, c *Client) context.Context {
return context.WithValue(ctx, ctxKeyClient, c)
}
|
[
"func",
"WithClient",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"Client",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyClient",
",",
"c",
")",
"\n",
"}"
] |
// WithClient returns a context with a client instance set.
|
[
"WithClient",
"returns",
"a",
"context",
"with",
"a",
"client",
"instance",
"set",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/context.go#L12-L14
|
train
|
gopasspw/gopass
|
pkg/agent/client/context.go
|
GetClient
|
func GetClient(ctx context.Context) *Client {
c, ok := ctx.Value(ctxKeyClient).(*Client)
if !ok {
return nil
}
return c
}
|
go
|
func GetClient(ctx context.Context) *Client {
c, ok := ctx.Value(ctxKeyClient).(*Client)
if !ok {
return nil
}
return c
}
|
[
"func",
"GetClient",
"(",
"ctx",
"context",
".",
"Context",
")",
"*",
"Client",
"{",
"c",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyClient",
")",
".",
"(",
"*",
"Client",
")",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] |
// GetClient returns a client instance, if set. May be nil.
|
[
"GetClient",
"returns",
"a",
"client",
"instance",
"if",
"set",
".",
"May",
"be",
"nil",
"."
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/agent/client/context.go#L17-L23
|
train
|
gopasspw/gopass
|
pkg/action/update.go
|
Update
|
func (s *Action) Update(ctx context.Context, c *cli.Context) error {
pre := c.Bool("pre")
if s.version.String() == "0.0.0+HEAD" {
out.Error(ctx, "Can not check version against HEAD")
return nil
}
if err := updater.Update(ctx, pre, s.version); err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to update gopass: %s", err)
}
return nil
}
|
go
|
func (s *Action) Update(ctx context.Context, c *cli.Context) error {
pre := c.Bool("pre")
if s.version.String() == "0.0.0+HEAD" {
out.Error(ctx, "Can not check version against HEAD")
return nil
}
if err := updater.Update(ctx, pre, s.version); err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to update gopass: %s", err)
}
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"pre",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"s",
".",
"version",
".",
"String",
"(",
")",
"==",
"\"",
"\"",
"{",
"out",
".",
"Error",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"updater",
".",
"Update",
"(",
"ctx",
",",
"pre",
",",
"s",
".",
"version",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUnknown",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Update will start the interactive update assistant
|
[
"Update",
"will",
"start",
"the",
"interactive",
"update",
"assistant"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/update.go#L13-L25
|
train
|
gopasspw/gopass
|
pkg/clipboard/unclip.go
|
Clear
|
func Clear(ctx context.Context, checksum string, force bool) error {
if clipboard.Unsupported {
return ErrNotSupported
}
cur, err := clipboard.ReadAll()
if err != nil {
return errors.Wrapf(err, "failed to read clipboard: %s", err)
}
hash := fmt.Sprintf("%x", sha256.Sum256([]byte(cur)))
if hash != checksum && !force {
return nil
}
if err := clipboard.WriteAll(""); err != nil {
_ = notify.Notify(ctx, "gopass - clipboard", "Failed to clear clipboard")
return errors.Wrapf(err, "failed to write clipboard: %s", err)
}
if err := clearClipboardHistory(ctx); err != nil {
_ = notify.Notify(ctx, "gopass - clipboard", "Failed to clear clipboard history")
return errors.Wrapf(err, "failed to clear clipboard history: %s", err)
}
if err := notify.Notify(ctx, "gopass -clipboard", "Clipboard has been cleared"); err != nil {
return errors.Wrapf(err, "failed to send unclip notification: %s", err)
}
return nil
}
|
go
|
func Clear(ctx context.Context, checksum string, force bool) error {
if clipboard.Unsupported {
return ErrNotSupported
}
cur, err := clipboard.ReadAll()
if err != nil {
return errors.Wrapf(err, "failed to read clipboard: %s", err)
}
hash := fmt.Sprintf("%x", sha256.Sum256([]byte(cur)))
if hash != checksum && !force {
return nil
}
if err := clipboard.WriteAll(""); err != nil {
_ = notify.Notify(ctx, "gopass - clipboard", "Failed to clear clipboard")
return errors.Wrapf(err, "failed to write clipboard: %s", err)
}
if err := clearClipboardHistory(ctx); err != nil {
_ = notify.Notify(ctx, "gopass - clipboard", "Failed to clear clipboard history")
return errors.Wrapf(err, "failed to clear clipboard history: %s", err)
}
if err := notify.Notify(ctx, "gopass -clipboard", "Clipboard has been cleared"); err != nil {
return errors.Wrapf(err, "failed to send unclip notification: %s", err)
}
return nil
}
|
[
"func",
"Clear",
"(",
"ctx",
"context",
".",
"Context",
",",
"checksum",
"string",
",",
"force",
"bool",
")",
"error",
"{",
"if",
"clipboard",
".",
"Unsupported",
"{",
"return",
"ErrNotSupported",
"\n",
"}",
"\n\n",
"cur",
",",
"err",
":=",
"clipboard",
".",
"ReadAll",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"hash",
":=",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"sha256",
".",
"Sum256",
"(",
"[",
"]",
"byte",
"(",
"cur",
")",
")",
")",
"\n",
"if",
"hash",
"!=",
"checksum",
"&&",
"!",
"force",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"clipboard",
".",
"WriteAll",
"(",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"_",
"=",
"notify",
".",
"Notify",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"clearClipboardHistory",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"_",
"=",
"notify",
".",
"Notify",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
"\n",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"notify",
".",
"Notify",
"(",
"ctx",
",",
"\"",
"\"",
",",
"\"",
"\"",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"nil",
"\n",
"}"
] |
// Clear will attempt to erase the clipboard
|
[
"Clear",
"will",
"attempt",
"to",
"erase",
"the",
"clipboard"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/clipboard/unclip.go#L15-L45
|
train
|
gopasspw/gopass
|
pkg/notify/notify_darwin.go
|
Notify
|
func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
osas, err := exec.LookPath("osascript")
if err != nil {
return err
}
return exec.Command(
osas,
"-e",
`display notification "`+msg+`" with title "`+subj+`"`,
).Start()
}
|
go
|
func Notify(ctx context.Context, subj, msg string) error {
if os.Getenv("GOPASS_NO_NOTIFY") != "" || !ctxutil.IsNotifications(ctx) {
return nil
}
osas, err := exec.LookPath("osascript")
if err != nil {
return err
}
return exec.Command(
osas,
"-e",
`display notification "`+msg+`" with title "`+subj+`"`,
).Start()
}
|
[
"func",
"Notify",
"(",
"ctx",
"context",
".",
"Context",
",",
"subj",
",",
"msg",
"string",
")",
"error",
"{",
"if",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
"!=",
"\"",
"\"",
"||",
"!",
"ctxutil",
".",
"IsNotifications",
"(",
"ctx",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"osas",
",",
"err",
":=",
"exec",
".",
"LookPath",
"(",
"\"",
"\"",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"exec",
".",
"Command",
"(",
"osas",
",",
"\"",
"\"",
",",
"`display notification \"`",
"+",
"msg",
"+",
"`\" with title \"`",
"+",
"subj",
"+",
"`\"`",
",",
")",
".",
"Start",
"(",
")",
"\n",
"}"
] |
// Notify displays a desktop notification using osascript
|
[
"Notify",
"displays",
"a",
"desktop",
"notification",
"using",
"osascript"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/notify/notify_darwin.go#L14-L28
|
train
|
gopasspw/gopass
|
pkg/action/show.go
|
Show
|
func (s *Action) Show(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
key := c.Args().Get(1)
ctx = s.Store.WithConfig(ctx, name)
ctx = WithClip(ctx, c.Bool("clip"))
ctx = WithForce(ctx, c.Bool("force"))
ctx = WithPrintQR(ctx, c.Bool("qr"))
ctx = WithPasswordOnly(ctx, c.Bool("password"))
ctx = WithRevision(ctx, c.String("revision"))
if c.Bool("sync") {
if err := s.sync(out.WithHidden(ctx, true), c, s.Store.MountPoint(name)); err != nil {
out.Error(ctx, "Failed to sync %s: %s", name, err)
}
}
if err := s.show(ctx, c, name, key, true); err != nil {
return ExitError(ctx, ExitDecrypt, err, "%s", err)
}
return nil
}
|
go
|
func (s *Action) Show(ctx context.Context, c *cli.Context) error {
name := c.Args().First()
key := c.Args().Get(1)
ctx = s.Store.WithConfig(ctx, name)
ctx = WithClip(ctx, c.Bool("clip"))
ctx = WithForce(ctx, c.Bool("force"))
ctx = WithPrintQR(ctx, c.Bool("qr"))
ctx = WithPasswordOnly(ctx, c.Bool("password"))
ctx = WithRevision(ctx, c.String("revision"))
if c.Bool("sync") {
if err := s.sync(out.WithHidden(ctx, true), c, s.Store.MountPoint(name)); err != nil {
out.Error(ctx, "Failed to sync %s: %s", name, err)
}
}
if err := s.show(ctx, c, name, key, true); err != nil {
return ExitError(ctx, ExitDecrypt, err, "%s", err)
}
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"Show",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"First",
"(",
")",
"\n",
"key",
":=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"1",
")",
"\n\n",
"ctx",
"=",
"s",
".",
"Store",
".",
"WithConfig",
"(",
"ctx",
",",
"name",
")",
"\n",
"ctx",
"=",
"WithClip",
"(",
"ctx",
",",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
")",
"\n",
"ctx",
"=",
"WithForce",
"(",
"ctx",
",",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
")",
"\n",
"ctx",
"=",
"WithPrintQR",
"(",
"ctx",
",",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
")",
"\n",
"ctx",
"=",
"WithPasswordOnly",
"(",
"ctx",
",",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
")",
"\n",
"ctx",
"=",
"WithRevision",
"(",
"ctx",
",",
"c",
".",
"String",
"(",
"\"",
"\"",
")",
")",
"\n\n",
"if",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"{",
"if",
"err",
":=",
"s",
".",
"sync",
"(",
"out",
".",
"WithHidden",
"(",
"ctx",
",",
"true",
")",
",",
"c",
",",
"s",
".",
"Store",
".",
"MountPoint",
"(",
"name",
")",
")",
";",
"err",
"!=",
"nil",
"{",
"out",
".",
"Error",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"err",
":=",
"s",
".",
"show",
"(",
"ctx",
",",
"c",
",",
"name",
",",
"key",
",",
"true",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitDecrypt",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// Show the content of a secret file
|
[
"Show",
"the",
"content",
"of",
"a",
"secret",
"file"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/show.go#L25-L46
|
train
|
gopasspw/gopass
|
pkg/action/show.go
|
showHandleRevision
|
func (s *Action) showHandleRevision(ctx context.Context, c *cli.Context, name, key, revision string) error {
sec, err := s.Store.GetRevision(ctx, name, revision)
if err != nil {
return s.showHandleError(ctx, c, name, false, err)
}
return s.showHandleOutput(ctx, name, key, sec)
}
|
go
|
func (s *Action) showHandleRevision(ctx context.Context, c *cli.Context, name, key, revision string) error {
sec, err := s.Store.GetRevision(ctx, name, revision)
if err != nil {
return s.showHandleError(ctx, c, name, false, err)
}
return s.showHandleOutput(ctx, name, key, sec)
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"showHandleRevision",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"name",
",",
"key",
",",
"revision",
"string",
")",
"error",
"{",
"sec",
",",
"err",
":=",
"s",
".",
"Store",
".",
"GetRevision",
"(",
"ctx",
",",
"name",
",",
"revision",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"s",
".",
"showHandleError",
"(",
"ctx",
",",
"c",
",",
"name",
",",
"false",
",",
"err",
")",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"showHandleOutput",
"(",
"ctx",
",",
"name",
",",
"key",
",",
"sec",
")",
"\n",
"}"
] |
// showHandleRevision displays a single revision
|
[
"showHandleRevision",
"displays",
"a",
"single",
"revision"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/show.go#L79-L86
|
train
|
gopasspw/gopass
|
pkg/action/show.go
|
showHandleOutput
|
func (s *Action) showHandleOutput(ctx context.Context, name, key string, sec store.Secret) error {
var content string
switch {
case key != "":
val, err := sec.Value(key)
if err != nil {
return s.showHandleYAMLError(ctx, name, key, err)
}
if IsClip(ctx) {
return clipboard.CopyTo(ctx, name, []byte(val))
}
content = val
case IsPrintQR(ctx):
return s.showPrintQR(ctx, name, sec.Password())
case IsClip(ctx):
return clipboard.CopyTo(ctx, name, []byte(sec.Password()))
default:
switch {
case IsPasswordOnly(ctx):
content = sec.Password()
case ctxutil.IsShowSafeContent(ctx) && !IsForce(ctx):
content = sec.Body()
if content == "" {
if ctxutil.IsAutoClip(ctx) {
out.Yellow(ctx, "No safe content to display, you can force display with show -f.\nCopying password instead.")
return clipboard.CopyTo(ctx, name, []byte(sec.Password()))
}
return ExitError(ctx, ExitNotFound, store.ErrNoBody, store.ErrNoBody.Error())
}
default:
buf, err := sec.Bytes()
if err != nil {
return ExitError(ctx, ExitUnknown, err, "failed to encode secret: %s", err)
}
content = string(buf)
}
}
ctx = out.WithNewline(ctx, ctxutil.IsTerminal(ctx) && !strings.HasSuffix(content, "\n"))
out.Yellow(ctx, content)
return nil
}
|
go
|
func (s *Action) showHandleOutput(ctx context.Context, name, key string, sec store.Secret) error {
var content string
switch {
case key != "":
val, err := sec.Value(key)
if err != nil {
return s.showHandleYAMLError(ctx, name, key, err)
}
if IsClip(ctx) {
return clipboard.CopyTo(ctx, name, []byte(val))
}
content = val
case IsPrintQR(ctx):
return s.showPrintQR(ctx, name, sec.Password())
case IsClip(ctx):
return clipboard.CopyTo(ctx, name, []byte(sec.Password()))
default:
switch {
case IsPasswordOnly(ctx):
content = sec.Password()
case ctxutil.IsShowSafeContent(ctx) && !IsForce(ctx):
content = sec.Body()
if content == "" {
if ctxutil.IsAutoClip(ctx) {
out.Yellow(ctx, "No safe content to display, you can force display with show -f.\nCopying password instead.")
return clipboard.CopyTo(ctx, name, []byte(sec.Password()))
}
return ExitError(ctx, ExitNotFound, store.ErrNoBody, store.ErrNoBody.Error())
}
default:
buf, err := sec.Bytes()
if err != nil {
return ExitError(ctx, ExitUnknown, err, "failed to encode secret: %s", err)
}
content = string(buf)
}
}
ctx = out.WithNewline(ctx, ctxutil.IsTerminal(ctx) && !strings.HasSuffix(content, "\n"))
out.Yellow(ctx, content)
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"showHandleOutput",
"(",
"ctx",
"context",
".",
"Context",
",",
"name",
",",
"key",
"string",
",",
"sec",
"store",
".",
"Secret",
")",
"error",
"{",
"var",
"content",
"string",
"\n\n",
"switch",
"{",
"case",
"key",
"!=",
"\"",
"\"",
":",
"val",
",",
"err",
":=",
"sec",
".",
"Value",
"(",
"key",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"s",
".",
"showHandleYAMLError",
"(",
"ctx",
",",
"name",
",",
"key",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"IsClip",
"(",
"ctx",
")",
"{",
"return",
"clipboard",
".",
"CopyTo",
"(",
"ctx",
",",
"name",
",",
"[",
"]",
"byte",
"(",
"val",
")",
")",
"\n",
"}",
"\n",
"content",
"=",
"val",
"\n",
"case",
"IsPrintQR",
"(",
"ctx",
")",
":",
"return",
"s",
".",
"showPrintQR",
"(",
"ctx",
",",
"name",
",",
"sec",
".",
"Password",
"(",
")",
")",
"\n",
"case",
"IsClip",
"(",
"ctx",
")",
":",
"return",
"clipboard",
".",
"CopyTo",
"(",
"ctx",
",",
"name",
",",
"[",
"]",
"byte",
"(",
"sec",
".",
"Password",
"(",
")",
")",
")",
"\n",
"default",
":",
"switch",
"{",
"case",
"IsPasswordOnly",
"(",
"ctx",
")",
":",
"content",
"=",
"sec",
".",
"Password",
"(",
")",
"\n",
"case",
"ctxutil",
".",
"IsShowSafeContent",
"(",
"ctx",
")",
"&&",
"!",
"IsForce",
"(",
"ctx",
")",
":",
"content",
"=",
"sec",
".",
"Body",
"(",
")",
"\n",
"if",
"content",
"==",
"\"",
"\"",
"{",
"if",
"ctxutil",
".",
"IsAutoClip",
"(",
"ctx",
")",
"{",
"out",
".",
"Yellow",
"(",
"ctx",
",",
"\"",
"\\n",
"\"",
")",
"\n",
"return",
"clipboard",
".",
"CopyTo",
"(",
"ctx",
",",
"name",
",",
"[",
"]",
"byte",
"(",
"sec",
".",
"Password",
"(",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitNotFound",
",",
"store",
".",
"ErrNoBody",
",",
"store",
".",
"ErrNoBody",
".",
"Error",
"(",
")",
")",
"\n",
"}",
"\n",
"default",
":",
"buf",
",",
"err",
":=",
"sec",
".",
"Bytes",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUnknown",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"content",
"=",
"string",
"(",
"buf",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"ctx",
"=",
"out",
".",
"WithNewline",
"(",
"ctx",
",",
"ctxutil",
".",
"IsTerminal",
"(",
"ctx",
")",
"&&",
"!",
"strings",
".",
"HasSuffix",
"(",
"content",
",",
"\"",
"\\n",
"\"",
")",
")",
"\n",
"out",
".",
"Yellow",
"(",
"ctx",
",",
"content",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// showHandleOutput displays a secret
|
[
"showHandleOutput",
"displays",
"a",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/show.go#L89-L131
|
train
|
gopasspw/gopass
|
pkg/action/show.go
|
showHandleError
|
func (s *Action) showHandleError(ctx context.Context, c *cli.Context, name string, recurse bool, err error) error {
if err != store.ErrNotFound || !recurse || !ctxutil.IsTerminal(ctx) {
return ExitError(ctx, ExitUnknown, err, "failed to retrieve secret '%s': %s", name, err)
}
out.Yellow(ctx, "Entry '%s' not found. Starting search...", name)
if err := s.Find(ctx, c); err != nil {
return ExitError(ctx, ExitNotFound, err, "%s", err)
}
os.Exit(ExitNotFound)
return nil
}
|
go
|
func (s *Action) showHandleError(ctx context.Context, c *cli.Context, name string, recurse bool, err error) error {
if err != store.ErrNotFound || !recurse || !ctxutil.IsTerminal(ctx) {
return ExitError(ctx, ExitUnknown, err, "failed to retrieve secret '%s': %s", name, err)
}
out.Yellow(ctx, "Entry '%s' not found. Starting search...", name)
if err := s.Find(ctx, c); err != nil {
return ExitError(ctx, ExitNotFound, err, "%s", err)
}
os.Exit(ExitNotFound)
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"showHandleError",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
",",
"name",
"string",
",",
"recurse",
"bool",
",",
"err",
"error",
")",
"error",
"{",
"if",
"err",
"!=",
"store",
".",
"ErrNotFound",
"||",
"!",
"recurse",
"||",
"!",
"ctxutil",
".",
"IsTerminal",
"(",
"ctx",
")",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUnknown",
",",
"err",
",",
"\"",
"\"",
",",
"name",
",",
"err",
")",
"\n",
"}",
"\n",
"out",
".",
"Yellow",
"(",
"ctx",
",",
"\"",
"\"",
",",
"name",
")",
"\n",
"if",
"err",
":=",
"s",
".",
"Find",
"(",
"ctx",
",",
"c",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitNotFound",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"os",
".",
"Exit",
"(",
"ExitNotFound",
")",
"\n",
"return",
"nil",
"\n",
"}"
] |
// showHandleError handles errors retrieving secrets
|
[
"showHandleError",
"handles",
"errors",
"retrieving",
"secrets"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/show.go#L134-L144
|
train
|
gopasspw/gopass
|
pkg/updater/update.go
|
Update
|
func Update(ctx context.Context, pre bool, version semver.Version) error {
if err := IsUpdateable(ctx); err != nil {
out.Error(ctx, "Your gopass binary is externally managed. Can not update.")
out.Debug(ctx, "Error: %s", err)
return nil
}
ok, err := termio.AskForBool(ctx, "Do you want to check for available updates?", true)
if err != nil {
return err
}
if !ok {
return nil
}
r, err := LatestRelease(ctx, pre || len(version.Pre) > 0)
if err != nil {
return err
}
out.Debug(ctx, "Current: %s - Latest: %s", version.String(), r.Version().String())
if version.GTE(r.Version()) {
out.Green(ctx, "gopass is up to date (%s)", version.String())
return nil
}
out.Debug(ctx, "Assets: %+v", r.Assets)
for _, asset := range r.Assets {
name := strings.TrimSuffix(strings.TrimPrefix(asset.Name, "gopass-"), ".tar.gz")
p := strings.Split(name, "-")
if len(p) < 3 {
continue
}
if p[len(p)-2] != runtime.GOOS {
continue
}
if p[len(p)-1] != runtime.GOARCH {
continue
}
if asset.URL == "" {
continue
}
if err := updateTo(ctx, r.Version().String(), asset.URL); err != nil {
return errors.Wrapf(err, "Failed to update gopass: %s", err)
}
return nil
}
return errors.New("no supported binary found")
}
|
go
|
func Update(ctx context.Context, pre bool, version semver.Version) error {
if err := IsUpdateable(ctx); err != nil {
out.Error(ctx, "Your gopass binary is externally managed. Can not update.")
out.Debug(ctx, "Error: %s", err)
return nil
}
ok, err := termio.AskForBool(ctx, "Do you want to check for available updates?", true)
if err != nil {
return err
}
if !ok {
return nil
}
r, err := LatestRelease(ctx, pre || len(version.Pre) > 0)
if err != nil {
return err
}
out.Debug(ctx, "Current: %s - Latest: %s", version.String(), r.Version().String())
if version.GTE(r.Version()) {
out.Green(ctx, "gopass is up to date (%s)", version.String())
return nil
}
out.Debug(ctx, "Assets: %+v", r.Assets)
for _, asset := range r.Assets {
name := strings.TrimSuffix(strings.TrimPrefix(asset.Name, "gopass-"), ".tar.gz")
p := strings.Split(name, "-")
if len(p) < 3 {
continue
}
if p[len(p)-2] != runtime.GOOS {
continue
}
if p[len(p)-1] != runtime.GOARCH {
continue
}
if asset.URL == "" {
continue
}
if err := updateTo(ctx, r.Version().String(), asset.URL); err != nil {
return errors.Wrapf(err, "Failed to update gopass: %s", err)
}
return nil
}
return errors.New("no supported binary found")
}
|
[
"func",
"Update",
"(",
"ctx",
"context",
".",
"Context",
",",
"pre",
"bool",
",",
"version",
"semver",
".",
"Version",
")",
"error",
"{",
"if",
"err",
":=",
"IsUpdateable",
"(",
"ctx",
")",
";",
"err",
"!=",
"nil",
"{",
"out",
".",
"Error",
"(",
"ctx",
",",
"\"",
"\"",
")",
"\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"ok",
",",
"err",
":=",
"termio",
".",
"AskForBool",
"(",
"ctx",
",",
"\"",
"\"",
",",
"true",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"!",
"ok",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
",",
"err",
":=",
"LatestRelease",
"(",
"ctx",
",",
"pre",
"||",
"len",
"(",
"version",
".",
"Pre",
")",
">",
"0",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"version",
".",
"String",
"(",
")",
",",
"r",
".",
"Version",
"(",
")",
".",
"String",
"(",
")",
")",
"\n",
"if",
"version",
".",
"GTE",
"(",
"r",
".",
"Version",
"(",
")",
")",
"{",
"out",
".",
"Green",
"(",
"ctx",
",",
"\"",
"\"",
",",
"version",
".",
"String",
"(",
")",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"r",
".",
"Assets",
")",
"\n",
"for",
"_",
",",
"asset",
":=",
"range",
"r",
".",
"Assets",
"{",
"name",
":=",
"strings",
".",
"TrimSuffix",
"(",
"strings",
".",
"TrimPrefix",
"(",
"asset",
".",
"Name",
",",
"\"",
"\"",
")",
",",
"\"",
"\"",
")",
"\n",
"p",
":=",
"strings",
".",
"Split",
"(",
"name",
",",
"\"",
"\"",
")",
"\n",
"if",
"len",
"(",
"p",
")",
"<",
"3",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"p",
"[",
"len",
"(",
"p",
")",
"-",
"2",
"]",
"!=",
"runtime",
".",
"GOOS",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"p",
"[",
"len",
"(",
"p",
")",
"-",
"1",
"]",
"!=",
"runtime",
".",
"GOARCH",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"asset",
".",
"URL",
"==",
"\"",
"\"",
"{",
"continue",
"\n",
"}",
"\n",
"if",
"err",
":=",
"updateTo",
"(",
"ctx",
",",
"r",
".",
"Version",
"(",
")",
".",
"String",
"(",
")",
",",
"asset",
".",
"URL",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// Update will start hte interactive update assistant
|
[
"Update",
"will",
"start",
"hte",
"interactive",
"update",
"assistant"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/updater/update.go#L41-L89
|
train
|
gopasspw/gopass
|
pkg/action/history.go
|
History
|
func (s *Action) History(ctx context.Context, c *cli.Context) error {
name := c.Args().Get(0)
showPassword := c.Bool("password")
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s history <NAME>", s.Name)
}
if !s.Store.Exists(ctx, name) {
return ExitError(ctx, ExitNotFound, nil, "Secret not found")
}
revs, err := s.Store.ListRevisions(ctx, name)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to get revisions: %s", err)
}
for _, rev := range revs {
pw := ""
if showPassword {
sec, err := s.Store.GetRevision(ctx, name, rev.Hash)
if err != nil {
out.Debug(ctx, "Failed to get revision '%s' of '%s': %s", rev.Hash, name, err)
}
if err == nil {
pw = " - " + sec.Password()
}
}
out.Print(ctx, "%s - %s <%s> - %s - %s%s", rev.Hash[:8], rev.AuthorName, rev.AuthorEmail, rev.Date.Format(time.RFC3339), rev.Subject, pw)
}
return nil
}
|
go
|
func (s *Action) History(ctx context.Context, c *cli.Context) error {
name := c.Args().Get(0)
showPassword := c.Bool("password")
if name == "" {
return ExitError(ctx, ExitUsage, nil, "Usage: %s history <NAME>", s.Name)
}
if !s.Store.Exists(ctx, name) {
return ExitError(ctx, ExitNotFound, nil, "Secret not found")
}
revs, err := s.Store.ListRevisions(ctx, name)
if err != nil {
return ExitError(ctx, ExitUnknown, err, "Failed to get revisions: %s", err)
}
for _, rev := range revs {
pw := ""
if showPassword {
sec, err := s.Store.GetRevision(ctx, name, rev.Hash)
if err != nil {
out.Debug(ctx, "Failed to get revision '%s' of '%s': %s", rev.Hash, name, err)
}
if err == nil {
pw = " - " + sec.Password()
}
}
out.Print(ctx, "%s - %s <%s> - %s - %s%s", rev.Hash[:8], rev.AuthorName, rev.AuthorEmail, rev.Date.Format(time.RFC3339), rev.Subject, pw)
}
return nil
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"History",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"name",
":=",
"c",
".",
"Args",
"(",
")",
".",
"Get",
"(",
"0",
")",
"\n",
"showPassword",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"name",
"==",
"\"",
"\"",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUsage",
",",
"nil",
",",
"\"",
"\"",
",",
"s",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"s",
".",
"Store",
".",
"Exists",
"(",
"ctx",
",",
"name",
")",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitNotFound",
",",
"nil",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"revs",
",",
"err",
":=",
"s",
".",
"Store",
".",
"ListRevisions",
"(",
"ctx",
",",
"name",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUnknown",
",",
"err",
",",
"\"",
"\"",
",",
"err",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"rev",
":=",
"range",
"revs",
"{",
"pw",
":=",
"\"",
"\"",
"\n",
"if",
"showPassword",
"{",
"sec",
",",
"err",
":=",
"s",
".",
"Store",
".",
"GetRevision",
"(",
"ctx",
",",
"name",
",",
"rev",
".",
"Hash",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"out",
".",
"Debug",
"(",
"ctx",
",",
"\"",
"\"",
",",
"rev",
".",
"Hash",
",",
"name",
",",
"err",
")",
"\n",
"}",
"\n",
"if",
"err",
"==",
"nil",
"{",
"pw",
"=",
"\"",
"\"",
"+",
"sec",
".",
"Password",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"out",
".",
"Print",
"(",
"ctx",
",",
"\"",
"\"",
",",
"rev",
".",
"Hash",
"[",
":",
"8",
"]",
",",
"rev",
".",
"AuthorName",
",",
"rev",
".",
"AuthorEmail",
",",
"rev",
".",
"Date",
".",
"Format",
"(",
"time",
".",
"RFC3339",
")",
",",
"rev",
".",
"Subject",
",",
"pw",
")",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}"
] |
// History displays the history of a given secret
|
[
"History",
"displays",
"the",
"history",
"of",
"a",
"given",
"secret"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/history.go#L13-L44
|
train
|
gopasspw/gopass
|
pkg/fsutil/fsutil.go
|
CleanPath
|
func CleanPath(path string) string {
// http://stackoverflow.com/questions/17609732/expand-tilde-to-home-directory
if len(path) > 1 && path[:2] == "~/" {
usr, _ := user.Current()
dir := usr.HomeDir
path = strings.Replace(path, "~/", dir+"/", 1)
}
if p, err := filepath.Abs(path); err == nil {
return p
}
return filepath.Clean(path)
}
|
go
|
func CleanPath(path string) string {
// http://stackoverflow.com/questions/17609732/expand-tilde-to-home-directory
if len(path) > 1 && path[:2] == "~/" {
usr, _ := user.Current()
dir := usr.HomeDir
path = strings.Replace(path, "~/", dir+"/", 1)
}
if p, err := filepath.Abs(path); err == nil {
return p
}
return filepath.Clean(path)
}
|
[
"func",
"CleanPath",
"(",
"path",
"string",
")",
"string",
"{",
"// http://stackoverflow.com/questions/17609732/expand-tilde-to-home-directory",
"if",
"len",
"(",
"path",
")",
">",
"1",
"&&",
"path",
"[",
":",
"2",
"]",
"==",
"\"",
"\"",
"{",
"usr",
",",
"_",
":=",
"user",
".",
"Current",
"(",
")",
"\n",
"dir",
":=",
"usr",
".",
"HomeDir",
"\n",
"path",
"=",
"strings",
".",
"Replace",
"(",
"path",
",",
"\"",
"\"",
",",
"dir",
"+",
"\"",
"\"",
",",
"1",
")",
"\n",
"}",
"\n",
"if",
"p",
",",
"err",
":=",
"filepath",
".",
"Abs",
"(",
"path",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"p",
"\n",
"}",
"\n",
"return",
"filepath",
".",
"Clean",
"(",
"path",
")",
"\n",
"}"
] |
// CleanPath resolves common aliases in a path and cleans it as much as possible
|
[
"CleanPath",
"resolves",
"common",
"aliases",
"in",
"a",
"path",
"and",
"cleans",
"it",
"as",
"much",
"as",
"possible"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/fsutil/fsutil.go#L26-L37
|
train
|
gopasspw/gopass
|
pkg/fsutil/fsutil.go
|
IsFile
|
func IsFile(path string) bool {
fi, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
// not found
return false
}
fmt.Printf("failed to check dir %s: %s\n", path, err)
return false
}
return fi.Mode().IsRegular()
}
|
go
|
func IsFile(path string) bool {
fi, err := os.Stat(path)
if err != nil {
if os.IsNotExist(err) {
// not found
return false
}
fmt.Printf("failed to check dir %s: %s\n", path, err)
return false
}
return fi.Mode().IsRegular()
}
|
[
"func",
"IsFile",
"(",
"path",
"string",
")",
"bool",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Stat",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"os",
".",
"IsNotExist",
"(",
"err",
")",
"{",
"// not found",
"return",
"false",
"\n",
"}",
"\n",
"fmt",
".",
"Printf",
"(",
"\"",
"\\n",
"\"",
",",
"path",
",",
"err",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n\n",
"return",
"fi",
".",
"Mode",
"(",
")",
".",
"IsRegular",
"(",
")",
"\n",
"}"
] |
// IsFile checks if a certain path is actually a file
|
[
"IsFile",
"checks",
"if",
"a",
"certain",
"path",
"is",
"actually",
"a",
"file"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/fsutil/fsutil.go#L56-L68
|
train
|
gopasspw/gopass
|
pkg/fsutil/fsutil.go
|
IsEmptyDir
|
func IsEmptyDir(path string) (bool, error) {
empty := true
if err := filepath.Walk(path, func(fp string, fi os.FileInfo, ferr error) error {
if ferr != nil {
return ferr
}
if fi.IsDir() && (fi.Name() == "." || fi.Name() == "..") {
return filepath.SkipDir
}
if fi.Mode().IsRegular() {
empty = false
}
return nil
}); err != nil {
return false, err
}
return empty, nil
}
|
go
|
func IsEmptyDir(path string) (bool, error) {
empty := true
if err := filepath.Walk(path, func(fp string, fi os.FileInfo, ferr error) error {
if ferr != nil {
return ferr
}
if fi.IsDir() && (fi.Name() == "." || fi.Name() == "..") {
return filepath.SkipDir
}
if fi.Mode().IsRegular() {
empty = false
}
return nil
}); err != nil {
return false, err
}
return empty, nil
}
|
[
"func",
"IsEmptyDir",
"(",
"path",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"empty",
":=",
"true",
"\n",
"if",
"err",
":=",
"filepath",
".",
"Walk",
"(",
"path",
",",
"func",
"(",
"fp",
"string",
",",
"fi",
"os",
".",
"FileInfo",
",",
"ferr",
"error",
")",
"error",
"{",
"if",
"ferr",
"!=",
"nil",
"{",
"return",
"ferr",
"\n",
"}",
"\n",
"if",
"fi",
".",
"IsDir",
"(",
")",
"&&",
"(",
"fi",
".",
"Name",
"(",
")",
"==",
"\"",
"\"",
"||",
"fi",
".",
"Name",
"(",
")",
"==",
"\"",
"\"",
")",
"{",
"return",
"filepath",
".",
"SkipDir",
"\n",
"}",
"\n",
"if",
"fi",
".",
"Mode",
"(",
")",
".",
"IsRegular",
"(",
")",
"{",
"empty",
"=",
"false",
"\n",
"}",
"\n",
"return",
"nil",
"\n",
"}",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"false",
",",
"err",
"\n",
"}",
"\n",
"return",
"empty",
",",
"nil",
"\n",
"}"
] |
// IsEmptyDir checks if a certain path is an empty directory
|
[
"IsEmptyDir",
"checks",
"if",
"a",
"certain",
"path",
"is",
"an",
"empty",
"directory"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/fsutil/fsutil.go#L71-L88
|
train
|
gopasspw/gopass
|
pkg/fsutil/fsutil.go
|
Shred
|
func Shred(path string, runs int) error {
rand.Seed(time.Now().UnixNano())
fh, err := os.OpenFile(path, os.O_WRONLY, 0600)
if err != nil {
return errors.Wrapf(err, "failed to open file '%s'", path)
}
buf := make([]byte, 1024)
for i := 0; i < runs; i++ {
// overwrite using pseudo-random data n-1 times and
// use zeros in the last iteration
if i < runs-1 {
_, _ = rand.Read(buf)
} else {
buf = make([]byte, 1024)
}
if _, err := fh.Seek(0, 0); err != nil {
return errors.Wrapf(err, "failed to seek to 0,0")
}
if _, err := fh.Write(buf); err != nil {
if err != io.EOF {
return errors.Wrapf(err, "failed to write to file")
}
}
// if we fail to sync the written blocks to disk it'd be pointless
// do any further loops
if err := fh.Sync(); err != nil {
return errors.Wrapf(err, "failed to sync to disk")
}
}
if err := fh.Close(); err != nil {
return errors.Wrapf(err, "failed to close file after writing")
}
return os.Remove(path)
}
|
go
|
func Shred(path string, runs int) error {
rand.Seed(time.Now().UnixNano())
fh, err := os.OpenFile(path, os.O_WRONLY, 0600)
if err != nil {
return errors.Wrapf(err, "failed to open file '%s'", path)
}
buf := make([]byte, 1024)
for i := 0; i < runs; i++ {
// overwrite using pseudo-random data n-1 times and
// use zeros in the last iteration
if i < runs-1 {
_, _ = rand.Read(buf)
} else {
buf = make([]byte, 1024)
}
if _, err := fh.Seek(0, 0); err != nil {
return errors.Wrapf(err, "failed to seek to 0,0")
}
if _, err := fh.Write(buf); err != nil {
if err != io.EOF {
return errors.Wrapf(err, "failed to write to file")
}
}
// if we fail to sync the written blocks to disk it'd be pointless
// do any further loops
if err := fh.Sync(); err != nil {
return errors.Wrapf(err, "failed to sync to disk")
}
}
if err := fh.Close(); err != nil {
return errors.Wrapf(err, "failed to close file after writing")
}
return os.Remove(path)
}
|
[
"func",
"Shred",
"(",
"path",
"string",
",",
"runs",
"int",
")",
"error",
"{",
"rand",
".",
"Seed",
"(",
"time",
".",
"Now",
"(",
")",
".",
"UnixNano",
"(",
")",
")",
"\n",
"fh",
",",
"err",
":=",
"os",
".",
"OpenFile",
"(",
"path",
",",
"os",
".",
"O_WRONLY",
",",
"0600",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
",",
"path",
")",
"\n",
"}",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"runs",
";",
"i",
"++",
"{",
"// overwrite using pseudo-random data n-1 times and",
"// use zeros in the last iteration",
"if",
"i",
"<",
"runs",
"-",
"1",
"{",
"_",
",",
"_",
"=",
"rand",
".",
"Read",
"(",
"buf",
")",
"\n",
"}",
"else",
"{",
"buf",
"=",
"make",
"(",
"[",
"]",
"byte",
",",
"1024",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"fh",
".",
"Seek",
"(",
"0",
",",
"0",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"if",
"_",
",",
"err",
":=",
"fh",
".",
"Write",
"(",
"buf",
")",
";",
"err",
"!=",
"nil",
"{",
"if",
"err",
"!=",
"io",
".",
"EOF",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"// if we fail to sync the written blocks to disk it'd be pointless",
"// do any further loops",
"if",
"err",
":=",
"fh",
".",
"Sync",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"err",
":=",
"fh",
".",
"Close",
"(",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"errors",
".",
"Wrapf",
"(",
"err",
",",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"return",
"os",
".",
"Remove",
"(",
"path",
")",
"\n",
"}"
] |
// Shred overwrite the given file any number of times
|
[
"Shred",
"overwrite",
"the",
"given",
"file",
"any",
"number",
"of",
"times"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/fsutil/fsutil.go#L91-L125
|
train
|
gopasspw/gopass
|
pkg/action/copy.go
|
Copy
|
func (s *Action) Copy(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s cp <FROM> <TO>", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
return s.copy(ctx, from, to, force)
}
|
go
|
func (s *Action) Copy(ctx context.Context, c *cli.Context) error {
force := c.Bool("force")
if len(c.Args()) != 2 {
return ExitError(ctx, ExitUsage, nil, "Usage: %s cp <FROM> <TO>", s.Name)
}
from := c.Args()[0]
to := c.Args()[1]
return s.copy(ctx, from, to, force)
}
|
[
"func",
"(",
"s",
"*",
"Action",
")",
"Copy",
"(",
"ctx",
"context",
".",
"Context",
",",
"c",
"*",
"cli",
".",
"Context",
")",
"error",
"{",
"force",
":=",
"c",
".",
"Bool",
"(",
"\"",
"\"",
")",
"\n\n",
"if",
"len",
"(",
"c",
".",
"Args",
"(",
")",
")",
"!=",
"2",
"{",
"return",
"ExitError",
"(",
"ctx",
",",
"ExitUsage",
",",
"nil",
",",
"\"",
"\"",
",",
"s",
".",
"Name",
")",
"\n",
"}",
"\n\n",
"from",
":=",
"c",
".",
"Args",
"(",
")",
"[",
"0",
"]",
"\n",
"to",
":=",
"c",
".",
"Args",
"(",
")",
"[",
"1",
"]",
"\n\n",
"return",
"s",
".",
"copy",
"(",
"ctx",
",",
"from",
",",
"to",
",",
"force",
")",
"\n",
"}"
] |
// Copy the contents of a file to another one
|
[
"Copy",
"the",
"contents",
"of",
"a",
"file",
"to",
"another",
"one"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/action/copy.go#L13-L24
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
GetTemplate
|
func (s *Store) GetTemplate(context.Context, string) ([]byte, error) {
return nil, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) GetTemplate(context.Context, string) ([]byte, error) {
return nil, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"GetTemplate",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// GetTemplate is unsupported
|
[
"GetTemplate",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L16-L18
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
LookupTemplate
|
func (s *Store) LookupTemplate(context.Context, string) (string, []byte, bool) {
return "", nil, false
}
|
go
|
func (s *Store) LookupTemplate(context.Context, string) (string, []byte, bool) {
return "", nil, false
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"LookupTemplate",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"string",
",",
"[",
"]",
"byte",
",",
"bool",
")",
"{",
"return",
"\"",
"\"",
",",
"nil",
",",
"false",
"\n",
"}"
] |
// LookupTemplate is unsupported
|
[
"LookupTemplate",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L31-L33
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
SetTemplate
|
func (s *Store) SetTemplate(context.Context, string, []byte) error {
return fmt.Errorf("not supported")
}
|
go
|
func (s *Store) SetTemplate(context.Context, string, []byte) error {
return fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"SetTemplate",
"(",
"context",
".",
"Context",
",",
"string",
",",
"[",
"]",
"byte",
")",
"error",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// SetTemplate is unsupported
|
[
"SetTemplate",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L41-L43
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
TemplateTree
|
func (s *Store) TemplateTree(context.Context) (tree.Tree, error) {
return nil, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) TemplateTree(context.Context) (tree.Tree, error) {
return nil, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"TemplateTree",
"(",
"context",
".",
"Context",
")",
"(",
"tree",
".",
"Tree",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// TemplateTree is unsupported
|
[
"TemplateTree",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L46-L48
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
GetRecipients
|
func (s *Store) GetRecipients(context.Context, string) ([]string, error) {
return nil, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) GetRecipients(context.Context, string) ([]string, error) {
return nil, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"GetRecipients",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"[",
"]",
"string",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// GetRecipients is unsupported
|
[
"GetRecipients",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L56-L58
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
ExportMissingPublicKeys
|
func (s *Store) ExportMissingPublicKeys(context.Context, []string) (bool, error) {
return false, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) ExportMissingPublicKeys(context.Context, []string) (bool, error) {
return false, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"ExportMissingPublicKeys",
"(",
"context",
".",
"Context",
",",
"[",
"]",
"string",
")",
"(",
"bool",
",",
"error",
")",
"{",
"return",
"false",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// ExportMissingPublicKeys is unsupported
|
[
"ExportMissingPublicKeys",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L86-L88
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
GitInit
|
func (s *Store) GitInit(context.Context, string, string) error {
return fmt.Errorf("not supported")
}
|
go
|
func (s *Store) GitInit(context.Context, string, string) error {
return fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"GitInit",
"(",
"context",
".",
"Context",
",",
"string",
",",
"string",
")",
"error",
"{",
"return",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// GitInit is unsupported
|
[
"GitInit",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L106-L108
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
GetRevision
|
func (s *Store) GetRevision(context.Context, string, string) (store.Secret, error) {
return nil, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) GetRevision(context.Context, string, string) (store.Secret, error) {
return nil, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"GetRevision",
"(",
"context",
".",
"Context",
",",
"string",
",",
"string",
")",
"(",
"store",
".",
"Secret",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// GetRevision is unsupported
|
[
"GetRevision",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L111-L113
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
ListRevisions
|
func (s *Store) ListRevisions(context.Context, string) ([]backend.Revision, error) {
return nil, fmt.Errorf("not supported")
}
|
go
|
func (s *Store) ListRevisions(context.Context, string) ([]backend.Revision, error) {
return nil, fmt.Errorf("not supported")
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"ListRevisions",
"(",
"context",
".",
"Context",
",",
"string",
")",
"(",
"[",
"]",
"backend",
".",
"Revision",
",",
"error",
")",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// ListRevisions is unsupported
|
[
"ListRevisions",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L116-L118
|
train
|
gopasspw/gopass
|
pkg/store/vault/unsupported.go
|
Fsck
|
func (s *Store) Fsck(ctx context.Context, prefix string) error {
return nil
}
|
go
|
func (s *Store) Fsck(ctx context.Context, prefix string) error {
return nil
}
|
[
"func",
"(",
"s",
"*",
"Store",
")",
"Fsck",
"(",
"ctx",
"context",
".",
"Context",
",",
"prefix",
"string",
")",
"error",
"{",
"return",
"nil",
"\n",
"}"
] |
// Fsck is unsupported
|
[
"Fsck",
"is",
"unsupported"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/store/vault/unsupported.go#L121-L123
|
train
|
gopasspw/gopass
|
pkg/pwgen/pwgen.go
|
GeneratePassword
|
func GeneratePassword(length int, symbols bool) string {
chars := digits + upper + lower
if symbols {
chars += syms
}
if c := os.Getenv("GOPASS_CHARACTER_SET"); c != "" {
chars = c
}
if c := os.Getenv("GOPASS_EXTERNAL_PWGEN"); c != "" {
if pw, err := generateExternal(c); err == nil {
return pw
}
}
return GeneratePasswordCharsetCheck(length, chars)
}
|
go
|
func GeneratePassword(length int, symbols bool) string {
chars := digits + upper + lower
if symbols {
chars += syms
}
if c := os.Getenv("GOPASS_CHARACTER_SET"); c != "" {
chars = c
}
if c := os.Getenv("GOPASS_EXTERNAL_PWGEN"); c != "" {
if pw, err := generateExternal(c); err == nil {
return pw
}
}
return GeneratePasswordCharsetCheck(length, chars)
}
|
[
"func",
"GeneratePassword",
"(",
"length",
"int",
",",
"symbols",
"bool",
")",
"string",
"{",
"chars",
":=",
"digits",
"+",
"upper",
"+",
"lower",
"\n",
"if",
"symbols",
"{",
"chars",
"+=",
"syms",
"\n",
"}",
"\n",
"if",
"c",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"c",
"!=",
"\"",
"\"",
"{",
"chars",
"=",
"c",
"\n",
"}",
"\n",
"if",
"c",
":=",
"os",
".",
"Getenv",
"(",
"\"",
"\"",
")",
";",
"c",
"!=",
"\"",
"\"",
"{",
"if",
"pw",
",",
"err",
":=",
"generateExternal",
"(",
"c",
")",
";",
"err",
"==",
"nil",
"{",
"return",
"pw",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"GeneratePasswordCharsetCheck",
"(",
"length",
",",
"chars",
")",
"\n",
"}"
] |
// GeneratePassword generates a random, hard to remember password
|
[
"GeneratePassword",
"generates",
"a",
"random",
"hard",
"to",
"remember",
"password"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pwgen/pwgen.go#L36-L50
|
train
|
gopasspw/gopass
|
pkg/pwgen/pwgen.go
|
GeneratePasswordCharset
|
func GeneratePasswordCharset(length int, chars string) string {
pw := &bytes.Buffer{}
for pw.Len() < length {
_ = pw.WriteByte(chars[randomInteger(len(chars))])
}
return pw.String()
}
|
go
|
func GeneratePasswordCharset(length int, chars string) string {
pw := &bytes.Buffer{}
for pw.Len() < length {
_ = pw.WriteByte(chars[randomInteger(len(chars))])
}
return pw.String()
}
|
[
"func",
"GeneratePasswordCharset",
"(",
"length",
"int",
",",
"chars",
"string",
")",
"string",
"{",
"pw",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"for",
"pw",
".",
"Len",
"(",
")",
"<",
"length",
"{",
"_",
"=",
"pw",
".",
"WriteByte",
"(",
"chars",
"[",
"randomInteger",
"(",
"len",
"(",
"chars",
")",
")",
"]",
")",
"\n",
"}",
"\n",
"return",
"pw",
".",
"String",
"(",
")",
"\n",
"}"
] |
// GeneratePasswordCharset generates a random password from a given
// set of characters
|
[
"GeneratePasswordCharset",
"generates",
"a",
"random",
"password",
"from",
"a",
"given",
"set",
"of",
"characters"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pwgen/pwgen.go#L74-L80
|
train
|
gopasspw/gopass
|
pkg/pwgen/pwgen.go
|
GeneratePasswordCharsetCheck
|
func GeneratePasswordCharsetCheck(length int, chars string) string {
validator := crunchy.NewValidator()
var password string
for i := 0; i < 3; i++ {
pw := &bytes.Buffer{}
for pw.Len() < length {
_ = pw.WriteByte(chars[randomInteger(len(chars))])
}
password = pw.String()
if validator.Check(password) == nil {
break
}
}
return password
}
|
go
|
func GeneratePasswordCharsetCheck(length int, chars string) string {
validator := crunchy.NewValidator()
var password string
for i := 0; i < 3; i++ {
pw := &bytes.Buffer{}
for pw.Len() < length {
_ = pw.WriteByte(chars[randomInteger(len(chars))])
}
password = pw.String()
if validator.Check(password) == nil {
break
}
}
return password
}
|
[
"func",
"GeneratePasswordCharsetCheck",
"(",
"length",
"int",
",",
"chars",
"string",
")",
"string",
"{",
"validator",
":=",
"crunchy",
".",
"NewValidator",
"(",
")",
"\n",
"var",
"password",
"string",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"3",
";",
"i",
"++",
"{",
"pw",
":=",
"&",
"bytes",
".",
"Buffer",
"{",
"}",
"\n",
"for",
"pw",
".",
"Len",
"(",
")",
"<",
"length",
"{",
"_",
"=",
"pw",
".",
"WriteByte",
"(",
"chars",
"[",
"randomInteger",
"(",
"len",
"(",
"chars",
")",
")",
"]",
")",
"\n",
"}",
"\n",
"password",
"=",
"pw",
".",
"String",
"(",
")",
"\n\n",
"if",
"validator",
".",
"Check",
"(",
"password",
")",
"==",
"nil",
"{",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"password",
"\n",
"}"
] |
// GeneratePasswordCharsetCheck generates a random password from a given
// set of characters and validates the generated password with crunchy
|
[
"GeneratePasswordCharsetCheck",
"generates",
"a",
"random",
"password",
"from",
"a",
"given",
"set",
"of",
"characters",
"and",
"validates",
"the",
"generated",
"password",
"with",
"crunchy"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/pwgen/pwgen.go#L112-L129
|
train
|
gopasspw/gopass
|
pkg/backend/crypto/xc/export.go
|
ExportPublicKey
|
func (x *XC) ExportPublicKey(ctx context.Context, id string) ([]byte, error) {
if x.pubring.Contains(id) {
return x.pubring.Export(id)
}
if x.secring.Contains(id) {
return x.secring.Export(id, false)
}
return nil, fmt.Errorf("key not found")
}
|
go
|
func (x *XC) ExportPublicKey(ctx context.Context, id string) ([]byte, error) {
if x.pubring.Contains(id) {
return x.pubring.Export(id)
}
if x.secring.Contains(id) {
return x.secring.Export(id, false)
}
return nil, fmt.Errorf("key not found")
}
|
[
"func",
"(",
"x",
"*",
"XC",
")",
"ExportPublicKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"if",
"x",
".",
"pubring",
".",
"Contains",
"(",
"id",
")",
"{",
"return",
"x",
".",
"pubring",
".",
"Export",
"(",
"id",
")",
"\n",
"}",
"\n",
"if",
"x",
".",
"secring",
".",
"Contains",
"(",
"id",
")",
"{",
"return",
"x",
".",
"secring",
".",
"Export",
"(",
"id",
",",
"false",
")",
"\n",
"}",
"\n",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
"\n",
"}"
] |
// ExportPublicKey exports a given public key
|
[
"ExportPublicKey",
"exports",
"a",
"given",
"public",
"key"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/export.go#L9-L17
|
train
|
gopasspw/gopass
|
pkg/backend/crypto/xc/export.go
|
ExportPrivateKey
|
func (x *XC) ExportPrivateKey(ctx context.Context, id string) ([]byte, error) {
return x.secring.Export(id, true)
}
|
go
|
func (x *XC) ExportPrivateKey(ctx context.Context, id string) ([]byte, error) {
return x.secring.Export(id, true)
}
|
[
"func",
"(",
"x",
"*",
"XC",
")",
"ExportPrivateKey",
"(",
"ctx",
"context",
".",
"Context",
",",
"id",
"string",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"return",
"x",
".",
"secring",
".",
"Export",
"(",
"id",
",",
"true",
")",
"\n",
"}"
] |
// ExportPrivateKey exports a given private key
|
[
"ExportPrivateKey",
"exports",
"a",
"given",
"private",
"key"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/backend/crypto/xc/export.go#L20-L22
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithDebug
|
func WithDebug(ctx context.Context, dbg bool) context.Context {
return context.WithValue(ctx, ctxKeyDebug, dbg)
}
|
go
|
func WithDebug(ctx context.Context, dbg bool) context.Context {
return context.WithValue(ctx, ctxKeyDebug, dbg)
}
|
[
"func",
"WithDebug",
"(",
"ctx",
"context",
".",
"Context",
",",
"dbg",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyDebug",
",",
"dbg",
")",
"\n",
"}"
] |
// WithDebug returns a context with an explicit value for debug
|
[
"WithDebug",
"returns",
"a",
"context",
"with",
"an",
"explicit",
"value",
"for",
"debug"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L39-L41
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasDebug
|
func HasDebug(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyDebug).(bool)
return ok
}
|
go
|
func HasDebug(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyDebug).(bool)
return ok
}
|
[
"func",
"HasDebug",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyDebug",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasDebug returns true if a value for debug has been set in this context
|
[
"HasDebug",
"returns",
"true",
"if",
"a",
"value",
"for",
"debug",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L44-L47
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithColor
|
func WithColor(ctx context.Context, color bool) context.Context {
return context.WithValue(ctx, ctxKeyColor, color)
}
|
go
|
func WithColor(ctx context.Context, color bool) context.Context {
return context.WithValue(ctx, ctxKeyColor, color)
}
|
[
"func",
"WithColor",
"(",
"ctx",
"context",
".",
"Context",
",",
"color",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyColor",
",",
"color",
")",
"\n",
"}"
] |
// WithColor returns a context with an explicit value for color
|
[
"WithColor",
"returns",
"a",
"context",
"with",
"an",
"explicit",
"value",
"for",
"color"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L59-L61
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasColor
|
func HasColor(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyColor).(bool)
return ok
}
|
go
|
func HasColor(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyColor).(bool)
return ok
}
|
[
"func",
"HasColor",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyColor",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasColor returns true if a value for Color has been set in this context
|
[
"HasColor",
"returns",
"true",
"if",
"a",
"value",
"for",
"Color",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L64-L67
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithTerminal
|
func WithTerminal(ctx context.Context, isTerm bool) context.Context {
return context.WithValue(ctx, ctxKeyTerminal, isTerm)
}
|
go
|
func WithTerminal(ctx context.Context, isTerm bool) context.Context {
return context.WithValue(ctx, ctxKeyTerminal, isTerm)
}
|
[
"func",
"WithTerminal",
"(",
"ctx",
"context",
".",
"Context",
",",
"isTerm",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyTerminal",
",",
"isTerm",
")",
"\n",
"}"
] |
// WithTerminal returns a context with an explicit value for terminal
|
[
"WithTerminal",
"returns",
"a",
"context",
"with",
"an",
"explicit",
"value",
"for",
"terminal"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L79-L81
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasTerminal
|
func HasTerminal(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyTerminal).(bool)
return ok
}
|
go
|
func HasTerminal(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyTerminal).(bool)
return ok
}
|
[
"func",
"HasTerminal",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyTerminal",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasTerminal returns true if a value for Terminal has been set in this context
|
[
"HasTerminal",
"returns",
"true",
"if",
"a",
"value",
"for",
"Terminal",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L84-L87
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithInteractive
|
func WithInteractive(ctx context.Context, isInteractive bool) context.Context {
return context.WithValue(ctx, ctxKeyInteractive, isInteractive)
}
|
go
|
func WithInteractive(ctx context.Context, isInteractive bool) context.Context {
return context.WithValue(ctx, ctxKeyInteractive, isInteractive)
}
|
[
"func",
"WithInteractive",
"(",
"ctx",
"context",
".",
"Context",
",",
"isInteractive",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyInteractive",
",",
"isInteractive",
")",
"\n",
"}"
] |
// WithInteractive returns a context with an explicit value for interactive
|
[
"WithInteractive",
"returns",
"a",
"context",
"with",
"an",
"explicit",
"value",
"for",
"interactive"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L99-L101
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasInteractive
|
func HasInteractive(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyInteractive).(bool)
return ok
}
|
go
|
func HasInteractive(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyInteractive).(bool)
return ok
}
|
[
"func",
"HasInteractive",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyInteractive",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasInteractive returns true if a value for Interactive has been set in this context
|
[
"HasInteractive",
"returns",
"true",
"if",
"a",
"value",
"for",
"Interactive",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L104-L107
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasStdin
|
func HasStdin(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStdin).(bool)
return ok
}
|
go
|
func HasStdin(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyStdin).(bool)
return ok
}
|
[
"func",
"HasStdin",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyStdin",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasStdin returns true if a value for Stdin has been set in this context
|
[
"HasStdin",
"returns",
"true",
"if",
"a",
"value",
"for",
"Stdin",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L125-L128
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithAskForMore
|
func WithAskForMore(ctx context.Context, afm bool) context.Context {
return context.WithValue(ctx, ctxKeyAskForMore, afm)
}
|
go
|
func WithAskForMore(ctx context.Context, afm bool) context.Context {
return context.WithValue(ctx, ctxKeyAskForMore, afm)
}
|
[
"func",
"WithAskForMore",
"(",
"ctx",
"context",
".",
"Context",
",",
"afm",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyAskForMore",
",",
"afm",
")",
"\n",
"}"
] |
// WithAskForMore returns a context with the value for ask for more set
|
[
"WithAskForMore",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ask",
"for",
"more",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L141-L143
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasAskForMore
|
func HasAskForMore(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAskForMore).(bool)
return ok
}
|
go
|
func HasAskForMore(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyAskForMore).(bool)
return ok
}
|
[
"func",
"HasAskForMore",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyAskForMore",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasAskForMore returns true if a value for AskForMore has been set in this context
|
[
"HasAskForMore",
"returns",
"true",
"if",
"a",
"value",
"for",
"AskForMore",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L146-L149
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithClipTimeout
|
func WithClipTimeout(ctx context.Context, to int) context.Context {
return context.WithValue(ctx, ctxKeyClipTimeout, to)
}
|
go
|
func WithClipTimeout(ctx context.Context, to int) context.Context {
return context.WithValue(ctx, ctxKeyClipTimeout, to)
}
|
[
"func",
"WithClipTimeout",
"(",
"ctx",
"context",
".",
"Context",
",",
"to",
"int",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyClipTimeout",
",",
"to",
")",
"\n",
"}"
] |
// WithClipTimeout returns a context with the value for clip timeout set
|
[
"WithClipTimeout",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"clip",
"timeout",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L161-L163
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasClipTimeout
|
func HasClipTimeout(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyClipTimeout).(int)
return ok
}
|
go
|
func HasClipTimeout(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyClipTimeout).(int)
return ok
}
|
[
"func",
"HasClipTimeout",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyClipTimeout",
")",
".",
"(",
"int",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasClipTimeout returns true if a value for ClipTimeout has been set in this context
|
[
"HasClipTimeout",
"returns",
"true",
"if",
"a",
"value",
"for",
"ClipTimeout",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L166-L169
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithNoConfirm
|
func WithNoConfirm(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoConfirm, bv)
}
|
go
|
func WithNoConfirm(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoConfirm, bv)
}
|
[
"func",
"WithNoConfirm",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNoConfirm",
",",
"bv",
")",
"\n",
"}"
] |
// WithNoConfirm returns a context with the value for ask for more set
|
[
"WithNoConfirm",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ask",
"for",
"more",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L181-L183
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasNoConfirm
|
func HasNoConfirm(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoConfirm).(bool)
return ok
}
|
go
|
func HasNoConfirm(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoConfirm).(bool)
return ok
}
|
[
"func",
"HasNoConfirm",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyNoConfirm",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasNoConfirm returns true if a value for NoConfirm has been set in this context
|
[
"HasNoConfirm",
"returns",
"true",
"if",
"a",
"value",
"for",
"NoConfirm",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L186-L189
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithNoPager
|
func WithNoPager(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoPager, bv)
}
|
go
|
func WithNoPager(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyNoPager, bv)
}
|
[
"func",
"WithNoPager",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyNoPager",
",",
"bv",
")",
"\n",
"}"
] |
// WithNoPager returns a context with the value for ask for more set
|
[
"WithNoPager",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ask",
"for",
"more",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L201-L203
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasNoPager
|
func HasNoPager(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoPager).(bool)
return ok
}
|
go
|
func HasNoPager(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyNoPager).(bool)
return ok
}
|
[
"func",
"HasNoPager",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyNoPager",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasNoPager returns true if a value for NoPager has been set in this context
|
[
"HasNoPager",
"returns",
"true",
"if",
"a",
"value",
"for",
"NoPager",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L206-L209
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithShowSafeContent
|
func WithShowSafeContent(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyShowSafeContent, bv)
}
|
go
|
func WithShowSafeContent(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyShowSafeContent, bv)
}
|
[
"func",
"WithShowSafeContent",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyShowSafeContent",
",",
"bv",
")",
"\n",
"}"
] |
// WithShowSafeContent returns a context with the value for ShowSafeContent set
|
[
"WithShowSafeContent",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ShowSafeContent",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L221-L223
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasShowSafeContent
|
func HasShowSafeContent(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyShowSafeContent).(bool)
return ok
}
|
go
|
func HasShowSafeContent(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyShowSafeContent).(bool)
return ok
}
|
[
"func",
"HasShowSafeContent",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyShowSafeContent",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasShowSafeContent returns true if a value for ShowSafeContent has been set in this context
|
[
"HasShowSafeContent",
"returns",
"true",
"if",
"a",
"value",
"for",
"ShowSafeContent",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L226-L229
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithGitCommit
|
func WithGitCommit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitCommit, bv)
}
|
go
|
func WithGitCommit(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyGitCommit, bv)
}
|
[
"func",
"WithGitCommit",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyGitCommit",
",",
"bv",
")",
"\n",
"}"
] |
// WithGitCommit returns a context with the value of git commit set
|
[
"WithGitCommit",
"returns",
"a",
"context",
"with",
"the",
"value",
"of",
"git",
"commit",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L241-L243
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasGitCommit
|
func HasGitCommit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitCommit).(bool)
return ok
}
|
go
|
func HasGitCommit(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyGitCommit).(bool)
return ok
}
|
[
"func",
"HasGitCommit",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyGitCommit",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasGitCommit returns true if a value for GitCommit has been set in this context
|
[
"HasGitCommit",
"returns",
"true",
"if",
"a",
"value",
"for",
"GitCommit",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L246-L249
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
WithUseSymbols
|
func WithUseSymbols(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyUseSymbols, bv)
}
|
go
|
func WithUseSymbols(ctx context.Context, bv bool) context.Context {
return context.WithValue(ctx, ctxKeyUseSymbols, bv)
}
|
[
"func",
"WithUseSymbols",
"(",
"ctx",
"context",
".",
"Context",
",",
"bv",
"bool",
")",
"context",
".",
"Context",
"{",
"return",
"context",
".",
"WithValue",
"(",
"ctx",
",",
"ctxKeyUseSymbols",
",",
"bv",
")",
"\n",
"}"
] |
// WithUseSymbols returns a context with the value for ask for more set
|
[
"WithUseSymbols",
"returns",
"a",
"context",
"with",
"the",
"value",
"for",
"ask",
"for",
"more",
"set"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L261-L263
|
train
|
gopasspw/gopass
|
pkg/ctxutil/ctxutil.go
|
HasUseSymbols
|
func HasUseSymbols(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyUseSymbols).(bool)
return ok
}
|
go
|
func HasUseSymbols(ctx context.Context) bool {
_, ok := ctx.Value(ctxKeyUseSymbols).(bool)
return ok
}
|
[
"func",
"HasUseSymbols",
"(",
"ctx",
"context",
".",
"Context",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"ctx",
".",
"Value",
"(",
"ctxKeyUseSymbols",
")",
".",
"(",
"bool",
")",
"\n",
"return",
"ok",
"\n",
"}"
] |
// HasUseSymbols returns true if a value for UseSymbols has been set in this context
|
[
"HasUseSymbols",
"returns",
"true",
"if",
"a",
"value",
"for",
"UseSymbols",
"has",
"been",
"set",
"in",
"this",
"context"
] |
fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4
|
https://github.com/gopasspw/gopass/blob/fe4e21d62182f0f2e4ef9a0ca8168d849dc52bd4/pkg/ctxutil/ctxutil.go#L266-L269
|
train
|
Subsets and Splits
SQL Console for semeru/code-text-go
Retrieves a limited set of code samples with their languages, with a specific case adjustment for 'Go' language.