commands: make --version a synonym for 'version'

This commit is contained in:
Taylor Blau 2018-04-12 11:45:54 -07:00
parent f04650163c
commit e37c8bb223
2 changed files with 28 additions and 0 deletions

@ -10,6 +10,7 @@ import (
"time"
"github.com/git-lfs/git-lfs/config"
"github.com/git-lfs/git-lfs/lfsapi"
"github.com/spf13/cobra"
)
@ -55,6 +56,10 @@ func Run() {
root := NewCommand("git-lfs", gitlfsCommand)
root.PreRun = nil
// Set up --version flag to be a synonym of version sub-command.
root.SetVersionTemplate("{{ .Version }}\n")
root.Version = lfsapi.UserAgent
// Set up help/usage funcs based on manpage text
root.SetHelpTemplate("{{.UsageString}}")
root.SetHelpFunc(helpCommand)

23
test/test-version.sh Executable file

@ -0,0 +1,23 @@
#!/usr/bin/env bash
. "test/testlib.sh"
begin_test "git lfs --version is a synonym of git lfs version"
(
set -e
reponame="git-lfs-version-synonymous"
mkdir "$reponame"
cd "$reponame"
git lfs version 2>&1 >version.log
git lfs --version 2>&1 >flag.log
if [ "$(cat version.log)" != "$(cat flag.log)" ]; then
echo >&2 "fatal: expected 'git lfs version' and 'git lfs --version' to"
echo >&2 "produce identical output ..."
diff -u {version,flag}.log
fi
)
end_test