Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add version --all option #2790

Merged
merged 3 commits into from
Jun 2, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions core/commands/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package commands
import (
"fmt"
"io"
"runtime"
"strings"

cmds "github.com/ipfs/go-ipfs/commands"
Expand All @@ -14,6 +15,8 @@ type VersionOutput struct {
Version string
Commit string
Repo string
System string
Golang string
}

var VersionCmd = &cmds.Command{
Expand All @@ -26,12 +29,15 @@ var VersionCmd = &cmds.Command{
cmds.BoolOption("number", "n", "Only show the version number.").Default(false),
cmds.BoolOption("commit", "Show the commit hash.").Default(false),
cmds.BoolOption("repo", "Show repo version.").Default(false),
cmds.BoolOption("all", "Show all version information").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
res.SetOutput(&VersionOutput{
Version: config.CurrentVersionNumber,
Commit: config.CurrentCommit,
Repo: fsrepo.RepoVersion,
System: runtime.GOARCH + "/" + runtime.GOOS, //TODO: Precise version here
Golang: runtime.Version(),
})
},
Marshalers: cmds.MarshalerMap{
Expand Down Expand Up @@ -64,6 +70,17 @@ var VersionCmd = &cmds.Command{
return strings.NewReader(fmt.Sprintln(v.Version + commitTxt)), nil
}

all, _, err := res.Request().Option("all").Bool()
if err != nil {
return nil, err
}
if all {
out := fmt.Sprintf("go-ipfs version: %s-%s\n"+
"Repo version: %s\nSystem version: %s\nGolang version: %s\n",
v.Version, v.Commit, v.Repo, v.System, v.Golang)
return strings.NewReader(out), nil
}

return strings.NewReader(fmt.Sprintf("ipfs version %s%s\n", v.Version, commitTxt)), nil
},
},
Expand Down
8 changes: 8 additions & 0 deletions test/sharness/t0010-basic-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ test_expect_success "ipfs version output looks good" '
test_fsh cat version.txt
'

test_expect_success "ipfs version --all has all required fields" '
ipfs version --all > version_all.txt &&
grep "go-ipfs version" version_all.txt &&
grep "Repo version" version_all.txt &&
grep "System version" version_all.txt &&
grep "Golang version" version_all.txt
'

test_expect_success "ipfs help succeeds" '
ipfs help >help.txt
'
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/t0500-issues-and-regressions-offline.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

test_description="Tests for various fxed issues and regressions."
test_description="Tests for various fixed issues and regressions."

. lib/test-lib.sh

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

test_description="Tests for various fxed issues and regressions."
test_description="Tests for various fixed issues and regressions."

. lib/test-lib.sh

Expand Down