Skip to content

Commit

Permalink
Add programatic defaults
Browse files Browse the repository at this point in the history
Also fixed up a few spelling errors and mistypes, here and there. Got everything I could find.

License: MIT
Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
  • Loading branch information
RichardLitt committed Mar 22, 2016
1 parent 7134930 commit 6b2f4f2
Show file tree
Hide file tree
Showing 31 changed files with 106 additions and 96 deletions.
18 changes: 9 additions & 9 deletions cmd/ipfs/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,15 +122,15 @@ future version, along with this notice. Please move to setting the HTTP Headers.
},

Options: []cmds.Option{
cmds.BoolOption(initOptionKwd, "Initialize IPFS with default settings if not already initialized"),
cmds.StringOption(routingOptionKwd, "Overrides the routing option (dht, supernode)"),
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem"),
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)"),
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount)"),
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount)"),
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes"),
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
cmds.BoolOption(initOptionKwd, "Initialize IPFS with default settings if not already initialized").Default(false),
cmds.StringOption(routingOptionKwd, "Overrides the routing option (dht, supernode)").Default(false),
cmds.BoolOption(mountKwd, "Mounts IPFS to the filesystem").Default(false),
cmds.BoolOption(writableKwd, "Enable writing objects (with POST, PUT and DELETE)").Default(false),
cmds.StringOption(ipfsMountKwd, "Path to the mountpoint for IPFS (if using --mount)").Default("/ipfs"),
cmds.StringOption(ipnsMountKwd, "Path to the mountpoint for IPNS (if using --mount)").Default("/ipns"),
cmds.BoolOption(unrestrictedApiAccessKwd, "Allow API access to unlisted hashes").Default(true),
cmds.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)").Default(false),
cmds.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection").Default(false),

// TODO: add way to override addresses. tricky part: updating the config if also --init.
// cmds.StringOption(apiAddrKwd, "Address for the daemon rpc API (overrides config)"),
Expand Down
6 changes: 3 additions & 3 deletions cmd/ipfs/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
},

