Beispiel #1
0
func ex_make_cmd_subcmd2() *commander.Command {
	cmd := &commander.Command{
		UsageLine: "subcmd2",
		Short:     "subcmd2 subcommand. does subcmd2 thingies (help list)",
		List:      commander.HelpTopicsList,
		Subcommands: []*commander.Command{
			ex_make_cmd_subcmd2_cmd1(),
			ex_make_cmd_subcmd2_cmd2(),
		},
		Flag: *flag.NewFlagSet("my-cmd-subcmd2", flag.ExitOnError),
	}
	return cmd
}
Beispiel #2
0
func ex_make_cmd_subcmd2_cmd1() *commander.Command {
	cmd := &commander.Command{
		Run:       ex_run_cmd_subcmd2_cmd1,
		UsageLine: "cmd1 [options]",
		Short:     "runs cmd1 and exits",
		Long: `
runs cmd1 and exits.

ex:
 $ my-cmd subcmd2 cmd1
`,
		Flag: *flag.NewFlagSet("my-cmd-subcmd2-cmd1", flag.ExitOnError),
	}
	cmd.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
	return cmd
}
Beispiel #3
0
var cmdIpfsRefs = &commander.Command{
	UsageLine: "refs",
	Short:     "List link hashes from an object.",
	Long: `ipfs refs <ipfs-path> - List link hashes from an object..

    Retrieves the object named by <ipfs-path> and displays the link
    hashes it contains, with the following format:

    <link base58 hash>

    Note: list all refs recursively with -r.

`,
	Run:  refCmd,
	Flag: *flag.NewFlagSet("ipfs-refs", flag.ExitOnError),
}

func init() {
	cmdIpfsRefs.Flag.Bool("r", false, "recursive: list refs recursively")
	cmdIpfsRefs.Flag.Bool("u", false, "unique: list each ref only once")
}

