Skip to content
This repository has been archived by the owner on Jun 13, 2021. It is now read-only.

Commit

Permalink
Remove version command, introduce --version option
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
  • Loading branch information
ndeloof committed Sep 16, 2019
1 parent c9eb813 commit fb735ca
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 85 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,6 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information
Run 'docker app COMMAND --help' for more information on a command.
```
Expand Down
37 changes: 0 additions & 37 deletions e2e/base_invocation_image_test.go

This file was deleted.

2 changes: 1 addition & 1 deletion e2e/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestMain(m *testing.M) {

dockerCli = dockerCliCommand{path: dockerCliPath, cliPluginDir: cliPluginDir}

cmd := exec.Command(dockerApp, "app", "version")
cmd := exec.Command(dockerApp, "app", "--version")
output, err := cmd.CombinedOutput()
if err != nil {
panic(err)
Expand Down
6 changes: 4 additions & 2 deletions e2e/testdata/plugin-usage-experimental.golden
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

Usage: docker app COMMAND
Usage: docker app [OPTIONS] COMMAND

A tool to build and manage Docker Applications.

Options:
--version Print version information

Commands:
bundle Create a CNAB invocation image and `bundle.json` for the application
init Initialize Docker Application definition
Expand All @@ -16,6 +19,5 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information

Run 'docker app COMMAND --help' for more information on a command.
6 changes: 4 additions & 2 deletions e2e/testdata/plugin-usage.golden
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@

Usage: docker app COMMAND
Usage: docker app [OPTIONS] COMMAND

A tool to build and manage Docker Applications.

Options:
--version Print version information

Commands:
bundle Create a CNAB invocation image and `bundle.json` for the application
init Initialize Docker Application definition
Expand All @@ -16,6 +19,5 @@ Commands:
uninstall Uninstall an application
upgrade Upgrade an installed application
validate Checks the rendered application is syntactically correct
version Print version information

Run 'docker app COMMAND --help' for more information on a command.
12 changes: 10 additions & 2 deletions internal/commands/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package commands

import (
"fmt"
"github.com/docker/app/internal"
"io/ioutil"
"os"

Expand All @@ -14,6 +15,7 @@ import (

var (
completion string
showversion bool
)

// NewRootCmd returns the base root command.
Expand All @@ -24,6 +26,12 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {
Use: use,
Annotations: map[string]string{"experimentalCLI": "true"},
RunE: func(cmd *cobra.Command, args []string) error {

if showversion {
fmt.Fprintln(os.Stdout, internal.FullVersion()) //nolint:errcheck
return nil
}

switch completion {
case "bash":
return cmd.GenBashCompletion(dockerCli.Out())
Expand All @@ -41,10 +49,11 @@ func NewRootCmd(use string, dockerCli command.Cli) *cobra.Command {

cmd.Flags().StringVar(&completion, "completion", "", "Generates completion scripts for the specified shell (bash or zsh)")
if err := cmd.Flags().MarkHidden("completion"); err != nil {
_, _ = fmt.Fprintf(os.Stderr, "Failed to register command line options: %v", err.Error())
fmt.Fprintf(os.Stderr, "Failed to register command line options: %v", err.Error()) //nolit:errcheck
return nil
}

cmd.Flags().BoolVar(&showversion, "version", false,"Print version information")
return cmd
}

Expand All @@ -59,7 +68,6 @@ func addCommands(cmd *cobra.Command, dockerCli command.Cli) {
inspectCmd(dockerCli),
renderCmd(dockerCli),
validateCmd(),
versionCmd(dockerCli),
bundleCmd(dockerCli),
pushCmd(dockerCli),
pullCmd(dockerCli),
Expand Down
37 changes: 0 additions & 37 deletions internal/commands/version.go

This file was deleted.

5 changes: 2 additions & 3 deletions internal/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@ var (
)

// FullVersion returns a string of version information.
func FullVersion(invocationBaseImage string) string {
func FullVersion() string {
res := []string{
fmt.Sprintf("Version: %s", Version),
fmt.Sprintf("Git commit: %s", GitCommit),
fmt.Sprintf("Built: %s", reformatDate(BuildTime)),
fmt.Sprintf("OS/Arch: %s/%s", runtime.GOOS, runtime.GOARCH),
fmt.Sprintf("Experimental: %s", Experimental),
fmt.Sprintf("Invocation Base Image: %s", invocationBaseImage),
// +experimental fmt.Sprintf("Experimental: %s", Experimental),
}
return strings.Join(res, "\n")
}
Expand Down

0 comments on commit fb735ca

Please sign in to comment.