From 921f1c977c4e0704f61e3a7c092d3a4317ab278c Mon Sep 17 00:00:00 2001 From: "Joe Richey joerichey@google.com" Date: Mon, 9 Oct 2017 19:12:49 -0700 Subject: Fixes --- ext4/ext4.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'ext4/ext4.go') diff --git a/ext4/ext4.go b/ext4/ext4.go index 7419929..063d68c 100644 --- a/ext4/ext4.go +++ b/ext4/ext4.go @@ -25,6 +25,9 @@ import ( "io" "io/ioutil" "os" + "time" + + "github.com/urfave/cli" ) var ( @@ -77,6 +80,38 @@ func printAndExit(err error, printUsage bool) { } func main() { + // Create our command line application + app := cli.NewApp() + app.Usage = shortUsage + app.Authors = Authors + app.Copyright = apache2GoogleCopyright + + // Grab the version and compilation time passed in from the Makefile. + app.Version = version + app.Compiled, _ = time.Parse(time.UnixDate, buildTime) + app.OnUsageError = onUsageError + + // Setup global flags + cli.HelpFlag = helpFlag + cli.VersionFlag = versionFlag + cli.VersionPrinter = func(c *cli.Context) { + cli.HelpPrinter(c.App.Writer, versionInfoTemplate, c.App) + } + app.Flags = universalFlags + + // We hide the help subcommand so that "fscrypt --help" works + // and "fscrypt help" does not. + app.HideHelp = true + + // Initialize command list and setup all of the commands. + app.Action = defaultAction + app.Commands = []cli.Command{Setup, Encrypt, Unlock, Purge, Status, Metadata} + for i := range app.Commands { + setupCommand(&app.Commands[i]) + } + + app.Run(os.Args) + set.SetOutput(ioutil.Discard) if err := set.Parse(os.Args[1:]); err != nil { printAndExit(err, true) -- cgit v1.2.3