func refCmd(c *commander.Command, inp []string) error {
	if len(inp) < 1 {
		u.POut(c.Long)
		return nil
	}

	n, err := localNode(false)
	if err != nil {
Beispiel #4
0
	config "github.com/jbenet/go-ipfs/config"
	ci "github.com/jbenet/go-ipfs/crypto"
	identify "github.com/jbenet/go-ipfs/identify"
	u "github.com/jbenet/go-ipfs/util"
)

var cmdIpfsInit = &commander.Command{
	UsageLine: "init",
	Short:     "Initialize ipfs local configuration",
	Long: `ipfs init

	Initializes ipfs configuration files and generates a
	new keypair.
`,
	Run:  initCmd,
	Flag: *flag.NewFlagSet("ipfs-init", flag.ExitOnError),
}

func init() {
	cmdIpfsInit.Flag.Int("b", 4096, "number of bits for keypair")
	cmdIpfsInit.Flag.String("p", "", "passphrase for encrypting keys")
	cmdIpfsInit.Flag.Bool("f", false, "force overwrite of existing config")
}

func initCmd(c *commander.Command, inp []string) error {
	filename, err := config.Filename(config.DefaultConfigFilePath)
	if err != nil {
		return errors.New("Couldn't get home directory path")
	}
	fi, err := os.Lstat(filename)
	force := c.Flag.Lookup("f").Value.Get().(bool)
Beispiel #5
0
    ipfs config --show         - Show config file
    ipfs config --edit         - Edit config file in $EDITOR

Examples:

  Get the value of the 'datastore.path' key:

      ipfs config datastore.path

  Set the value of the 'datastore.path' key:

      ipfs config datastore.path ~/.go-ipfs/datastore

`,
	Run:  configCmd,
	Flag: *flag.NewFlagSet("ipfs-config", flag.ExitOnError),
}

func init() {
	cmdIpfsConfig.Flag.Bool("edit", false, "Edit config file in $EDITOR")
	cmdIpfsConfig.Flag.Bool("show", false, "Show config file")
}

func configCmd(c *commander.Command, inp []string) error {

	// todo: implement --config filename flag.
	filename, err := config.Filename("")
	if err != nil {
		return err
	}
Beispiel #6
0
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
)

var cmd_cmd1 = &commander.Command{
	Run:       ex_run_cmd_cmd1,
	UsageLine: "cmd1 [options]",
	Short:     "runs cmd1 and exits",
	Long: `
runs cmd1 and exits.

ex:
$ my-cmd cmd1
`,
	Flag: *flag.NewFlagSet("my-cmd-cmd1", flag.ExitOnError),
}

func init() {
	cmd_cmd1.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
}

func ex_run_cmd_cmd1(cmd *commander.Command, args []string) error {
	name := "my-cmd-" + cmd.Name()
	quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
	fmt.Printf("%s: hello from cmd1 (quiet=%v)\n", name, quiet)
	return nil
}

// EOF
Beispiel #7
0
	rofs "github.com/jbenet/go-ipfs/fuse/readonly"
	u "github.com/jbenet/go-ipfs/util"
)

var cmdIpfsMount = &commander.Command{
	UsageLine: "mount",
	Short:     "Mount an ipfs read-only mountpoint.",
	Long: `ipfs mount <os-path> - Mount an ipfs read-only mountpoint.

    Mount ipfs at a read-only mountpoint on the OS. All ipfs objects
    will be accessible under that directory. Note that the root will
    not be listable, as it is virtual. Accessing known paths directly.

`,
	Run:  mountCmd,
	Flag: *flag.NewFlagSet("ipfs-mount", flag.ExitOnError),
}

func mountCmd(c *commander.Command, inp []string) error {
	u.Debug = true
	if len(inp) < 1 || len(inp[0]) == 0 {
		u.POut(c.Long)
		return nil
	}
	fmt.Println("wtf.")

	n, err := localNode(true)
	if err != nil {
		return err
	}
Beispiel #8
0
// Error indicating the max depth has been exceded.
var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")

var cmdIpfsAdd = &commander.Command{
	UsageLine: "add",
	Short:     "Add an object to ipfs.",
	Long: `ipfs add <path>... - Add objects to ipfs.

    Adds contents of <path> to ipfs. Use -r to add directories.
    Note that directories are added recursively, to form the ipfs
    MerkleDAG. A smarter partial add with a staging area (like git)
    remains to be implemented.
`,
	Run:  addCmd,
	Flag: *flag.NewFlagSet("ipfs-add", flag.ExitOnError),
}

func init() {
	cmdIpfsAdd.Flag.Bool("r", false, "add objects recursively")
}

func addCmd(c *commander.Command, inp []string) error {
	if len(inp) < 1 {
		u.POut(c.Long)
		return nil
	}

	cmd := daemon.NewCommand()
	cmd.Command = "add"
	fmt.Println(inp)
Beispiel #9
0
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
)

var cmd_subcmd1_cmd2 = &commander.Command{
	Run:       ex_run_cmd_subcmd1_cmd2,
	UsageLine: "cmd2 [options]",
	Short:     "runs cmd2 and exits",
	Long: `
runs cmd2 and exits.

ex:
$ my-cmd subcmd1 cmd2
`,
	Flag: *flag.NewFlagSet("my-cmd-subcmd1-cmd2", flag.ExitOnError),
}

func init() {
	cmd_subcmd1_cmd2.Flag.Bool("q", true, "only print error and warning messages, all other output will be suppressed")
}

func ex_run_cmd_subcmd1_cmd2(cmd *commander.Command, args []string) error {
	name := "my-cmd-subcmd1-" + cmd.Name()
	quiet := cmd.Flag.Lookup("q").Value.Get().(bool)
	fmt.Printf("%s: hello from subcmd1-cmd2 (quiet=%v)\n", name, quiet)
	return nil
}

// EOF