commands: make --version a synonym for 'version'
This commit is contained in:
parent
f04650163c
commit
e37c8bb223
@ -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
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
|
Loading…
Reference in New Issue
Block a user