Options: []cmds.Option{
cmds.IntOption("bits", "b", fmt.Sprintf("Number of bits to use in the generated RSA private key (defaults to %d)", nBitsForKeypairDefault)),
cmds.BoolOption("force", "f", "Overwrite existing config (if it exists)."),
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."),
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key").Default(fmt.Sprintf("%d", nBitsForKeypairDefault)),
cmds.BoolOption("force", "f", "Overwrite existing config (if it exists).").Default(false),
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage.").Default(false),

// TODO need to decide whether to expose the override as a file or a
// directory. That is: should we allow the user to also specify the
Expand Down
2 changes: 1 addition & 1 deletion core/commands/active.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Lists running and recently run commands.
res.SetOutput(req.InvocContext().ReqLog.Report())
},
Options: []cmds.Option{
cmds.BoolOption("v", "verbose", "print more verbose output"),
cmds.BoolOption("v", "verbose", "print more verbose output").Default(false),
},
Subcommands: map[string]*cmds.Command{
"clear": clearInactiveCmd,
Expand Down
18 changes: 9 additions & 9 deletions core/commands/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ MerkleDAG.
},
Options: []cmds.Option{
cmds.OptionRecursivePath, // a builtin option that allows recursive paths (-r, --recursive)
cmds.BoolOption(quietOptionName, "q", "Write minimal output."),
cmds.BoolOption(silentOptionName, "Write no output."),
cmds.BoolOption(progressOptionName, "p", "Stream progress data."),
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation."),
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk."),
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object."),
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add."),
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm to use."),
cmds.BoolOption(pinOptionName, "Pin this object when adding. Default: true."),
cmds.BoolOption(quietOptionName, "q", "Write minimal output.").Default(false),
cmds.BoolOption(silentOptionName, "Write no output.").Default(false),
cmds.BoolOption(progressOptionName, "p", "Stream progress data.").Default(false),
cmds.BoolOption(trickleOptionName, "t", "Use trickle-dag format for dag generation.").Default(false),
cmds.BoolOption(onlyHashOptionName, "n", "Only chunk and hash - do not write to disk.").Default(false),
cmds.BoolOption(wrapOptionName, "w", "Wrap files with a directory object.").Default(false),
cmds.BoolOption(hiddenOptionName, "H", "Include files that are hidden. Only takes effect on recursive add.").Default(false),
cmds.StringOption(chunkerOptionName, "s", "Chunking algorithm to use.").Default(false),
cmds.BoolOption(pinOptionName, "Pin this object when adding.").Default(true),
},
PreRun: func(req cmds.Request) error {
if quiet, _, _ := req.Option(quietOptionName).Bool(); quiet {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ var showWantlistCmd = &cmds.Command{
Print out all blocks currently on the bitswap wantlist for the local peer.`,
},
Options: []cmds.Option{
cmds.StringOption("peer", "p", "Specify which peer to show wantlist for. Default: self."),
cmds.StringOption("peer", "p", "Specify which peer to show wantlist for.").Default("self"),
},
Type: KeyList{},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down
4 changes: 2 additions & 2 deletions core/commands/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ in the bootstrap list).
},

Options: []cmds.Option{
cmds.BoolOption("default", "Add default bootstrap nodes."),
cmds.BoolOption("default", "Add default bootstrap nodes.").Default(false),
},

Run: func(req cmds.Request, res cmds.Response) {
Expand Down Expand Up @@ -137,7 +137,7 @@ var bootstrapRemoveCmd = &cmds.Command{
cmds.StringArg("peer", false, true, peerOptionDesc).EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("all", "Remove all bootstrap peers."),
cmds.BoolOption("all", "Remove all bootstrap peers.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
input, err := config.ParseBootstrapPeers(req.Arguments())
Expand Down
2 changes: 1 addition & 1 deletion core/commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
ShortDescription: `Lists all available commands (and subcommands) and exits.`,
},
Options: []cmds.Option{
cmds.BoolOption(flagsOptionName, "f", "Show command flags"),
cmds.BoolOption(flagsOptionName, "f", "Show command flags").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
showOptions, _, _ := req.Option(flagsOptionName).Bool()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ Set the value of the 'datastore.path' key:
cmds.StringArg("value", false, false, "The value to set the config entry to."),
},
Options: []cmds.Option{
cmds.BoolOption("bool", "Set a boolean value. Default: false."),
cmds.BoolOption("json", "Parse stringified JSON. Default: false."),
cmds.BoolOption("bool", "Set a boolean value.").Default(false),
cmds.BoolOption("json", "Parse stringified JSON.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
args := req.Arguments()
Expand Down
8 changes: 4 additions & 4 deletions core/commands/dht.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ var queryDhtCmd = &cmds.Command{
cmds.StringArg("peerID", true, true, "The peerID to run the query against."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Write extra information."),
cmds.BoolOption("verbose", "v", "Write extra information.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -129,7 +129,7 @@ FindProviders will return a list of peers who are able to provide the value requ
cmds.StringArg("key", true, true, "The key to find providers for."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Write extra information."),
cmds.BoolOption("verbose", "v", "Write extra information.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -327,7 +327,7 @@ GetValue will return the value stored in the DHT at the given key.
cmds.StringArg("key", true, true, "The key to find a value for."),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Write extra information."),
cmds.BoolOption("verbose", "v", "Write extra information.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -431,7 +431,7 @@ PutValue will store the given key value pair in the DHT.
cmds.StringArg("value", true, false, "The value to store.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("verbose", "v", "Write extra information."),
cmds.BoolOption("verbose", "v", "Write extra information.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
11 changes: 6 additions & 5 deletions core/commands/diag.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ type DiagnosticConnection struct {
var (
visD3 = "d3"
visDot = "dot"
visFmts = []string{visD3, visDot}
visText = "text"
visFmts = []string{visD3, visDot, visText}
)

type DiagnosticPeer struct {
Expand Down Expand Up @@ -66,8 +67,8 @@ timeout. If the timeout is too small, some peers may not be reached.
The default timeout is 20 seconds.
The 'vis' option may be used to change the output format.
Four formats are supported:
* plain text - Easy to read. Default.
Three formats are supported:
* text - Easy to read. Default.
* d3 - json ready to be fed into d3view
* dot - graphviz format
Expand All @@ -81,13 +82,13 @@ open the following link:
http://gateway.ipfs.io/ipfs/QmbesKpGyQGd5jtJFUGEB1ByPjNFpukhnKZDnkfxUiKn38/chord#<your hash>
The dot format can be fed into graphviz and other programs
The 'dot' format can be fed into graphviz and other programs
that consume the dot format to generate graphs of the network.
`,
},

Options: []cmds.Option{
cmds.StringOption("vis", "Output vis. One of: "+strings.Join(visFmts, ", ")),
cmds.StringOption("vis", "Output format. One of: "+strings.Join(visFmts, ", ")).Default("text"),
},

Run: func(req cmds.Request, res cmds.Response) {
Expand Down
2 changes: 1 addition & 1 deletion core/commands/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ The resolver can recursively resolve:
cmds.StringArg("domain-name", true, false, "The domain-name name to resolve.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Resolve until the result is not a DNS link. Default: false."),
cmds.BoolOption("recursive", "r", "Resolve until the result is not a DNS link.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {

Expand Down
4 changes: 2 additions & 2 deletions core/commands/external.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ func ExternalBinary() *cmds.Command {
if arg == "--help" || arg == "-h" {
buf := new(bytes.Buffer)
fmt.Fprintf(buf, "%s is an 'external' command.\n", binname)
fmt.Fprintf(buf, "it does not currently appear to be installed.\n")
fmt.Fprintf(buf, "please refer to the ipfs documentation for instructions\n")
fmt.Fprintf(buf, "It does not currently appear to be installed.\n")
fmt.Fprintf(buf, "Please refer to the ipfs documentation for instructions.\n")
res.SetOutput(buf)
return
}
Expand Down
20 changes: 10 additions & 10 deletions core/commands/files/files.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ on the files in question, then data may be lost. This also applies to running
`,
},
Options: []cmds.Option{
cmds.BoolOption("f", "flush", "Flush target and ancestors after write. Default: true."),
cmds.BoolOption("f", "flush", "Flush target and ancestors after write.").Default(true),
},
Subcommands: map[string]*cmds.Command{
"read": FilesReadCmd,
Expand Down Expand Up @@ -249,10 +249,10 @@ Examples:
`,
},
Arguments: []cmds.Argument{
cmds.StringArg("path", false, false, "Path to show listing for. Defaults to '/'."),
cmds.StringArg("path", false, false, "Path to show listing for.").Default('/'),
},
Options: []cmds.Option{
cmds.BoolOption("l", "Use long listing format."),
cmds.BoolOption("l", "Use long listing format.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
var arg string
Expand Down Expand Up @@ -348,7 +348,7 @@ Examples:
cmds.StringArg("path", true, false, "Path to file to be read."),
},
Options: []cmds.Option{
cmds.IntOption("o", "offset", "Byte offset to begin reading from."),
cmds.IntOption("o", "offset", "Byte offset to begin reading from.").Default(false),
cmds.IntOption("n", "count", "Maximum number of bytes to read."),
},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down Expand Up @@ -516,9 +516,9 @@ Warning:
cmds.FileArg("data", true, false, "Data to write.").EnableStdin(),
},
Options: []cmds.Option{
cmds.IntOption("o", "offset", "Byte offset to begin writing at."),
cmds.BoolOption("e", "create", "Create the file if it does not exist."),
cmds.BoolOption("t", "truncate", "Truncate the file to size zero before writing."),
cmds.IntOption("o", "offset", "Byte offset to begin writing at.").Default(0),
cmds.BoolOption("e", "create", "Create the file if it does not exist.").Default(false),
cmds.BoolOption("t", "truncate", "Truncate the file to size zero before writing.").Default(false),
cmds.IntOption("n", "count", "Maximum number of bytes to read."),
},
Run: func(req cmds.Request, res cmds.Response) {
Expand Down Expand Up @@ -629,7 +629,7 @@ Examples:
cmds.StringArg("path", true, false, "Path to dir to make."),
},
Options: []cmds.Option{
cmds.BoolOption("p", "parents", "No error if existing, make parent directories as needed."),
cmds.BoolOption("p", "parents", "No error if existing, make parent directories as needed.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -668,7 +668,7 @@ are run with the '--flush=false'.
`,
},
Arguments: []cmds.Argument{
cmds.StringArg("path", false, false, "Path to flush. Default: '/'."),
cmds.StringArg("path", false, false, "Path to flush.").Default("/"),
},
Run: func(req cmds.Request, res cmds.Response) {
nd, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -709,7 +709,7 @@ Remove files or directories.
cmds.StringArg("path", true, true, "File to remove."),
},
Options: []cmds.Option{
cmds.BoolOption("r", "recursive", "Recursively remove directories."),
cmds.BoolOption("r", "recursive", "Recursively remove directories.").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
nd, err := req.InvocContext().GetNode()
Expand Down
8 changes: 4 additions & 4 deletions core/commands/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ may also specify the level of compression by specifying '-l=<1-9>'.
cmds.StringArg("ipfs-path", true, false, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
},
Options: []cmds.Option{
cmds.StringOption("output", "o", "The path where the output should be stored."),
cmds.BoolOption("archive", "a", "Output a TAR archive. Default: false."),
cmds.BoolOption("compress", "C", "Compress the output with GZIP compression. Default: false."),
cmds.IntOption("compression-level", "l", "The level of compression (1-9). Default: -1."),
cmds.StringOption("output", "o", "The path where the output should be stored.").Default("'./<ipfs-path>'"),
cmds.BoolOption("archive", "a", "Output a TAR archive.").Default(false),
cmds.BoolOption("compress", "C", "Compress the output with GZIP compression.").Default(false),
cmds.IntOption("compression-level", "l", "The level of compression (1-9).").Default(-1),
},
PreRun: func(req cmds.Request) error {
_, err := getCompressOptions(req)
Expand Down
7 changes: 4 additions & 3 deletions core/commands/ipns.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,12 @@ Resolve the value of another name:
},

Arguments: []cmds.Argument{
cmds.StringArg("name", false, false, "The IPNS name to resolve. Defaults to your node's peerID.").EnableStdin(),
cmds.StringArg("name", false, false, "The IPNS name to resolve.").EnableStdin().Default("your node's peerID"),
},
Options: []cmds.Option{
cmds.BoolOption("recursive", "r", "Resolve until the result is not an IPNS name."),
cmds.BoolOption("nocache", "n", "Do not used cached entries."),
cmds.BoolOption("recursive", "r", "Resolve until the result is not an IPNS name.").Default(false),
cmds.BoolOption("nocache", "n", "Do not use cached entries.").Default(false),
cmds.BoolOption("local", "l", "Use only local entires").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {

Expand Down
2 changes: 1 addition & 1 deletion core/commands/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Displays the links an IPFS or IPNS object(s) contains, with the following format
cmds.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to list links from.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
node, err := req.InvocContext().GetNode()
Expand Down
4 changes: 2 additions & 2 deletions core/commands/mount_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ baz
`,
},
Options: []cmds.Option{
cmds.StringOption("ipfs-path", "f", "The path where IPFS should be mounted."),
cmds.StringOption("ipns-path", "n", "The path where IPNS should be mounted."),
cmds.StringOption("ipfs-path", "f", "The path where IPFS should be mounted.").Default("'/ipfs'"),
cmds.StringOption("ipns-path", "n", "The path where IPNS should be mounted.").Default("'/ipns'"),
},
Run: func(req cmds.Request, res cmds.Response) {
cfg, err := req.InvocContext().GetConfig()
Expand Down
6 changes: 3 additions & 3 deletions core/commands/object/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ multihash.
cmds.StringArg("key", true, false, "Key of the object to retrieve, in base58-encoded multihash format.").EnableStdin(),
},
Options: []cmds.Option{
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name)."),
cmds.BoolOption("headers", "v", "Print table headers (Hash, Size, Name).").Default(false),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -341,7 +341,7 @@ And then run:
cmds.FileArg("data", true, false, "Data to be stored as a DAG object.").EnableStdin(),
},
Options: []cmds.Option{
cmds.StringOption("inputenc", "Encoding type of input data, either \"protobuf\" or \"json\"."),
cmds.StringOption("inputenc", "Encoding type of input data. One of: protobuf, json.").Default("json"),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down Expand Up @@ -403,7 +403,7 @@ Available templates:
`,
},
Arguments: []cmds.Argument{
cmds.StringArg("template", false, false, "Template to use. Optional."),
cmds.StringArg("template", false, false, "Template to use."),
},
Run: func(req cmds.Request, res cmds.Response) {
n, err := req.InvocContext().GetNode()
Expand Down
2 changes: 1 addition & 1 deletion core/commands/object/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ a file containing 'bar', and returns the hash of the new object.
`,
},
Options: []cmds.Option{
cmds.BoolOption("p", "create", "Create intermediary nodes."),
cmds.BoolOption("p", "create", "Create intermediary nodes.").Default(false),
},
Arguments: []cmds.Argument{
cmds.StringArg("root", true, false, "The hash of the node to modify."),
Expand Down
Loading

0 comments on commit 6b2f4f2

Please sign in to comment.