diff --git a/cmd/ipfs/main.go b/cmd/ipfs/main.go index 817d72472..f5b035678 100644 --- a/cmd/ipfs/main.go +++ b/cmd/ipfs/main.go @@ -103,9 +103,13 @@ func main() { } // Handle `ipfs help' - if len(os.Args) == 2 && os.Args[1] == "help" { - printHelp(false, os.Stdout) - os.Exit(0) + if len(os.Args) == 2 { + if os.Args[1] == "help" { + printHelp(false, os.Stdout) + os.Exit(0) + } else if os.Args[1] == "--version" { + os.Args[1] = "version" + } } // parse the commandline into a command invocation diff --git a/test/sharness/t0010-basic-commands.sh b/test/sharness/t0010-basic-commands.sh index 4b05c99b6..a4d561435 100755 --- a/test/sharness/t0010-basic-commands.sh +++ b/test/sharness/t0010-basic-commands.sh @@ -16,11 +16,24 @@ test_expect_success "ipfs version succeeds" ' ipfs version >version.txt ' +test_expect_success "ipfs --version success" ' + ipfs --version || + test_fsh ipfs --version +' + test_expect_success "ipfs version output looks good" ' egrep "^ipfs version [0-9]+\.[0-9]+\.[0-9]" version.txt >/dev/null || test_fsh cat version.txt ' +test_expect_success "ipfs versions matches ipfs --version" ' + ipfs version > version.txt && + ipfs --version > version2.txt && + diff version2.txt version.txt || + test_fsh ipfs --version + +' + test_expect_success "ipfs version --all has all required fields" ' ipfs version --all > version_all.txt && grep "go-ipfs version" version_all.txt &&