// Package cli implements the sutil command tree. // // The tree is built by New rather than assembled in init functions, so // the package holds no global state and tests can construct it repeatedly // with captured input and output. package cli import ( "github.com/spf13/cobra" ) // Params configures New. type Params struct { // Version is the version string embedded at build time. It is shown // by `sutil version`, `sutil --version`, and `sutil info`. Version string } // New builds the root sutil command with every subcommand attached. func New(p Params) *cobra.Command { root := &cobra.Command{ Use: "sutil", Short: "sneak's shell utility", Long: `sutil is a small collection of shell utilities built on the packages in sneak.berlin/go/x: fast pseudorandom byte streams, memorable passwords, BIP39 mnemonics, and crypto_box keypairs derived from them.`, Version: p.Version, SilenceUsage: true, } root.AddCommand( newVersionCommand(p), newInfoCommand(p), newGenerateCommand(), newCBKCommand(), ) return root }