示例#1
0
文件: cat.go 项目: mappum/go-ipfs
func catCmd(c *commander.Command, inp []string) error {
	if len(inp) < 1 {
		u.POut(c.Long)
		return nil
	}

	expanded, err := u.ExpandPathnames(inp)
	if err != nil {
		return err
	}

	com := daemon.NewCommand()
	com.Command = "cat"
	com.Args = expanded

	err = daemon.SendCommand(com, "localhost:12345")
	if err != nil {
		n, err := localNode(false)
		if err != nil {
			return err
		}

		return commands.Cat(n, com.Args, com.Opts, os.Stdout)
	}
	return nil
}
示例#2
0
文件: ls.go 项目: mappum/go-ipfs
func lsCmd(c *commander.Command, inp []string) error {
	if len(inp) < 1 {
		u.POut(c.Long)
		return nil
	}

	com := daemon.NewCommand()
	com.Command = "ls"
	com.Args = inp
	err := daemon.SendCommand(com, "localhost:12345")
	if err != nil {
		fmt.Println(err)
		n, err := localNode(false)
		if err != nil {
			return err
		}

		return commands.Ls(n, com.Args, com.Opts, os.Stdout)
	}

	return nil
}
示例#3
0
文件: add.go 项目: mappum/go-ipfs
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)
	cmd.Args = inp
	cmd.Opts["r"] = c.Flag.Lookup("r").Value.Get()
	err := daemon.SendCommand(cmd, "localhost:12345")
	if err != nil {
		// Do locally
		n, err := localNode(false)
		if err != nil {
			return err
		}

		return commands.Add(n, cmd.Args, cmd.Opts, os.Stdout)
	}
	return nil
}