-
Notifications
You must be signed in to change notification settings - Fork 3
/
secret.go
52 lines (39 loc) · 1.11 KB
/
secret.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package main
import (
"flag"
"fmt"
"github.com/hexops/cmder"
)
// secretCommands contains all registered 'wrench secret' subcommands.
var secretCommands cmder.Commander
var (
secretFlagSet = flag.NewFlagSet("secret", flag.ExitOnError)
secretConfigFile = secretFlagSet.String("config", defaultConfigFilePath(), "Path to TOML configuration file (see config.go)")
)
func init() {
const usage = `wrench secret: manage wrench as a secret
Usage:
wrench secret [-config=config.toml] <command> [arguments]
The commands are:
list list all secrets
delete delete a secret
upsert create or update a secret
Use "wrench secret <command> -h" for more information about a command.
`
usageFunc := func() {
fmt.Printf("%s", usage)
}
secretFlagSet.Usage = usageFunc
// Handles calls to our subcommand.
handler := func(args []string) error {
_ = secretFlagSet.Parse(args)
secretCommands.Run(secretFlagSet, "wrench secret", usage, args)
return nil
}
// Register the command.
commands = append(commands, &cmder.Command{
FlagSet: secretFlagSet,
Handler: handler,
UsageFunc: usageFunc,
})
}