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-unixfs
Commits
81c6298a
Commit
81c6298a
authored
10 years ago
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cli tool beginning
parent
69e92f93
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
130 additions
and
0 deletions
+130
-0
cli/commands.go
cli/commands.go
+113
-0
cli/ipfs
cli/ipfs
+0
-0
cli/ipfs.go
cli/ipfs.go
+17
-0
No files found.
cli/commands.go
0 → 100644
View file @
81c6298a
package
main
import
(
"github.com/gonuts/flag"
"github.com/jbenet/commander"
u
"github.com/jbenet/go-ipfs/util"
"strings"
"time"
)
var
CmdIpfs
=
&
commander
.
Command
{
UsageLine
:
"ipfs [<flags>] <command> [<args>]"
,
Short
:
"global versioned p2p merkledag file system"
,
Long
:
`ipfs - global versioned p2p merkledag file system
Basic commands:
add <path> Add an object to ipfs.
cat <ref> Show ipfs object data.
ls <ref> List links from an object.
refs <ref> List link hashes from an object.
Tool commands:
config Manage configuration.
version Show ipfs version information.
commands List all available commands.
Advanced Commands:
mount Mount a ipfs a read-only mountpoint.
Use "ipfs help <command>" for more information about a command.
`
,
Run
:
ipfsCmd
,
Subcommands
:
[]
*
commander
.
Command
{
// cmdIpfsVersion,
// cmdIpfsConfig,
cmdIpfsCommands
,
},
Flag
:
*
flag
.
NewFlagSet
(
"ipfs"
,
flag
.
ExitOnError
),
}
func
ipfsCmd
(
c
*
commander
.
Command
,
args
[]
string
)
error
{
u
.
POut
(
c
.
Long
)
return
nil
}
var
cmdIpfsCommands
=
&
commander
.
Command
{
UsageLine
:
"commands"
,
Short
:
"List all available commands."
,
Long
:
`ipfs commands - List all available commands.
Lists all available commands (and sub-commands) and exits.
`
,
Run
:
commandsCmd
,
Subcommands
:
[]
*
commander
.
Command
{
cmdIpfsCommandsHelp
,
},
}
func
commandsCmd
(
c
*
commander
.
Command
,
args
[]
string
)
error
{
var
listCmds
func
(
c
*
commander
.
Command
)
listCmds
=
func
(
c
*
commander
.
Command
)
{
u
.
POut
(
"%s
\n
"
,
c
.
FullSpacedName
())
for
_
,
sc
:=
range
c
.
Subcommands
{
listCmds
(
sc
)
}
}
listCmds
(
c
.
Parent
)
return
nil
}
var
cmdIpfsCommandsHelp
=
&
commander
.
Command
{
UsageLine
:
"help"
,
Short
:
"List all available commands' help pages."
,
Long
:
`ipfs commands help - List all available commands's help pages.
Shows the pages of all available commands (and sub-commands) and exits.
Outputs a markdown document.
`
,
Run
:
commandsHelpCmd
,
}
func
commandsHelpCmd
(
c
*
commander
.
Command
,
args
[]
string
)
error
{
u
.
POut
(
referenceHeaderMsg
)
u
.
POut
(
"Generated on %s.
\n\n
"
,
time
.
Now
()
.
UTC
()
.
Format
(
"2006-01-02"
))
var
printCmds
func
(
*
commander
.
Command
,
int
)
printCmds
=
func
(
c
*
commander
.
Command
,
level
int
)
{
u
.
POut
(
"%s "
,
strings
.
Repeat
(
"#"
,
level
))
u
.
POut
(
"%s
\n\n
"
,
c
.
FullSpacedName
())
u
.
POut
(
"```
\n
"
)
u
.
POut
(
"%s
\n
"
,
c
.
Long
)
u
.
POut
(
"```
\n\n
"
)
for
_
,
sc
:=
range
c
.
Subcommands
{
printCmds
(
sc
,
level
+
1
)
}
}
printCmds
(
c
.
Parent
.
Parent
,
1
)
return
nil
}
const
referenceHeaderMsg
=
`
# ipfs command reference
This document lists every ipfs command (including subcommands), along with
its help page. It can be viewed by running 'ipfs commands help'.
`
This diff is collapsed.
Click to expand it.
cli/ipfs
0 → 100755
View file @
81c6298a
File added
This diff is collapsed.
Click to expand it.
cli/ipfs.go
0 → 100644
View file @
81c6298a
package
main
import
(
"fmt"
"os"
)
func
main
()
{
err
:=
CmdIpfs
.
Dispatch
(
os
.
Args
[
1
:
])
if
err
!=
nil
{
if
len
(
err
.
Error
())
>
0
{
fmt
.
Fprintf
(
os
.
Stderr
,
"%v
\n
"
,
err
)
}
os
.
Exit
(
1
)
}
return
}
This diff is collapsed.
Click to expand it.
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