master
go 174 lines 5.63 KB
Raw
1 package commands
2
3 import (
4 "errors"
5
6 cmdenv "github.com/ipfs/kubo/core/commands/cmdenv"
7 dag "github.com/ipfs/kubo/core/commands/dag"
8 name "github.com/ipfs/kubo/core/commands/name"
9 ocmd "github.com/ipfs/kubo/core/commands/object"
10 "github.com/ipfs/kubo/core/commands/pin"
11
12 cmds "github.com/ipfs/go-ipfs-cmds"
13 logging "github.com/ipfs/go-log/v2"
14 )
15
16 var log = logging.Logger("core/commands")
17
18 var (
19 ErrNotOnline = errors.New("this command must be run in online mode. Try running 'ipfs daemon' first")
20 ErrSelfUnsupported = errors.New("finding your own node in the DHT is currently not supported")
21 )
22
23 const (
24 RepoDirOption = "repo-dir"
25 ConfigFileOption = "config-file"
26 ConfigOption = "config"
27 DebugOption = "debug"
28 LocalOption = "local" // DEPRECATED: use OfflineOption
29 OfflineOption = "offline"
30 ApiOption = "api" //nolint
31 ApiAuthOption = "api-auth" //nolint
32 )
33
34 var Root = &cmds.Command{
35 Helptext: cmds.HelpText{
36 Tagline: "Global p2p merkle-dag filesystem.",
37 Synopsis: "ipfs [--config=<config> | -c] [--debug | -D] [--help] [-h] [--api=<api>] [--offline] [--cid-base=<base>] [--upgrade-cidv0-in-output] [--encoding=<encoding> | --enc] [--timeout=<timeout>] <command> ...",
38 Subcommands: `
39 BASIC COMMANDS
40 init Initialize local IPFS configuration
41 add <path> Add a file to IPFS
42 cat <ref> Show IPFS object data
43 get <ref> Download IPFS objects
44 ls <ref> List links from an object
45 refs <ref> List hashes of links from an object
46
47 DATA STRUCTURE COMMANDS
48 dag Interact with IPLD DAG nodes
49 files Interact with files as if they were a unix filesystem
50 block Interact with raw blocks in the datastore
51
52 TEXT ENCODING COMMANDS
53 cid Convert and discover properties of CIDs
54 multibase Encode and decode data with Multibase format
55
56 ADVANCED COMMANDS
57 daemon Start a long-running daemon process
58 shutdown Shut down the daemon process
59 resolve Resolve any type of content path
60 name Publish and resolve IPNS names
61 key Create and list IPNS name keypairs
62 pin Pin objects to local storage
63 repo Manipulate the IPFS repository
64 stats Various operational stats
65 p2p Libp2p stream mounting (experimental)
66 filestore Manage the filestore (experimental)
67 mount Mount an IPFS read-only mount point (experimental)
68 provide Control providing operations
69
70 NETWORK COMMANDS
71 id Show info about IPFS peers
72 bootstrap Add or remove bootstrap peers
73 swarm Manage connections to the p2p network
74 dht Query the DHT for values or peers
75 routing Issue routing commands
76 ping Measure the latency of a connection
77 bitswap Inspect bitswap state
78 pubsub Send and receive messages via pubsub
79
80 TOOL COMMANDS
81 config Manage configuration
82 version Show IPFS version information
83 diag Generate diagnostic reports
84 update Update Kubo to a different version
85 commands List all available commands
86 log Manage and show logs of running daemon
87
88 Use 'ipfs <command> --help' to learn more about each command.
89
90 ipfs uses a repository in the local file system. By default, the repo is
91 located at ~/.ipfs. To change the repo location, set the $IPFS_PATH
92 environment variable:
93
94 export IPFS_PATH=/path/to/ipfsrepo
95
96 EXIT STATUS
97
98 The CLI will exit with one of the following values:
99
100 0 Successful execution.
101 1 Failed executions.
102 `,
103 },
104 Options: []cmds.Option{
105 cmds.StringOption(RepoDirOption, "Path to the repository directory to use."),
106 cmds.StringOption(ConfigFileOption, "Path to the configuration file to use."),
107 cmds.StringOption(ConfigOption, "c", "[DEPRECATED] Path to the configuration file to use."),
108 cmds.BoolOption(DebugOption, "D", "Operate in debug mode."),
109 cmds.BoolOption(cmds.OptLongHelp, "Show the full command help text."),
110 cmds.BoolOption(cmds.OptShortHelp, "Show a short version of the command help text."),
111 cmds.BoolOption(LocalOption, "L", "Run the command locally, instead of using the daemon. DEPRECATED: use --offline."),
112 cmds.BoolOption(OfflineOption, "Run the command offline."),
113 cmds.StringOption(ApiOption, "Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001)"),
114 cmds.StringOption(ApiAuthOption, "Optional RPC API authorization secret (defined as AuthSecret in API.Authorizations config)"),
115
116 // global options, added to every command
117 cmdenv.OptionCidBase,
118 cmdenv.OptionUpgradeCidV0InOutput,
119
120 cmds.OptionEncodingType,
121 cmds.OptionStreamChannels,
122 cmds.OptionTimeout,
123 },
124 }
125
126 var CommandsDaemonCmd = CommandsCmd(Root)
127
128 var rootSubcommands = map[string]*cmds.Command{
129 "add": AddCmd,
130 "bitswap": BitswapCmd,
131 "block": BlockCmd,
132 "cat": CatCmd,
133 "commands": CommandsDaemonCmd,
134 "files": FilesCmd,
135 "filestore": FileStoreCmd,
136 "get": GetCmd,
137 "provide": ProvideCmd,
138 "pubsub": PubsubCmd,
139 "repo": RepoCmd,
140 "stats": StatsCmd,
141 "bootstrap": BootstrapCmd,
142 "config": ConfigCmd,
143 "dag": dag.DagCmd,
144 "dht": DhtCmd,
145 "routing": RoutingCmd,
146 "diag": DiagCmd,
147 "id": IDCmd,
148 "key": KeyCmd,
149 "log": LogCmd,
150 "ls": LsCmd,
151 "mount": MountCmd,
152 "name": name.NameCmd,
153 "object": ocmd.ObjectCmd,
154 "pin": pin.PinCmd,
155 "ping": PingCmd,
156 "p2p": P2PCmd,
157 "refs": RefsCmd,
158 "resolve": ResolveCmd,
159 "swarm": SwarmCmd,
160 "update": UpdateCmd,
161 "version": VersionCmd,
162 "shutdown": daemonShutdownCmd,
163 "cid": CidCmd,
164 "multibase": MbaseCmd,
165 }
166
167 func init() {
168 Root.ProcessHelp()
169 Root.Subcommands = rootSubcommands
170 }
171
172 type MessageOutput struct {
173 Message string
174 }