commands

package
v0.0.0-...-e4696f9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2014 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var CommandsDaemonCmd = CommandsCmd(Root)

commandsDaemonCmd is the "ipfs commands" command for daemon

View Source
var DiagCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Generates diagnostic reports",
	},

	Subcommands: map[string]*cmds.Command{
		"net": diagNetCmd,
	},
}
View Source
var ErrDepthLimitExceeded = fmt.Errorf("depth limit exceeded")

Error indicating the max depth has been exceded.

View Source
var ErrObjectTooLarge = errors.New("input object was too large. limit is 512kbytes")

ErrObjectTooLarge is returned when too much data was read from stdin. current limit 512k

View Source
var ErrUnknownObjectEnc = errors.New("unknown object encoding")

ErrUnknownObjectEnc is returned if a invalid encoding is supplied

View Source
var LogCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "Change the logging level",
		ShortDescription: `
'ipfs log' is a utility command used to change the logging
output of a running daemon.
`,
	},

	Arguments: []cmds.Argument{

		cmds.StringArg("subsystem", true, false, fmt.Sprintf("the subsystem logging identifier. Use '%s' for all subsystems.", logAllKeyword)),
		cmds.StringArg("level", true, false, "one of: debug, info, notice, warning, error, critical"),
	},
	Run: func(req cmds.Request) (interface{}, error) {

		args := req.Arguments()
		subsystem, level := args[0], args[1]

		if subsystem == logAllKeyword {
			subsystem = "*"
		}

		if err := u.SetLogLevel(subsystem, level); err != nil {
			return nil, err
		}

		s := fmt.Sprintf("Changed log level of '%s' to '%s'", subsystem, level)
		log.Info(s)
		return &MessageOutput{s}, nil
	},
	Marshalers: cmds.MarshalerMap{
		cmds.Text: MessageTextMarshaler,
	},
	Type: &MessageOutput{},
}
View Source
var Root = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline: "global p2p merkle-dag filesystem",
		Synopsis: `
ipfs [<flags>] <command> [<arg>] ...
`,
		ShortDescription: `
Basic commands:

    init          Initialize ipfs local configurationx
    add <path>    Add an object to ipfs
    cat <ref>     Show ipfs object data
    ls <ref>      List links from an object

Tool commands:

    config        Manage configuration
    update        Download and apply go-ipfs updates
    version       Show ipfs version information
    commands      List all available commands
    id            Show info about ipfs peers

Advanced Commands:

    daemon        Start a long-running daemon process
    mount         Mount an ipfs read-only mountpoint
    serve         Serve an interface to ipfs
    diag          Print diagnostics

Plumbing commands:

    block         Interact with raw blocks in the datastore
    object        Interact with raw dag nodes

Use 'ipfs <command> --help' to learn more about each command.
`,
	},
	Options: []cmds.Option{
		cmds.StringOption("config", "c", "Path to the configuration file to use"),
		cmds.BoolOption("debug", "D", "Operate in debug mode"),
		cmds.BoolOption("help", "Show the full command help text"),
		cmds.BoolOption("h", "Show a short version of the command help text"),
		cmds.BoolOption("local", "L", "Run the command locally, instead of using the daemon"),
	},
}
View Source
var UpdateCheckCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline:          "Checks if updates are available",
		ShortDescription: "'ipfs update check' checks if any updates are available for IPFS.\nNothing will be downloaded or installed.",
	},

	Run: func(req cmds.Request) (interface{}, error) {
		n, err := req.Context().GetNode()
		if err != nil {
			return nil, err
		}
		return updateCheck(n)
	},
	Type: &UpdateOutput{},
	Marshalers: cmds.MarshalerMap{
		cmds.Text: func(res cmds.Response) ([]byte, error) {
			v := res.Output().(*UpdateOutput)
			s := ""
			if v.NewVersion != v.OldVersion {
				s = fmt.Sprintf("A new version of IPFS is available ('%s', currently running '%s')\n",
					v.NewVersion, v.OldVersion)
			} else {
				s = fmt.Sprintf("Already updated to latest version ('%s')\n", v.NewVersion)
			}
			return []byte(s), nil
		},
	},
}
View Source
var UpdateCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline:          "Downloads and installs updates for IPFS",
		ShortDescription: "ipfs update is a utility command used to check for updates and apply them.",
	},

	Run: func(req cmds.Request) (interface{}, error) {
		n, err := req.Context().GetNode()
		if err != nil {
			return nil, err
		}
		return updateApply(n)
	},
	Type: &UpdateOutput{},
	Subcommands: map[string]*cmds.Command{
		"check": UpdateCheckCmd,
		"log":   UpdateLogCmd,
	},
	Marshalers: cmds.MarshalerMap{
		cmds.Text: func(res cmds.Response) ([]byte, error) {
			v := res.Output().(*UpdateOutput)
			s := ""
			if v.NewVersion != v.OldVersion {
				s = fmt.Sprintf("Successfully updated to IPFS version '%s' (from '%s')\n",
					v.NewVersion, v.OldVersion)
			} else {
				s = fmt.Sprintf("Already updated to latest version ('%s')\n", v.NewVersion)
			}
			return []byte(s), nil
		},
	},
}
View Source
var UpdateLogCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline:          "List the changelog for the latest versions of IPFS",
		ShortDescription: "This command is not yet implemented.",
	},

	Run: func(req cmds.Request) (interface{}, error) {
		n, err := req.Context().GetNode()
		if err != nil {
			return nil, err
		}
		return updateLog(n)
	},
}
View Source
var VersionCmd = &cmds.Command{
	Helptext: cmds.HelpText{
		Tagline:          "Shows ipfs version information",
		ShortDescription: "Returns the current version of ipfs and exits.",
	},

	Options: []cmds.Option{
		cmds.BoolOption("number", "n", "Only show the version number"),
	},
	Run: func(req cmds.Request) (interface{}, error) {
		return &VersionOutput{
			Version: config.CurrentVersionNumber,
		}, nil
	},
	Marshalers: cmds.MarshalerMap{
		cmds.Text: func(res cmds.Response) ([]byte, error) {
			v := res.Output().(*VersionOutput)

			number, found, err := res.Request().Option("number").Bool()
			if err != nil {
				return nil, err
			}
			if found && number {
				return []byte(fmt.Sprintln(v.Version)), nil
			}
			return []byte(fmt.Sprintf("ipfs version %s\n", v.Version)), nil
		},
	},
	Type: &VersionOutput{},
}

