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
cd0a33c7
Commit
cd0a33c7
authored
Apr 20, 2016
by
Michael Pfister
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adds repo version subcommand
Fixes #2571 License: MIT Signed-off-by:
Mike Pfister
<
pfista@gmail.com
>
parent
234afc88
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
0 deletions
+41
-0
core/commands/repo.go
core/commands/repo.go
+41
-0
No files found.
core/commands/repo.go
View file @
cd0a33c7
...
@@ -7,12 +7,17 @@ import (
...
@@ -7,12 +7,17 @@ import (
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
corerepo
"github.com/ipfs/go-ipfs/core/corerepo"
config
"github.com/ipfs/go-ipfs/repo/config"
config
"github.com/ipfs/go-ipfs/repo/config"
lockfile
"github.com/ipfs/go-ipfs/repo/fsrepo/lock"
lockfile
"github.com/ipfs/go-ipfs/repo/fsrepo/lock"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
u
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
u
"gx/ipfs/QmZNVWh8LLjAavuQ2JXuFmuYH3C11xo988vSgp7UQrTRj1/go-ipfs-util"
"io"
"io"
"os"
"os"
"path/filepath"
"path/filepath"
)
)
type
RepoVersion
struct
{
Version
string
}
var
RepoCmd
=
&
cmds
.
Command
{
var
RepoCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Manipulate the IPFS repo."
,
Tagline
:
"Manipulate the IPFS repo."
,
...
@@ -25,6 +30,7 @@ var RepoCmd = &cmds.Command{
...
@@ -25,6 +30,7 @@ var RepoCmd = &cmds.Command{
"gc"
:
repoGcCmd
,
"gc"
:
repoGcCmd
,
"stat"
:
repoStatCmd
,
"stat"
:
repoStatCmd
,
"fsck"
:
RepoFsckCmd
,
"fsck"
:
RepoFsckCmd
,
"version"
:
repoVersionCmd
,
},
},
}
}
...
@@ -208,5 +214,40 @@ daemons are running.
...
@@ -208,5 +214,40 @@ daemons are running.
Type
:
MessageOutput
{},
Type
:
MessageOutput
{},
Marshalers
:
cmds
.
MarshalerMap
{
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
MessageTextMarshaler
,
cmds
.
Text
:
MessageTextMarshaler
,
var
repoVersionCmd
=
&
cmds
.
Command
{
Helptext
:
cmds
.
HelpText
{
Tagline
:
"Show the repo version."
,
ShortDescription
:
`
'ipfs repo version' returns the current repo version.
`
,
},
Options
:
[]
cmds
.
Option
{
cmds
.
BoolOption
(
"quiet"
,
"q"
,
"Write minimal output."
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
res
.
SetOutput
(
&
RepoVersion
{
Version
:
fsrepo
.
RepoVersion
,
})
},
Type
:
RepoVersion
{},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
response
:=
res
.
Output
()
.
(
*
RepoVersion
)
quiet
,
_
,
err
:=
res
.
Request
()
.
Option
(
"quiet"
)
.
Bool
()
if
err
!=
nil
{
return
nil
,
err
}
buf
:=
new
(
bytes
.
Buffer
)
if
quiet
{
buf
=
bytes
.
NewBufferString
(
fmt
.
Sprintf
(
"fs-repo@%s
\n
"
,
response
.
Version
))
}
else
{
buf
=
bytes
.
NewBufferString
(
fmt
.
Sprintf
(
"ipfs repo version fs-repo@%s
\n
"
,
response
.
Version
))
}
return
buf
,
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