Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Cmd = &cobra.Command{ Use: "add", Short: "Add keepass password node", Run: func(cmd *cobra.Command, args []string) { flag.Parse() arguments := flag.Args() if determineIsStdinModel(arguments) && determineIsNotTerminal() { in, err := io.ReadAll(os.Stdin) if err != nil { panic(fmt.Errorf("parse stdin contents error:%s", err.Error())) } json := string(in) if stringz.IsBlankString(json) { panic(fmt.Errorf("json file content can't be blank")) } event := &types.AddEvent{} jsonz.UnmarshalStruct([]byte(json), event) action.OnAddEvent(event) return } ns := namespace if stringz.IsBlankString(ns) { if len(args) > 0 { ns = args[0] } } if stringz.IsBlankString(ns) { panic("The namespace(master username) parameter cannot be blank. Either of the two commands, " + "`$ keepass add $username` or `$ keepass add -n $username` can be used.") } action.OnAddEvent(&types.AddEvent{ Namespace: ns, Nodes: []*types.Node{{ Alias: alias, Username: username, Password: password, Uri: uri, Note: note, }}, }) }, }
Cmd `keepass add` cmd
Add a password node into the namespace(master username) of $username.
Pattern: $ keepass add -n $namespace -a $alias -u $username -p $password ...
or
Pattern: $ keepass add $namespace -a $alias -u $username -p $password ...
e.g.:
$ keepass add -n photowey -a github -u photowey@github.com -p hello.github -i https://github.com -t "the username and password of github.com website".
or
$ keepass add photowey -a github -u photowey@github.com -p hello.github -i https://github.com -t "the username and password of github.com website".
or:
$ keepass add < testdata.json
Json example:
{ "namespace": "photowey", "nodes": [ { "alias": "github", "username": "photowey@github.com", "password": "hello.github", "uri": "https://github.com", "note": "the username and password of github.com website" } ] }
-n: namespace
-a: alias: the alias must be unique under the namespace of $username.
-p: password
-i: uri
-t: note
-
Add a password node (-u photowey@github.com -p hello.github) with the username photowey@github.com and password hello.github under the namespace of username photowey, using the alias github.
Functions ¶
This section is empty.
Types ¶
This section is empty.