Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide version info if user has not defined version [v2] #955

Merged
merged 4 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ func NewApp() *App {
HelpName: filepath.Base(os.Args[0]),
Usage: "A new cli application",
UsageText: "",
Version: "0.0.0",
BashComplete: DefaultAppComplete,
Action: helpCommand.Action,
Compiled: compileTime(),
Expand Down Expand Up @@ -141,7 +140,7 @@ func (a *App) Setup() {
}

if a.Version == "" {
a.Version = "0.0.0"
a.HideVersion = true
}

if a.BashComplete == nil {
Expand Down
8 changes: 1 addition & 7 deletions app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,11 @@ func ExampleApp_Run_noAction() {
// USAGE:
// greet [global options] command [command options] [arguments...]
//
// VERSION:
// 0.0.0
//
// COMMANDS:
// help, h Shows a list of commands or help for one command
//
// GLOBAL OPTIONS:
// --help, -h show help (default: false)
// --version, -v print the version (default: false)
// --help, -h show help (default: false)
}

func ExampleApp_Run_subcommandNoAction() {
Expand Down Expand Up @@ -256,8 +252,6 @@ func ExampleApp_Run_bashComplete_withShortFlag() {
// -x
// --help
// -h
// --version
// -v
}

func ExampleApp_Run_bashComplete_withLongFlag() {
Expand Down
5 changes: 1 addition & 4 deletions docs/v2/manual.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,11 @@ NAME:
USAGE:
greet [global options] command [command options] [arguments...]

VERSION:
0.0.0

COMMANDS:
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS
--version Shows version information
--help, -h show help (default: false)
```

### Arguments
Expand Down