added --version flag

This commit is contained in:
Fabien Potencier 2017-02-22 22:38:57 -08:00
parent 3fb2ea224b
commit 260fd61355

12
main.go
View file

@ -10,6 +10,10 @@ import (
"github.com/splitsh/lite/splitter"
)
var (
version = "dev"
)
type prefixesFlag []*splitter.Prefix
func (p *prefixesFlag) String() string {
@ -38,7 +42,7 @@ func (p *prefixesFlag) Set(value string) error {
var prefixes prefixesFlag
var origin, target, commit, path, gitVersion string
var scratch, debug, quiet, legacy, progress bool
var scratch, debug, quiet, legacy, progress, v bool
func init() {
flag.Var(&prefixes, "prefix", "The directory(ies) to split")
@ -52,11 +56,17 @@ func init() {
flag.BoolVar(&legacy, "legacy", false, "[DEPRECATED] Enable the legacy mode for projects migrating from an old version of git subtree split (optional)")
flag.StringVar(&gitVersion, "git", "latest", "Simulate a given version of Git (optional)")
flag.BoolVar(&progress, "progress", false, "Show progress bar (optional, cannot be enabled when debug is enabled)")
flag.BoolVar(&v, "version", false, "Show version")
}
func main() {
flag.Parse()
if v {
fmt.Printf("splitsh-lite version %s\n", version)
os.Exit(0)
}
if len(prefixes) == 0 {
fmt.Println("You must provide the directory to split via the --prefix flag")
os.Exit(1)