mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-03 02:56:09 +08:00

ipfs-shell [1] accesses the Command objects directly to construct requests for an external IPFS daemon API. This isn't a terribly robust approach, because it doesn't handle version differences between the version of go-ipfs used to build the daemon and the version used to build the ipfs-shell-consuming application. But for cases where you can get those APIs to match it works well. Making these two commands public allows us to write ipfs-shell wrappers for them. Until we figure out how to get ipfs-shell working without access to core/commands, I think the best approach is to make future command objects and their returned structures public, and to go back and expose existing commands/structures on an as-needed basis. In this case, I need the public PublishCmd for the Docker-registry storage driver, and I made the IpnsCmd public at the same time to stay consistent for both 'ipfs name ...' sub-commands. [1]: https://github.com/whyrusleeping/ipfs-shell License: MIT Signed-off-by: W. Trevor King <wking@tremily.us>
58 lines
1.7 KiB
Go
58 lines
1.7 KiB
Go
package commands
|
|
|
|
import cmds "github.com/ipfs/go-ipfs/commands"
|
|
|
|
type IpnsEntry struct {
|
|
Name string
|
|
Value string
|
|
}
|
|
|
|
var NameCmd = &cmds.Command{
|
|
Helptext: cmds.HelpText{
|
|
Tagline: "IPFS namespace (IPNS) tool",
|
|
Synopsis: `
|
|
ipfs name publish [<name>] <ipfs-path> - Publish an object to IPNS
|
|
ipfs name resolve [<name>] - Gets the value currently published at an IPNS name
|
|
`,
|
|
ShortDescription: `
|
|
IPNS is a PKI namespace, where names are the hashes of public keys, and
|
|
the private key enables publishing new (signed) values. In both publish
|
|
and resolve, the default value of <name> is your own identity public key.
|
|
`,
|
|
LongDescription: `
|
|
IPNS is a PKI namespace, where names are the hashes of public keys, and
|
|
the private key enables publishing new (signed) values. In both publish
|
|
and resolve, the default value of <name> is your own identity public key.
|
|
|
|
|
|
Examples:
|
|
|
|
Publish an <ipfs-path> to your identity name:
|
|
|
|
> ipfs name publish /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
|
|
Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
|
|
|
|
Publish an <ipfs-path> to another public key:
|
|
|
|
> ipfs name publish /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n
|
|
Published to QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n: /ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
|
|
|
|
Resolve the value of your identity:
|
|
|
|
> ipfs name resolve
|
|
/ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
|
|
|
|
Resolve the value of another name:
|
|
|
|
> ipfs name resolve QmbCMUZw6JFeZ7Wp9jkzbye3Fzp2GGcPgC3nmeUjfVF87n
|
|
/ipfs/QmatmE9msSfkKxoffpHwNLNKgwZG8eT9Bud6YoPab52vpy
|
|
|
|
`,
|
|
},
|
|
|
|
Subcommands: map[string]*cmds.Command{
|
|
"publish": PublishCmd,
|
|
"resolve": IpnsCmd,
|
|
},
|
|
}
|