Exemple #1
0
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
}
Exemple #2
0
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
}
Exemple #3
0
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
}