package main
import (
"fmt"
"os"
"github.com/jawher/mow.cli"
)
// Global options available to any of the commands
var filename *string
func main() {
app := cli.App("vault", "Password Keeper")
// Define our top-level global options
filename = app.StringOpt("f file", "", "Path to safe")
// Define our command structure for usage like this:
app.Command("list", "list accounts", cmdList)
app.Run(os.Args)
}
// Sample use: vault list OR vault config list
func cmdList(cmd *cli.Cmd) {
cmd.Action = func() {
fmt.Printf("list the contents of the safe here")
}
}
The default value of filename is abc.txt which is specified when I execute the program.
~ ./vault -f abc.txt
Usage: vault [OPTIONS] COMMAND [arg...]
Password Keeper
Options:
-f, --file Path to safe (default "abc.txt")
Commands:
list list accounts
Run 'vault COMMAND --help' for more information on a command.
The default value of filename is abc.txt which is specified when I execute the program.