Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
78119839
Commit
78119839
authored
Nov 03, 2015
by
Jeromy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add option to version command to print repo version
License: MIT Signed-off-by:
Jeromy
<
jeromyj@gmail.com
>
parent
b508c23b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
2 deletions
+15
-2
core/commands/version.go
core/commands/version.go
+15
-2
No files found.
core/commands/version.go
View file @
78119839
...
...
@@ -7,11 +7,13 @@ import (
cmds
"github.com/ipfs/go-ipfs/commands"
config
"github.com/ipfs/go-ipfs/repo/config"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
)
type
VersionOutput
struct
{
Version
string
Commit
string
Commit
string
Repo
string
}
var
VersionCmd
=
&
cmds
.
Command
{
...
...
@@ -23,17 +25,28 @@ var VersionCmd = &cmds.Command{
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"number"
,
"n"
,
"Only show the version number"
),
cmds
.
BoolOption
(
"commit"
,
"Show the commit hash"
),
cmds
.
BoolOption
(
"repo"
,
"Show repo version"
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
res
.
SetOutput
(
&
VersionOutput
{
Version
:
config
.
CurrentVersionNumber
,
Commit
:
config
.
CurrentCommit
,
Commit
:
config
.
CurrentCommit
,
Repo
:
fsrepo
.
RepoVersion
,
})
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
v
:=
res
.
Output
()
.
(
*
VersionOutput
)
repo
,
_
,
err
:=
res
.
Request
()
.
Option
(
"repo"
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
if
repo
{
return
strings
.
NewReader
(
v
.
Repo
+
"
\n
"
),
nil
}
commit
,
found
,
err
:=
res
.
Request
()
.
Option
(
"commit"
)
.
Bool
()
commitTxt
:=
""
if
err
!=
nil
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment