refactor: punctuation, error handling and package docs

This commit is contained in:
decentral1se 2021-09-05 00:21:45 +02:00
parent 254a4d6d43
commit dac679db48
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC
2 changed files with 19 additions and 19 deletions

View File

@ -1,3 +1,4 @@
// Package cli provides the interface for the command-line.
package cli package cli
import ( import (
@ -12,10 +13,10 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
// Verbose stores the variable from VerboseFlag // Verbose stores the variable from VerboseFlag.
var Verbose bool var Verbose bool
// VerboseFlag turns on/off verbose logging down to the INFO level // VerboseFlag turns on/off verbose logging down to the INFO level.
var VerboseFlag = &cli.BoolFlag{ var VerboseFlag = &cli.BoolFlag{
Name: "verbose", Name: "verbose",
Aliases: []string{"V"}, Aliases: []string{"V"},
@ -24,10 +25,10 @@ var VerboseFlag = &cli.BoolFlag{
Usage: "Show INFO messages", Usage: "Show INFO messages",
} }
// Debug stores the variable from DebugFlag // Debug stores the variable from DebugFlag.
var Debug bool var Debug bool
// DebugFlag turns on/off verbose logging down to the DEBUG level // DebugFlag turns on/off verbose logging down to the DEBUG level.
var DebugFlag = &cli.BoolFlag{ var DebugFlag = &cli.BoolFlag{
Name: "debug", Name: "debug",
Aliases: []string{"d"}, Aliases: []string{"d"},
@ -36,10 +37,10 @@ var DebugFlag = &cli.BoolFlag{
Usage: "Show DEBUG messages", Usage: "Show DEBUG messages",
} }
// NoPrompt stores the variable from NoPromptFlag // NoPrompt stores the variable from NoPromptFlag.
var NoPrompt bool var NoPrompt bool
// NoPromptFlag turns on/off non-interactive mode where no user input is required // NoPromptFlag turns on/off non-interactive mode where no user input is required.
var NoPromptFlag = &cli.BoolFlag{ var NoPromptFlag = &cli.BoolFlag{
Name: "no-prompt", Name: "no-prompt",
Aliases: []string{"n"}, Aliases: []string{"n"},
@ -48,10 +49,10 @@ var NoPromptFlag = &cli.BoolFlag{
Usage: "Don't prompt for input and run non-interactively", Usage: "Don't prompt for input and run non-interactively",
} }
// Env stores the variable from EnvFlag // Env stores the variable from EnvFlag.
var Env string var Env string
// EnvFlag takes a path to an env file to load variables from for the abra cli cmd // EnvFlag takes a path to an env file to load variables from for the abra cli cmd.
var EnvFlag = &cli.PathFlag{ var EnvFlag = &cli.PathFlag{
Name: "env", Name: "env",
Aliases: []string{"e"}, Aliases: []string{"e"},
@ -60,10 +61,10 @@ var EnvFlag = &cli.PathFlag{
Usage: "Environment variables to load", Usage: "Environment variables to load",
} }
// Branch stores the variable from BranchFlag // Branch stores the variable from BranchFlag.
var Branch string var Branch string
// BranchFlag takes the name of the git branch to use in app cloning // BranchFlag takes the name of the git branch to use in app cloning.
var BranchFlag = &cli.StringFlag{ var BranchFlag = &cli.StringFlag{
Name: "branch", Name: "branch",
Aliases: []string{"b"}, Aliases: []string{"b"},
@ -75,7 +76,7 @@ var BranchFlag = &cli.StringFlag{
// SkipUpdate stores the variable from SkipUpdateFlag // SkipUpdate stores the variable from SkipUpdateFlag
var SkipUpdate bool var SkipUpdate bool
// SkipUpdateFlag allows users to skip updating recipe definitions // SkipUpdateFlag allows users to skip updating recipe definitions.
var SkipUpdateFlag = &cli.BoolFlag{ var SkipUpdateFlag = &cli.BoolFlag{
Name: "skip-update", Name: "skip-update",
Aliases: []string{"U"}, Aliases: []string{"U"},
@ -84,10 +85,10 @@ var SkipUpdateFlag = &cli.BoolFlag{
Usage: "Don't pull latest app definitions", Usage: "Don't pull latest app definitions",
} }
// SkipCheck stores the variable from SkipCheckFlag // SkipCheck stores the variable from SkipCheckFlag.
var SkipCheck bool var SkipCheck bool
// SkipCheckFlag allows users to skip checking app vars // SkipCheckFlag allows users to skip checking app vars.
var SkipCheckFlag = &cli.BoolFlag{ var SkipCheckFlag = &cli.BoolFlag{
Name: "skip-check", Name: "skip-check",
Aliases: []string{"C"}, Aliases: []string{"C"},
@ -96,10 +97,10 @@ var SkipCheckFlag = &cli.BoolFlag{
Usage: "Don't verify app variables", Usage: "Don't verify app variables",
} }
// Stack stores the variable from StackFlag // Stack stores the variable from StackFlag.
var Stack string var Stack string
// StackFlag gets the name of the target stack to run commands against // StackFlag gets the name of the target stack to run commands against.
var StackFlag = &cli.StringFlag{ var StackFlag = &cli.StringFlag{
Name: "stack", Name: "stack",
Aliases: []string{"s"}, Aliases: []string{"s"},
@ -108,7 +109,7 @@ var StackFlag = &cli.StringFlag{
Usage: "Name of the target stack", Usage: "Name of the target stack",
} }
// RunApp runs CLI abra app // RunApp runs CLI abra app.
func RunApp(version, commit string) { func RunApp(version, commit string) {
app := &cli.App{ app := &cli.App{
Name: "abra", Name: "abra",
@ -141,8 +142,7 @@ func RunApp(version, commit string) {
}, },
} }
err := app.Run(os.Args) if err := app.Run(os.Args); err != nil {
if err != nil {
logrus.Fatal(err) logrus.Fatal(err)
} }
} }

View File

@ -4,7 +4,7 @@ import (
"github.com/urfave/cli/v2" "github.com/urfave/cli/v2"
) )
// VersionCommand prints the version of abra // VersionCommand prints the version of abra.
var VersionCommand = &cli.Command{ var VersionCommand = &cli.Command{
Name: "version", Name: "version",
Usage: "Print the version", Usage: "Print the version",