_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q28700
CreatePrivateKeyBatch
train
func (x *XC) CreatePrivateKeyBatch(ctx context.Context, name, email, passphrase string) error { k, err := keyring.GenerateKeypair(passphrase) if err != nil { return errors.Wrapf(err, "failed to generate keypair: %s", err) } k.Identity.Name = name k.Identity.Email = email if err := x.secring.Set(k); err != nil {...
go
{ "resource": "" }
q28701
WithAlwaysTrust
train
func WithAlwaysTrust(ctx context.Context, at bool) context.Context { return context.WithValue(ctx, ctxKeyAlwaysTrust, at) }
go
{ "resource": "" }
q28702
NewPubring
train
func NewPubring(sec *Secring) *Pubring { return &Pubring{ data: &xcpb.Pubring{ PublicKeys: make([]*xcpb.PublicKey, 0, 10), }, secring: sec, } }
go
{ "resource": "" }
q28703
LoadPubring
train
func LoadPubring(file string, sec *Secring) (*Pubring, error) { pr := NewPubring(sec) pr.File = file buf, err := ioutil.ReadFile(file) if os.IsNotExist(err) { return pr, nil } if err != nil { return nil, err } if err := proto.Unmarshal(buf, pr.data); err != nil { return nil, err } return pr, nil }
go
{ "resource": "" }
q28704
Contains
train
func (p *Pubring) Contains(fp string) bool { p.Lock() defer p.Unlock() for _, pk := range p.data.PublicKeys { if pk.Fingerprint == fp { return true } } if p.secring == nil { return false } return p.secring.Contains(fp) }
go
{ "resource": "" }
q28705
KeyIDs
train
func (p *Pubring) KeyIDs() []string { p.Lock() defer p.Unlock() ids := make([]string, 0, len(p.data.PublicKeys)) for _, pk := range p.data.PublicKeys { ids = append(ids, pk.Fingerprint) } if p.secring != nil { ids = append(ids, p.secring.KeyIDs()...) } sort.Strings(ids) return ids }
go
{ "resource": "" }
q28706
Export
train
func (p *Pubring) Export(id string) ([]byte, error) { p.Lock() defer p.Unlock() xpk := p.fetch(id) if xpk == nil { if p.secring != nil { return p.secring.Export(id, false) } return nil, fmt.Errorf("key not found") } return proto.Marshal(xpk) }
go
{ "resource": "" }
q28707
Import
train
func (p *Pubring) Import(buf []byte) error { pk := &xcpb.PublicKey{} if err := proto.Unmarshal(buf, pk); err != nil { return err } p.insert(pk) return nil }
go
{ "resource": "" }
q28708
Set
train
func (p *Pubring) Set(pk *PublicKey) error { p.Lock() defer p.Unlock() p.insert(pubKRToPB(pk)) return nil }
go
{ "resource": "" }
q28709
Remove
train
func (p *Pubring) Remove(id string) error { p.Lock() defer p.Unlock() match := -1 for i, pk := range p.data.PublicKeys { if pk.Fingerprint == id { match = i break } } if match < 0 || match > len(p.data.PublicKeys) { return fmt.Errorf("not found") } p.data.PublicKeys = append(p.data.PublicKeys[:matc...
go
{ "resource": "" }
q28710
ConfigMap
train
func (c *StoreConfig) ConfigMap() map[string]string { m := make(map[string]string, 20) o := reflect.ValueOf(c).Elem() for i := 0; i < o.NumField(); i++ { jsonArg := o.Type().Field(i).Tag.Get("yaml") if jsonArg == "" || jsonArg == "-" { continue } f := o.Field(i) var strVal string switch f.Kind() { c...
go
{ "resource": "" }
q28711
RemoveMount
train
func (r *Store) RemoveMount(ctx context.Context, alias string) error { if _, found := r.mounts[alias]; !found { return errors.Errorf("%s is not mounted", alias) } if _, found := r.mounts[alias]; !found { out.Yellow(ctx, "%s is not initialized", alias) } delete(r.mounts, alias) delete(r.cfg.Mounts, alias) ret...
go
{ "resource": "" }
q28712
Mounts
train
func (r *Store) Mounts() map[string]string { m := make(map[string]string, len(r.mounts)) for alias, sub := range r.mounts { m[alias] = sub.Path() } return m }
go
{ "resource": "" }
q28713
MountPoints
train
func (r *Store) MountPoints() []string { mps := make([]string, 0, len(r.mounts)) for k := range r.mounts { mps = append(mps, k) } sort.Sort(sort.Reverse(store.ByPathLen(mps))) return mps }
go
{ "resource": "" }
q28714
MountPoint
train
func (r *Store) MountPoint(name string) string { for _, mp := range r.MountPoints() { if strings.HasPrefix(name+"/", mp+"/") { return mp } } return "" }
go
{ "resource": "" }
q28715
getStore
train
func (r *Store) getStore(ctx context.Context, name string) (context.Context, store.Store, string) { name = strings.TrimSuffix(name, "/") mp := r.MountPoint(name) if sub, found := r.mounts[mp]; found { return r.cfg.Mounts[mp].WithContext(ctx), sub, strings.TrimPrefix(name, sub.Alias()) } return r.cfg.Root.WithCon...
go
{ "resource": "" }
q28716
WithConfig
train
func (r *Store) WithConfig(ctx context.Context, name string) context.Context { name = strings.TrimSuffix(name, "/") mp := r.MountPoint(name) if _, found := r.mounts[mp]; found { return r.cfg.Mounts[mp].WithContext(ctx) } return r.cfg.Root.WithContext(ctx) }
go
{ "resource": "" }
q28717
GetSubStore
train
func (r *Store) GetSubStore(name string) (store.Store, error) { if name == "" { return r.store, nil } if sub, found := r.mounts[name]; found { return sub, nil } return nil, errors.Errorf("no such mount point '%s'", name) }
go
{ "resource": "" }
q28718
checkMounts
train
func (r *Store) checkMounts() error { paths := make(map[string]string, len(r.mounts)) for k, v := range r.mounts { if _, found := paths[v.Path()]; found { return errors.Errorf("Doubly mounted path at %s: %s", v.Path(), k) } paths[v.Path()] = k } return nil }
go
{ "resource": "" }
q28719
Version
train
func (s *Action) Version(ctx context.Context, c *cli.Context) error { version := make(chan string, 1) go s.checkVersion(ctx, version) _ = s.Initialized(ctx, c) cli.VersionPrinter(c) cryptoVer := versionInfo(ctx, s.Store.Crypto(ctx, "")) rcsVer := versionInfo(ctx, s.Store.RCS(ctx, "")) storageVer := versionInf...
go
{ "resource": "" }
q28720
killPrecedessors
train
func killPrecedessors() error { procs, err := ps.Processes() if err != nil { return err } for _, proc := range procs { walkFn(proc.Pid(), killProc) } return nil }
go
{ "resource": "" }
q28721
Execute
train
func Execute(ctx context.Context, tpl, name string, content []byte, s kvstore) ([]byte, error) { funcs := funcMap(ctx, s) pl := payload{ Dir: filepath.Dir(name), Path: name, Name: filepath.Base(name), Content: string(content), } tmpl, err := template.New(tpl).Funcs(funcs).Parse(tpl) if err != ni...
go
{ "resource": "" }
q28722
Value
train
func (s *Secret) Value(key string) (string, error) { s.Lock() defer s.Unlock() if s.data == nil { if !strings.HasPrefix(s.body, "---\n") { return "", store.ErrYAMLNoMark } if err := s.decode(); err != nil { return "", err } } if v, found := s.data[key]; found { return fmt.Sprintf("%v", v), nil } ...
go
{ "resource": "" }
q28723
SetValue
train
func (s *Secret) SetValue(key, value string) error { s.Lock() defer s.Unlock() if s.body == "" && s.data == nil { s.data = make(map[string]interface{}, 1) } if s.data == nil { return store.ErrYAMLNoMark } s.data[key] = value return s.encode() }
go
{ "resource": "" }
q28724
DeleteKey
train
func (s *Secret) DeleteKey(key string) error { s.Lock() defer s.Unlock() if s.data == nil { return store.ErrYAMLNoMark } delete(s.data, key) return s.encode() }
go
{ "resource": "" }
q28725
decodeYAML
train
func (s *Secret) decodeYAML() (bool, error) { if !strings.HasPrefix(s.body, "---\n") && s.password != "---" { return false, nil } d := make(map[string]interface{}) err := yaml.Unmarshal([]byte(s.body), &d) if err != nil { return true, err } s.data = d return true, nil }
go
{ "resource": "" }
q28726
ListPublicKeyIDs
train
func (g *GPG) ListPublicKeyIDs(context.Context) ([]string, error) { if g.pubring == nil { return nil, fmt.Errorf("pubring is not initialized") } ids := listKeyIDs(g.pubring) if g.secring != nil { ids = append(ids, listKeyIDs(g.secring)...) } return ids, nil }
go
{ "resource": "" }
q28727
KeysByIdUsage
train
func (g *GPG) KeysByIdUsage(id uint64, requiredUsage byte) []openpgp.Key { return append(g.secring.KeysByIdUsage(id, requiredUsage), g.pubring.KeysByIdUsage(id, requiredUsage)...) }
go
{ "resource": "" }
q28728
SigningKeys
train
func (g *GPG) SigningKeys() []openpgp.Key { keys := []openpgp.Key{} for _, e := range g.secring { for _, subKey := range e.Subkeys { if subKey.PrivateKey != nil && (!subKey.Sig.FlagsValid || subKey.Sig.FlagSign) { keys = append(keys, openpgp.Key{ Entity: e, PublicKey: subKey.PublicKey, ...
go
{ "resource": "" }
q28729
isPublicSuffix
train
func isPublicSuffix(host string) bool { suffix, _ := publicsuffix.PublicSuffix(host) return host == suffix }
go
{ "resource": "" }
q28730
Recipients
train
func (s *Store) Recipients(ctx context.Context) []string { rs, err := s.GetRecipients(ctx, "") if err != nil { out.Error(ctx, "failed to read recipient list: %s", err) } return rs }
go
{ "resource": "" }
q28731
AddRecipient
train
func (s *Store) AddRecipient(ctx context.Context, id string) error { rs, err := s.GetRecipients(ctx, "") if err != nil { return errors.Wrapf(err, "failed to read recipient list") } for _, k := range rs { if k == id { return errors.Errorf("Recipient already in store") } } rs = append(rs, id) if err :=...
go
{ "resource": "" }
q28732
SaveRecipients
train
func (s *Store) SaveRecipients(ctx context.Context) error { rs, err := s.GetRecipients(ctx, "") if err != nil { return errors.Wrapf(err, "failed to get recipients") } return s.saveRecipients(ctx, rs, "Save Recipients", true) }
go
{ "resource": "" }
q28733
SetRecipients
train
func (s *Store) SetRecipients(ctx context.Context, rs []string) error { return s.saveRecipients(ctx, rs, "Set Recipients", true) }
go
{ "resource": "" }
q28734
RemoveRecipient
train
func (s *Store) RemoveRecipient(ctx context.Context, id string) error { keys, err := s.crypto.FindPublicKeys(ctx, id) if err != nil { out.Cyan(ctx, "Warning: Failed to get GPG Key Info for %s: %s", id, err) } rs, err := s.GetRecipients(ctx, "") if err != nil { return errors.Wrapf(err, "failed to read recipien...
go
{ "resource": "" }
q28735
ExportMissingPublicKeys
train
func (s *Store) ExportMissingPublicKeys(ctx context.Context, rs []string) (bool, error) { ok := true exported := false for _, r := range rs { if r == "" { continue } path, err := s.exportPublicKey(ctx, r) if err != nil { ok = false out.Error(ctx, "failed to export public key for '%s': %s", r, err) ...
go
{ "resource": "" }
q28736
unmarshalRecipients
train
func unmarshalRecipients(buf []byte) []string { m := make(map[string]struct{}, 5) scanner := bufio.NewScanner(bytes.NewReader(buf)) for scanner.Scan() { line := strings.TrimSpace(scanner.Text()) if line != "" { // deduplicate m[line] = struct{}{} } } lst := make([]string, 0, len(m)) for k := range m...
go
{ "resource": "" }
q28737
Print
train
func Print(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprintf(Stdout, Prefix(ctx)+format+newline(ctx), args...) }
go
{ "resource": "" }
q28738
Debug
train
func Debug(ctx context.Context, format string, args ...interface{}) { if !ctxutil.IsDebug(ctx) { return } var loc string if _, file, line, ok := runtime.Caller(1); ok { file = file[strings.Index(file, "pkg/"):] file = strings.TrimPrefix(file, "pkg/") loc = fmt.Sprintf("%s:%d ", file, line) } fmt.Fprintf...
go
{ "resource": "" }
q28739
Black
train
func Black(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.BlackString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28740
Blue
train
func Blue(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.BlueString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28741
Cyan
train
func Cyan(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.CyanString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28742
Green
train
func Green(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.GreenString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28743
Magenta
train
func Magenta(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.MagentaString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28744
Red
train
func Red(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.RedString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28745
Error
train
func Error(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stderr, color.RedString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28746
White
train
func White(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.WhiteString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28747
Yellow
train
func Yellow(ctx context.Context, format string, args ...interface{}) { if IsHidden(ctx) && !ctxutil.IsDebug(ctx) { return } fmt.Fprint(Stdout, color.YellowString(Prefix(ctx)+format+newline(ctx), args...)) }
go
{ "resource": "" }
q28748
Len
train
func (f *Folder) Len() int { l := len(f.Files) for _, f := range f.Folders { l += f.Len() } return l }
go
{ "resource": "" }
q28749
Format
train
func (f *Folder) Format(maxDepth int) string { return f.format("", true, maxDepth, 0) }
go
{ "resource": "" }
q28750
AddFile
train
func (f *Folder) AddFile(name string, contentType string) error { return f.addFile(strings.Split(name, sep), contentType) }
go
{ "resource": "" }
q28751
AddTemplate
train
func (f *Folder) AddTemplate(name string) error { return f.addTemplate(strings.Split(name, sep)) }
go
{ "resource": "" }
q28752
newFolder
train
func newFolder(name string) *Folder { return &Folder{ Name: name, Path: "", Folders: make(map[string]*Folder, 10), Files: make(map[string]*File, 10), } }
go
{ "resource": "" }
q28753
getFolder
train
func (f *Folder) getFolder(name string) *Folder { if next, found := f.Folders[name]; found { return next } next := newFolder(name) f.Folders[name] = next return next }
go
{ "resource": "" }
q28754
FindFolder
train
func (f *Folder) FindFolder(name string) (tree.Tree, error) { sub := f.findFolder(strings.Split(strings.TrimSuffix(name, sep), sep)) if sub == nil { return nil, errors.Errorf("Entry not found") } return sub, nil }
go
{ "resource": "" }
q28755
findFolder
train
func (f *Folder) findFolder(path []string) *Folder { if len(path) < 1 { return f } name := path[0] if next, found := f.Folders[name]; found { return next.findFolder(path[1:]) } return nil }
go
{ "resource": "" }
q28756
addFile
train
func (f *Folder) addFile(path []string, contentType string) error { if len(path) < 1 { return errors.Errorf("Path must not be empty") } name := path[0] if len(path) == 1 { if _, found := f.Files[name]; found { return errors.Errorf("File %s exists", name) } f.Files[name] = &File{ Name: name, Metadat...
go
{ "resource": "" }
q28757
ReadAndRespond
train
func (api *API) ReadAndRespond(ctx context.Context) error { silentCtx := out.WithHidden(ctx, true) message, err := readMessage(api.Reader) if message == nil || err != nil { return err } return api.respondMessage(silentCtx, message) }
go
{ "resource": "" }
q28758
RespondError
train
func (api *API) RespondError(err error) error { var response errorResponse response.Error = err.Error() return sendSerializedJSONMessage(response, api.Writer) }
go
{ "resource": "" }
q28759
New
train
func New() (*Client, error) { cmd := exec.Command(GetBinary()) stdin, err := cmd.StdinPipe() if err != nil { return nil, err } stdout, err := cmd.StdoutPipe() if err != nil { return nil, err } br := bufio.NewReader(stdout) if err := cmd.Start(); err != nil { return nil, err } // check welcome messag...
go
{ "resource": "" }
q28760
Confirm
train
func (c *Client) Confirm() bool { if err := c.Set("confirm", ""); err == nil { return true } return false }
go
{ "resource": "" }
q28761
Set
train
func (c *Client) Set(key, value string) error { key = strings.ToUpper(key) if value != "" { value = " " + value } val := "SET" + key + value + "\n" if _, err := c.in.Write([]byte(val)); err != nil { return err } line, _, _ := c.out.ReadLine() if string(line) != "OK" { return errors.Errorf("error: %s", lin...
go
{ "resource": "" }
q28762
GetPin
train
func (c *Client) GetPin() ([]byte, error) { if _, err := c.in.Write([]byte("GETPIN\n")); err != nil { return nil, err } pin, _, err := c.out.ReadLine() if err != nil { return nil, err } if bytes.HasPrefix(pin, []byte("OK")) { return nil, nil } if !bytes.HasPrefix(pin, []byte("D ")) { return nil, fmt.Err...
go
{ "resource": "" }
q28763
Config
train
func (s *Action) Config(ctx context.Context, c *cli.Context) error { if len(c.Args()) < 1 { s.printConfigValues(ctx, "") return nil } if len(c.Args()) == 1 { s.printConfigValues(ctx, "", c.Args()[0]) return nil } if len(c.Args()) > 2 { return ExitError(ctx, ExitUsage, nil, "Usage: %s config key value",...
go
{ "resource": "" }
q28764
ConfigComplete
train
func (s *Action) ConfigComplete(c *cli.Context) { cm := s.cfg.Root.ConfigMap() keys := make([]string, 0, len(cm)) for k := range cm { keys = append(keys, k) } sort.Strings(keys) for _, k := range keys { fmt.Fprintln(stdout, k) } }
go
{ "resource": "" }
q28765
Umask
train
func Umask() int { for _, en := range []string{"GOPASS_UMASK", "PASSWORD_STORE_UMASK"} { if um := os.Getenv(en); um != "" { if iv, err := strconv.ParseInt(um, 8, 32); err == nil && iv >= 0 && iv <= 0777 { return int(iv) } } } return 077 }
go
{ "resource": "" }
q28766
Initialized
train
func (r *Store) Initialized(ctx context.Context) (bool, error) { if r.store == nil { out.Debug(ctx, "initializing store and possible sub-stores") if err := r.initialize(ctx); err != nil { return false, errors.Wrapf(err, "failed to initialized stores: %s", err) } } return r.store.Initialized(ctx), nil }
go
{ "resource": "" }
q28767
Lookup
train
func Lookup(ctx context.Context, shaSum string) (uint64, error) { if len(shaSum) != 40 { return 0, errors.Errorf("invalid shasum") } shaSum = strings.ToUpper(shaSum) prefix := shaSum[:5] suffix := shaSum[5:] var count uint64 url := fmt.Sprintf("%s/range/%s", URL, prefix) op := func() error { out.Debug(ct...
go
{ "resource": "" }
q28768
GitInit
train
func (s *Action) GitInit(ctx context.Context, c *cli.Context) error { store := c.String("store") un := c.String("username") ue := c.String("useremail") ctx = backend.WithRCSBackendString(ctx, c.String("rcs")) // default to git if !backend.HasRCSBackend(ctx) { ctx = backend.WithRCSBackend(ctx, backend.GitCLI) ...
go
{ "resource": "" }
q28769
GitAddRemote
train
func (s *Action) GitAddRemote(ctx context.Context, c *cli.Context) error { store := c.String("store") remote := c.Args().Get(0) url := c.Args().Get(1) if remote == "" || url == "" { return ExitError(ctx, ExitUsage, nil, "Usage: %s git remote add <REMOTE> <URL>", s.Name) } return s.Store.GitAddRemote(ctx, stor...
go
{ "resource": "" }
q28770
GitPull
train
func (s *Action) GitPull(ctx context.Context, c *cli.Context) error { store := c.String("store") origin := c.Args().Get(0) branch := c.Args().Get(1) if origin == "" { origin = "origin" } if branch == "" { branch = "master" } return s.Store.GitPull(ctx, store, origin, branch) }
go
{ "resource": "" }
q28771
GitPush
train
func (s *Action) GitPush(ctx context.Context, c *cli.Context) error { store := c.String("store") origin := c.Args().Get(0) branch := c.Args().Get(1) if origin == "" || branch == "" { return ExitError(ctx, ExitUsage, nil, "Usage: %s git push <ORIGIN> <BRANCH>", s.Name) } return s.Store.GitPush(ctx, store, origi...
go
{ "resource": "" }
q28772
New
train
func New(ctx context.Context, sc recipientHashStorer, alias string, u *backend.URL, cfgdir string, agent *client.Client) (*Store, error) { out.Debug(ctx, "sub.New - URL: %s", u.String()) s := &Store{ alias: alias, url: u, rcs: noop.New(), cfgdir: cfgdir, agent: agent, sc: sc, } // init sto...
go
{ "resource": "" }
q28773
idFile
train
func (s *Store) idFile(ctx context.Context, name string) string { fn := name var cnt uint8 for { cnt++ if cnt > 100 { break } if fn == "" || fn == sep { break } gfn := filepath.Join(fn, s.crypto.IDFile()) if s.storage.Exists(ctx, gfn) { return gfn } fn = filepath.Dir(fn) } return s.crypt...
go
{ "resource": "" }
q28774
Equals
train
func (s *Store) Equals(other store.Store) bool { if other == nil { return false } return s.URL() == other.URL() }
go
{ "resource": "" }
q28775
IsDir
train
func (s *Store) IsDir(ctx context.Context, name string) bool { return s.storage.IsDir(ctx, name) }
go
{ "resource": "" }
q28776
Path
train
func (s *Store) Path() string { if s.url == nil { return "" } return s.url.Path }
go
{ "resource": "" }
q28777
ListPrivateKeys
train
func ListPrivateKeys(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } kl, err := crypto.ListPrivateKeyIDs(ctx) if err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to list priv...
go
{ "resource": "" }
q28778
GenerateKeypair
train
func GenerateKeypair(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } name := c.String("name") email := c.String("email") pw := c.String("passphrase") if name == "" { var err error name, err = ter...
go
{ "resource": "" }
q28779
ExportPrivateKey
train
func ExportPrivateKey(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } id := c.String("id") file := c.String("file") if id == "" { return action.ExitError(ctx, action.ExitUsage, nil, "need id") } i...
go
{ "resource": "" }
q28780
ImportPrivateKey
train
func ImportPrivateKey(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } file := c.String("file") if file == "" { return action.ExitError(ctx, action.ExitUsage, nil, "need file") } if !fsutil.IsFile(...
go
{ "resource": "" }
q28781
EncryptFile
train
func EncryptFile(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } if c.Bool("stream") { return EncryptFileStream(ctx, c) } inFile := c.String("file") if inFile == "" { return action.ExitError(ctx,...
go
{ "resource": "" }
q28782
DecryptFile
train
func DecryptFile(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } if c.Bool("stream") { return DecryptFileStream(ctx, c) } inFile := c.String("file") if inFile == "" { return action.ExitError(ctx,...
go
{ "resource": "" }
q28783
EncryptFileStream
train
func EncryptFileStream(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } inFile := c.String("file") if inFile == "" { return action.ExitError(ctx, action.ExitUsage, nil, "need file") } recipients := ...
go
{ "resource": "" }
q28784
DecryptFileStream
train
func DecryptFileStream(ctx context.Context, c *cli.Context) error { if err := initCrypto(); err != nil { return action.ExitError(ctx, action.ExitUnknown, err, "failed to init XC") } inFile := c.String("file") if inFile == "" { return action.ExitError(ctx, action.ExitUsage, nil, "need file") } if !strings.Has...
go
{ "resource": "" }
q28785
WriteTo
train
func (c *gitCredentials) WriteTo(w io.Writer) (int64, error) { var n int64 if c.Protocol != "" { i, err := io.WriteString(w, "protocol="+c.Protocol+"\n") n += int64(i) if err != nil { return n, err } } if c.Host != "" { i, err := io.WriteString(w, "host="+c.Host+"\n") n += int64(i) if err != nil { ...
go
{ "resource": "" }
q28786
GitCredentialBefore
train
func (s *Action) GitCredentialBefore(ctx context.Context, c *cli.Context) error { err := s.Initialized(ctx, c) if err != nil { return err } if !ctxutil.IsStdin(ctx) { return ExitError(ctx, ExitUsage, nil, "missing stdin from git") } return nil }
go
{ "resource": "" }
q28787
GitCredentialGet
train
func (s *Action) GitCredentialGet(ctx context.Context, c *cli.Context) error { ctx = sub.WithAutoSync(ctx, false) cred, err := parseGitCredentials(termio.Stdin) if err != nil { return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err) } // try git/host/username... If username is ...
go
{ "resource": "" }
q28788
GitCredentialStore
train
func (s *Action) GitCredentialStore(ctx context.Context, c *cli.Context) error { cred, err := parseGitCredentials(termio.Stdin) if err != nil { return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err) } path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename...
go
{ "resource": "" }
q28789
GitCredentialErase
train
func (s *Action) GitCredentialErase(ctx context.Context, c *cli.Context) error { cred, err := parseGitCredentials(termio.Stdin) if err != nil { return ExitError(ctx, ExitUnsupported, err, "Error: %v while parsing git-credential", err) } path := "git/" + fsutil.CleanFilename(cred.Host) + "/" + fsutil.CleanFilename...
go
{ "resource": "" }
q28790
GitCredentialConfigure
train
func (s *Action) GitCredentialConfigure(ctx context.Context, c *cli.Context) error { flags := 0 flag := "--global" if c.Bool("local") { flag = "--local" flags++ } if c.Bool("global") { flag = "--global" flags++ } if c.Bool("system") { flag = "--system" flags++ } if flags >= 2 { return ExitError(c...
go
{ "resource": "" }
q28791
format
train
func (f File) format(prefix string, last bool, _, _ int) string { sym := symBranch if last { sym = symLeaf } ft := "" if f.Metadata != nil { switch f.Metadata["Content-Type"] { case "application/octet-stream": ft = " " + colBin("(binary)") case "text/yaml": ft = " " + colYaml("(yaml)") } } return...
go
{ "resource": "" }
q28792
Selection
train
func (ca Actions) Selection() []string { keys := make([]string, 0, len(ca)) for _, a := range ca { keys = append(keys, a.Name) } return keys }
go
{ "resource": "" }
q28793
Run
train
func (ca Actions) Run(ctx context.Context, c *cli.Context, i int) error { if len(ca) < i || i >= len(ca) { return errors.New("action not found") } if ca[i].Fn == nil { return errors.New("action invalid") } return ca[i].Fn(ctx, c) }
go
{ "resource": "" }
q28794
New
train
func New(dumps ...string) (*Scanner, error) { ok := make([]string, 0, len(dumps)) for _, dump := range dumps { if !fsutil.IsFile(dump) { continue } ok = append(ok, dump) } if len(ok) < 1 { return nil, fmt.Errorf("no valid dumps given") } return &Scanner{ dumps: ok, }, nil }
go
{ "resource": "" }
q28795
LookupBatch
train
func (s *Scanner) LookupBatch(ctx context.Context, in []string) []string { if len(in) < 1 { return nil } sort.Strings(in) for i, hash := range in { in[i] = strings.ToUpper(hash) } out := make([]string, 0, len(in)) results := make(chan string, len(in)) done := make(chan struct{}, len(s.dumps)) for _, fn ...
go
{ "resource": "" }
q28796
Add
train
func (g *Noop) Add(ctx context.Context, args ...string) error { return nil }
go
{ "resource": "" }
q28797
Commit
train
func (g *Noop) Commit(ctx context.Context, msg string) error { return nil }
go
{ "resource": "" }
q28798
Push
train
func (g *Noop) Push(ctx context.Context, origin, branch string) error { return nil }
go
{ "resource": "" }
q28799
Cmd
train
func (g *Noop) Cmd(ctx context.Context, name string, args ...string) error { return nil }
go
{ "resource": "" }