mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-06 08:20:57 +08:00

- cleaned up cmd help - ipfs name publish [<name>] <ref> - ipfs name resolve [<name>] - publish validates <ref> - both validate n args
36 lines
563 B
Go
36 lines
563 B
Go
package commands
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
"io"
|
|
|
|
"github.com/jbenet/go-ipfs/core"
|
|
)
|
|
|
|
func Resolve(n *core.IpfsNode, args []string, opts map[string]interface{}, out io.Writer) error {
|
|
|
|
name := ""
|
|
|
|
switch len(args) {
|
|
case 1:
|
|
name = args[0]
|
|
case 0:
|
|
if n.Identity == nil {
|
|
return errors.New("Identity not loaded!")
|
|
}
|
|
name = n.Identity.ID.String()
|
|
|
|
default:
|
|
return fmt.Errorf("Publish expects 1 or 2 args; got %d.", len(args))
|
|
}
|
|
|
|
res, err := n.Namesys.Resolve(name)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
fmt.Fprintf(out, "%s\n", res)
|
|
return nil
|
|
}
|