mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
commands: deprecate --local for --offline
License: MIT Signed-off-by: Łukasz Magiera <magik6k@gmail.com>
This commit is contained in:
parent
47a46393cf
commit
2dceb09258
@ -40,7 +40,7 @@ const (
|
||||
ipnsMountKwd = "mount-ipns"
|
||||
migrateKwd = "migrate"
|
||||
mountKwd = "mount"
|
||||
offlineKwd = "offline"
|
||||
offlineKwd = "offline" // global option
|
||||
routingOptionKwd = "routing"
|
||||
routingOptionSupernodeKwd = "supernode"
|
||||
routingOptionDHTClientKwd = "dhtclient"
|
||||
@ -161,7 +161,6 @@ Headers.
|
||||
cmdkit.BoolOption(unencryptTransportKwd, "Disable transport encryption (for debugging protocols)"),
|
||||
cmdkit.BoolOption(enableGCKwd, "Enable automatic periodic repo garbage collection"),
|
||||
cmdkit.BoolOption(adjustFDLimitKwd, "Check and raise file descriptor limits if needed").WithDefault(true),
|
||||
cmdkit.BoolOption(offlineKwd, "Run offline. Do not connect to the rest of the network but provide local API."),
|
||||
cmdkit.BoolOption(migrateKwd, "If true, assume yes at the migrate prompt. If false, assume no."),
|
||||
cmdkit.BoolOption(enablePubSubKwd, "Instantiate the ipfs daemon with the experimental pubsub feature enabled."),
|
||||
cmdkit.BoolOption(enableIPNSPubSubKwd, "Enable IPNS record distribution through pubsub; enables pubsub."),
|
||||
|
||||
@ -2,6 +2,7 @@ package cmdenv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/ipfs/go-ipfs/commands"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
@ -10,8 +11,11 @@ import (
|
||||
|
||||
config "gx/ipfs/QmYyzmMnhNTtoXx5ttgUaRdHHckYnQWjPL98hgLAR2QLDD/go-ipfs-config"
|
||||
cmds "gx/ipfs/QmaAP56JAwdjwisPTu4yx17whcjTr6y5JCSCF77Y1rahWV/go-ipfs-cmds"
|
||||
logging "gx/ipfs/QmcuXC5cxs79ro2cUuHs4HQ2bkDLJUYokwL8aivcX6HW3C/go-log"
|
||||
)
|
||||
|
||||
var log = logging.Logger("core/commands/cmdenv")
|
||||
|
||||
// GetNode extracts the node from the environment.
|
||||
func GetNode(env interface{}) (*core.IpfsNode, error) {
|
||||
ctx, ok := env.(*commands.Context)
|
||||
@ -29,13 +33,19 @@ func GetApi(env cmds.Environment, req *cmds.Request) (coreiface.CoreAPI, error)
|
||||
return nil, fmt.Errorf("expected env to be of type %T, got %T", ctx, env)
|
||||
}
|
||||
|
||||
local, _ := req.Options["local"].(bool)
|
||||
offline, _ := req.Options["offline"].(bool)
|
||||
if !offline {
|
||||
offline, _ = req.Options["local"].(bool)
|
||||
if offline {
|
||||
log.Errorf("Command '%s', --local is deprecated, use --offline instead", strings.Join(req.Path, " "))
|
||||
}
|
||||
}
|
||||
api, err := ctx.GetAPI()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if local {
|
||||
return api.WithOptions(options.Api.Offline(local))
|
||||
if offline {
|
||||
return api.WithOptions(options.Api.Offline(offline))
|
||||
}
|
||||
|
||||
return api, nil
|
||||
|
||||
@ -18,10 +18,11 @@ var log = logging.Logger("core/commands")
|
||||
var ErrNotOnline = errors.New("this command must be run in online mode. Try running 'ipfs daemon' first")
|
||||
|
||||
const (
|
||||
ConfigOption = "config"
|
||||
DebugOption = "debug"
|
||||
LocalOption = "local"
|
||||
ApiOption = "api"
|
||||
ConfigOption = "config"
|
||||
DebugOption = "debug"
|
||||
LocalOption = "local" // DEPRECATED: use OfflineOption
|
||||
OfflineOption = "offline"
|
||||
ApiOption = "api"
|
||||
)
|
||||
|
||||
var Root = &cmds.Command{
|
||||
@ -92,7 +93,8 @@ The CLI will exit with one of the following values:
|
||||
cmdkit.BoolOption(DebugOption, "D", "Operate in debug mode."),
|
||||
cmdkit.BoolOption(cmds.OptLongHelp, "Show the full command help text."),
|
||||
cmdkit.BoolOption(cmds.OptShortHelp, "Show a short version of the command help text."),
|
||||
cmdkit.BoolOption(LocalOption, "L", "Run the command locally, instead of using the daemon."),
|
||||
cmdkit.BoolOption(LocalOption, "L", "Run the command locally, instead of using the daemon. DEPRECATED: use --offline."),
|
||||
cmdkit.BoolOption(OfflineOption, "O", "Run the command offline."),
|
||||
cmdkit.StringOption(ApiOption, "Use a specific API instance (defaults to /ip4/127.0.0.1/tcp/5001)"),
|
||||
|
||||
// global options, added to every command
|
||||
|
||||
Loading…
Reference in New Issue
Block a user