cat.go 1.01 KB
Newer Older
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
1 2 3
package main

import (
4 5
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/gonuts/flag"
	"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/commander"
6
	"github.com/jbenet/go-ipfs/core/commands"
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
7 8 9 10 11 12 13 14 15 16 17 18 19 20
)

var cmdIpfsCat = &commander.Command{
	UsageLine: "cat",
	Short:     "Show ipfs object data.",
	Long: `ipfs cat <ipfs-path> - Show ipfs object data.

    Retrieves the object named by <ipfs-path> and displays the Data
    it contains.
`,
	Run:  catCmd,
	Flag: *flag.NewFlagSet("ipfs-cat", flag.ExitOnError),
}

21 22 23
var catCmd = MakeCommand("cat", nil, commands.Cat)

/*
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
24 25 26 27 28 29
func catCmd(c *commander.Command, inp []string) error {
	if len(inp) < 1 {
		u.POut(c.Long)
		return nil
	}

30 31 32 33 34
	conf, err := getConfigDir(c.Parent)
	if err != nil {
		return err
	}

35 36
	com := daemon.NewCommand()
	com.Command = "cat"
37
	com.Args = inp
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
38

39
	err = daemon.SendCommand(com, conf)
40
	if err != nil {
Jeromy's avatar
Jeromy committed
41
		n, err := localNode(conf, false)
Juan Batiz-Benet's avatar
Juan Batiz-Benet committed
42 43 44 45
		if err != nil {
			return err
		}

46
		return commands.Cat(n, com.Args, com.Opts, os.Stdout)
47 48 49
	}
	return nil
}
50
*/