-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from kernle32dll/version-test
Add version command
- Loading branch information
Showing
5 changed files
with
53 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
) | ||
|
||
var ( | ||
buildBranch string | ||
buildDate string | ||
) | ||
|
||
// VersionCommand prints out the CLI help. | ||
type VersionCommand struct { | ||
output io.Writer | ||
} | ||
|
||
// NewVersionCommand creates a new VersionCommand. | ||
func NewVersionCommand( | ||
output io.Writer, | ||
) *VersionCommand { | ||
return &VersionCommand{ | ||
output: output, | ||
} | ||
} | ||
|
||
func (c VersionCommand) Execute() error { | ||
if buildBranch == "" { | ||
buildBranch = "master" | ||
} | ||
|
||
if buildDate != "" { | ||
fmt.Fprintf(c.output, "%s built %s\n", buildBranch, buildDate) | ||
} else { | ||
fmt.Fprintln(c.output, buildBranch) | ||
} | ||
|
||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters