Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 优化命令行提示及使用 / Optimize existing command line prompts and use #5136

Merged
merged 6 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions cmd/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@ import (

var chainCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Inspect the filecoin blockchain",
Tagline: "Interact with filecoin blockchain",
},
Subcommands: map[string]*cmds.Command{
"head": chainHeadCmd,
"ls": chainLsCmd,
"set-head": chainSetHeadCmd,
"getblock": chainGetBlockCmd,
"get-message": chainGetMessageCmd,
"get-messages": chainGetMessagesCmd,
"get-receipts": chainGetReceiptsCmd,
"disputer": chainDisputeSetCmd,
"export": chainExportCmd,
"head": chainHeadCmd,
"ls": chainLsCmd,
"set-head": chainSetHeadCmd,
"get-block": chainGetBlockCmd,
"get-message": chainGetMessageCmd,
"get-block-messages": chainGetBlockMessagesCmd,
"get-receipts": chainGetReceiptsCmd,
"disputer": chainDisputeSetCmd,
"export": chainExportCmd,
},
}

Expand Down Expand Up @@ -258,7 +258,7 @@ var chainGetMessageCmd = &cmds.Command{
Type: types.Message{},
}

var chainGetMessagesCmd = &cmds.Command{
var chainGetBlockMessagesCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Show a filecoin message collection by block CID",
ShortDescription: "Prints info for all messages in a collection, at the given block CID.",
Expand Down
20 changes: 5 additions & 15 deletions cmd/drand.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,18 @@ package cmd

import (
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/venus/app/node"
cmds "github.com/ipfs/go-ipfs-cmds"

"github.com/filecoin-project/venus/app/node"
)

var drandCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Explore access and configure drand.",
ShortDescription: ``,
},

Subcommands: map[string]*cmds.Command{
"random": drandRandom,
},
}

var drandRandom = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Retrieve randomness round from drand group",
Tagline: "Retrieve randomness from drand server",
},
Options: []cmds.Option{
cmds.Uint64Option("round", "retrieve randomness at given round (default 0)"),
cmds.Uint64Option("round", "retrieve randomness at height round (default 0)"),
cmds.Uint64Option("height", "chain epoch (default 0)"),
cmds.Uint64Option("round", "retrieve randomness at requested round (default 0)"),
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
round, _ := req.Options["round"].(uint64)
Expand Down
54 changes: 29 additions & 25 deletions cmd/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package cmd
import (
"github.com/filecoin-project/venus/app/node"
"github.com/filecoin-project/venus/pkg/config"
"github.com/filecoin-project/venus/venus-shared/types"
cmds "github.com/ipfs/go-ipfs-cmds"
)

var inspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Show info about the filecoin node",
Tagline: "Show info about the venus node",
},
Subcommands: map[string]*cmds.Command{
"all": allInspectCmd,
Expand All @@ -17,14 +18,13 @@ var inspectCmd = &cmds.Command{
"memory": memoryInspectCmd,
"config": configInspectCmd,
"environment": envInspectCmd,
"protocol": protocolInspectCmd,
},
}
var allInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print all diagnostic information.",
ShortDescription: `
Prints out information about filecoin process and its environment.
`,
Tagline: "Print all diagnostic information.",
ShortDescription: "Prints out information about filecoin process and its environment.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
var allInfo node.AllInspectorInfo
Expand All @@ -51,10 +51,8 @@ Prints out information about filecoin process and its environment.

var runtimeInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print runtime diagnostic information.",
ShortDescription: `
Prints out information about the golang runtime.
`,
Tagline: "Print runtime diagnostic information.",
ShortDescription: "Prints out information about the golang runtime.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Runtime()
Expand All @@ -65,10 +63,8 @@ Prints out information about the golang runtime.

var diskInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print filesystem usage information.",
ShortDescription: `
Prints out information about the filesystem.
`,
Tagline: "Print filesystem usage information.",
ShortDescription: "Prints out information about the filesystem.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out, err := env.(*node.Env).InspectorAPI.Disk()
Expand All @@ -82,10 +78,8 @@ Prints out information about the filesystem.

var memoryInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print memory usage information.",
ShortDescription: `
Prints out information about memory usage.
`,
Tagline: "Print memory usage information.",
ShortDescription: "Prints out information about memory usage.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out, err := env.(*node.Env).InspectorAPI.Memory()
Expand All @@ -99,10 +93,8 @@ Prints out information about memory usage.

var configInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print in-memory config information.",
ShortDescription: `
Prints out information about your filecoin nodes config.
`,
Tagline: "Print in-memory config information.",
ShortDescription: "Prints out information about your filecoin nodes config.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Config()
Expand All @@ -113,14 +105,26 @@ Prints out information about your filecoin nodes config.

var envInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Print filecoin environment information.",
ShortDescription: `
Prints out information about your filecoin nodes environment.
`,
Tagline: "Print filecoin environment information.",
ShortDescription: "Prints out information about your filecoin nodes environment.",
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
out := env.(*node.Env).InspectorAPI.Environment()
return cmds.EmitOnce(res, out)
},
Type: node.EnvironmentInfo{},
}

var protocolInspectCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "Show protocol parameter details",
},
Run: func(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment) error {
params, err := env.(*node.Env).ChainAPI.ProtocolParameters(req.Context)
if err != nil {
return err
}
return re.Emit(params)
},
Type: types.ProtocolParams{},
}
54 changes: 0 additions & 54 deletions cmd/leb128.go

This file was deleted.

55 changes: 0 additions & 55 deletions cmd/leb128_test.go

This file was deleted.

46 changes: 20 additions & 26 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,11 @@ func init() {
// command object for the local cli
var RootCmd = &cmds.Command{
Helptext: cmds.HelpText{
Tagline: "A decentralized storage network",
Tagline: "Filecoin decentralized storage network client",
Subcommands: `
START RUNNING FILECOIN
config <key> [<value>] - Get and set filecoin config values
daemon - Start a long-running daemon process
wallet - Manage your filecoin wallets
START RUNNING VENUS
daemon - Start a venus daemon process
wallet - Manage wallet
msig - Interact with a multisig wallet

VIEW DATA STRUCTURES
Expand All @@ -109,7 +108,7 @@ VIEW DATA STRUCTURES

NETWORK COMMANDS
swarm - Interact with the swarm
drand - retrieve drand randomness
drand - Retrieve randomness from drand server

MESSAGE COMMANDS
send - Send message
Expand Down Expand Up @@ -138,9 +137,7 @@ Cid COMMANDS

TOOL COMMANDS
inspect - Show info about the venus node
leb128 - Leb128 cli encode/decode
log - Interact with the daemon event log output
protocol - Show protocol parameter details
version - Show venus version information
seed - Seal sectors for genesis miner
fetch - Fetch proving parameters
Expand All @@ -167,30 +164,27 @@ var rootSubcmdsLocal = map[string]*cmds.Command{
"daemon": daemonCmd,
"fetch": fetchCmd,
"version": versionCmd,
"leb128": leb128Cmd,
"seed": seedCmd,
"cid": cidCmd,
}

// all top level commands, available on daemon. set during init() to avoid configuration loops.
var rootSubcmdsDaemon = map[string]*cmds.Command{
"chain": chainCmd,
"sync": syncCmd,
"drand": drandCmd,
"inspect": inspectCmd,
"leb128": leb128Cmd,
"log": logCmd,
"send": msgSendCmd,
"mpool": mpoolCmd,
"protocol": protocolCmd,
"show": showCmd,
"swarm": swarmCmd,
"wallet": walletCmd,
"version": versionCmd,
"state": stateCmd,
"miner": minerCmd,
"paych": paychCmd,
"msig": multisigCmd,
"chain": chainCmd,
"sync": syncCmd,
"drand": drandCmd,
"inspect": inspectCmd,
"log": logCmd,
"send": msgSendCmd,
"mpool": mpoolCmd,
"show": showCmd,
"swarm": swarmCmd,
"wallet": walletCmd,
"version": versionCmd,
"state": stateCmd,
"miner": minerCmd,
"paych": paychCmd,
"msig": multisigCmd,
}

func init() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func TestRequiresDaemon(t *testing.T) {
assert.NoError(t, err)
assert.False(t, requiresDaemon(reqWithoutDaemon))

reqSubcmdDaemon, err := cmds.NewRequest(context.Background(), []string{"leb128", "decode"}, nil, []string{"A=="}, nil, RootCmd)
reqSubcmdDaemon, err := cmds.NewRequest(context.Background(), []string{"version"}, nil, []string{}, nil, RootCmd)
assert.NoError(t, err)
assert.False(t, requiresDaemon(reqSubcmdDaemon))
}
Loading