Skip to content
This repository has been archived by the owner on Apr 28, 2020. It is now read-only.

Added version flag #169

Merged
merged 16 commits into from May 23, 2019
1 change: 1 addition & 0 deletions main.go
Expand Up @@ -66,6 +66,7 @@ func (r rootCmd) Subcommands() []cli.Command {
&rmcmd{gf: &r.globalFlags},
&proxycmd{},
&chromeExtInstall{},
&versioncmd{},
}
}

Expand Down
29 changes: 29 additions & 0 deletions versionmd.go
@@ -0,0 +1,29 @@
package main

import (
"flag"
"fmt"

"go.coder.com/cli"
)

var version string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this populated?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ci/build.sh

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, duh


type versioncmd struct {
print bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this variable is used

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that I was going to use it but did not. Will remove it.

}

func (v *versioncmd) Spec() cli.CommandSpec {
return cli.CommandSpec{
Name: "version",
Desc: fmt.Sprintf("Retrieve the current version"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should end with a period

}
}

func (v *versioncmd) RegisterFlags(fl *flag.FlagSet) {
fl.BoolVar(&v.print, "print", false, "Print the current version of Sail")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
fl.BoolVar(&v.print, "print", false, "Print the current version of Sail")
fl.BoolVar(&v.print, "print", false, "Print the current version")

}

func (v *versioncmd) Run(fl *flag.FlagSet) {
fmt.Printf("Sail version: %s", version)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should just print the version so sail version can be more easily used in scripts.

}