Functions

func CommandsCmd

func CommandsCmd(root *cmds.Command) *cmds.Command

CommandsCmd takes in a root command, and returns a command that lists the subcommands in that root

func KeyListTextMarshaler

func KeyListTextMarshaler(res cmds.Response) ([]byte, error)

KeyListTextMarshaler outputs a KeyList as plaintext, one key per line

func MessageTextMarshaler

func MessageTextMarshaler(res cmds.Response) ([]byte, error)

func Mount

func Mount(node *core.IpfsNode, fsdir, nsdir string) error

Types

type AddOutput

type AddOutput struct {
	Objects []*Object
	Names   []string
}

type Block

type Block struct {
	Key    string
	Length int
}

type BootstrapOutput

type BootstrapOutput struct {
	Peers []*config.BootstrapPeer
}

type Command

type Command struct {
	Name        string
	Subcommands []Command
}

type ConfigField

type ConfigField struct {
	Key   string
	Value interface{}
}

type DiagnosticConnection

type DiagnosticConnection struct {
	ID string
	// TODO use milliseconds or microseconds for human readability
	NanosecondsLatency uint64
}

type DiagnosticOutput

type DiagnosticOutput struct {
	Peers []DiagnosticPeer
}

type DiagnosticPeer

type DiagnosticPeer struct {
	ID                string
	UptimeSeconds     uint64
	BandwidthBytesIn  uint64
	BandwidthBytesOut uint64
	Connections       []DiagnosticConnection
}

type IdOutput

type IdOutput struct {
	ID              string
	PublicKey       string
	Addresses       []string
	AgentVersion    string
	ProtocolVersion string
}

type IpnsEntry

type IpnsEntry struct {
	Name  string
	Value string
}

type KeyList

type KeyList struct {
	Keys []u.Key
}

KeyList is a general type for outputting lists of keys

type Link struct {
	Name, Hash string
	Size       uint64
}

type LsOutput

type LsOutput struct {
	Objects []Object
}

type MessageOutput

type MessageOutput struct {
	Message string
}

type Node

type Node struct {
	Links []Link
	Data  []byte
}

type Object

type Object struct {
	Hash  string
	Links []Link
}

type TestOutput

type TestOutput struct {
	Foo string
	Bar int
}

type UpdateOutput

type UpdateOutput struct {
	OldVersion string
	NewVersion string
}

type VersionOutput

type VersionOutput struct {
	Version string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL