retrieval: Don't use subcommands

This commit is contained in:
Łukasz Magiera 2021-11-16 12:40:25 +01:00
parent 597b72e286
commit 53a48df77e
3 changed files with 61 additions and 42 deletions

View File

@ -93,6 +93,8 @@ var clientCmd = &cli.Command{
WithCategory("data", clientStat), WithCategory("data", clientStat),
WithCategory("retrieval", clientFindCmd), WithCategory("retrieval", clientFindCmd),
WithCategory("retrieval", clientRetrieveCmd), WithCategory("retrieval", clientRetrieveCmd),
WithCategory("retrieval", clientRetrieveCatCmd),
WithCategory("retrieval", clientRetrieveLsCmd),
WithCategory("retrieval", clientCancelRetrievalDealCmd), WithCategory("retrieval", clientCancelRetrievalDealCmd),
WithCategory("retrieval", clientListRetrievalsCmd), WithCategory("retrieval", clientListRetrievalsCmd),
WithCategory("util", clientCommPCmd), WithCategory("util", clientCommPCmd),

View File

@ -200,31 +200,15 @@ func retrieve(ctx context.Context, cctx *cli.Context, fapi lapi.FullNode, sel *l
return eref, nil return eref, nil
} }
var clientRetrieveCmd = &cli.Command{ var retrFlagsCommon = []cli.Flag{
Name: "retrieve",
Subcommands: []*cli.Command{
clientRetrieveCatCmd,
clientRetrieveLsCmd,
},
Usage: "Retrieve data from network",
ArgsUsage: "[dataCid outputPath]",
Flags: []cli.Flag{
&cli.StringFlag{ &cli.StringFlag{
Name: "from", Name: "from",
Usage: "address to send transactions from", Usage: "address to send transactions from",
}, },
&cli.BoolFlag{
Name: "car",
Usage: "export to a car file instead of a regular file",
},
&cli.StringFlag{ &cli.StringFlag{
Name: "miner", Name: "miner",
Usage: "miner address for retrieval, if not present it'll use local discovery", Usage: "miner address for retrieval, if not present it'll use local discovery",
}, },
&cli.StringFlag{
Name: "datamodel-path-selector",
Usage: "a rudimentary (DM-level-only) text-path selector, allowing for sub-selection within a deal",
},
&cli.StringFlag{ &cli.StringFlag{
Name: "maxPrice", Name: "maxPrice",
Usage: fmt.Sprintf("maximum price the client is willing to consider (default: %s FIL)", DefaultMaxRetrievePrice), Usage: fmt.Sprintf("maximum price the client is willing to consider (default: %s FIL)", DefaultMaxRetrievePrice),
@ -235,8 +219,24 @@ var clientRetrieveCmd = &cli.Command{
}, },
&cli.BoolFlag{ &cli.BoolFlag{
Name: "allow-local", Name: "allow-local",
// todo: default to true?
}, },
}
var clientRetrieveCmd = &cli.Command{
Name: "retrieve",
Usage: "Retrieve data from network",
ArgsUsage: "[dataCid outputPath]",
Flags: append([]cli.Flag{
&cli.BoolFlag{
Name: "car",
Usage: "export to a car file instead of a regular file",
}, },
&cli.StringFlag{
Name: "datamodel-path-selector",
Usage: "a rudimentary (DM-level-only) text-path selector, allowing for sub-selection within a deal",
},
}, retrFlagsCommon...),
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 2 { if cctx.NArg() != 2 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
@ -329,6 +329,7 @@ var clientRetrieveCatCmd = &cli.Command{
Name: "cat", Name: "cat",
Usage: "Show data from network", Usage: "Show data from network",
ArgsUsage: "[dataCid]", ArgsUsage: "[dataCid]",
Flags: retrFlagsCommon,
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))
@ -372,6 +373,7 @@ var clientRetrieveLsCmd = &cli.Command{
Name: "ls", Name: "ls",
Usage: "Show object links", Usage: "Show object links",
ArgsUsage: "[dataCid]", ArgsUsage: "[dataCid]",
Flags: retrFlagsCommon,
Action: func(cctx *cli.Context) error { Action: func(cctx *cli.Context) error {
if cctx.NArg() != 1 { if cctx.NArg() != 1 {
return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments")) return ShowHelp(cctx, fmt.Errorf("incorrect number of arguments"))

View File

@ -426,6 +426,8 @@ COMMANDS:
RETRIEVAL: RETRIEVAL:
find Find data in the network find Find data in the network
retrieve Retrieve data from network retrieve Retrieve data from network
cat Show data from network
ls Show object links
cancel-retrieval Cancel a retrieval deal by deal ID; this also cancels the associated transfer cancel-retrieval Cancel a retrieval deal by deal ID; this also cancels the associated transfer
list-retrievals List retrieval market deals list-retrievals List retrieval market deals
STORAGE: STORAGE:
@ -539,48 +541,61 @@ NAME:
lotus client retrieve - Retrieve data from network lotus client retrieve - Retrieve data from network
USAGE: USAGE:
lotus client retrieve command [command options] [dataCid outputPath] lotus client retrieve [command options] [dataCid outputPath]
COMMANDS: CATEGORY:
cat Show data from network RETRIEVAL
ls Show object links
help, h Shows a list of commands or help for one command
OPTIONS: OPTIONS:
--from value address to send transactions from
--car export to a car file instead of a regular file (default: false) --car export to a car file instead of a regular file (default: false)
--miner value miner address for retrieval, if not present it'll use local discovery
--datamodel-path-selector value a rudimentary (DM-level-only) text-path selector, allowing for sub-selection within a deal --datamodel-path-selector value a rudimentary (DM-level-only) text-path selector, allowing for sub-selection within a deal
--from value address to send transactions from
--miner value miner address for retrieval, if not present it'll use local discovery
--maxPrice value maximum price the client is willing to consider (default: 0.01 FIL) --maxPrice value maximum price the client is willing to consider (default: 0.01 FIL)
--pieceCid value require data to be retrieved from a specific Piece CID --pieceCid value require data to be retrieved from a specific Piece CID
--allow-local (default: false) --allow-local (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
--version, -v print the version (default: false)
``` ```
#### lotus client retrieve cat ### lotus client cat
``` ```
NAME: NAME:
lotus client retrieve cat - Show data from network lotus client cat - Show data from network
USAGE: USAGE:
lotus client retrieve cat [command options] [dataCid] lotus client cat [command options] [dataCid]
CATEGORY:
RETRIEVAL
OPTIONS: OPTIONS:
--from value address to send transactions from
--miner value miner address for retrieval, if not present it'll use local discovery
--maxPrice value maximum price the client is willing to consider (default: 0.01 FIL)
--pieceCid value require data to be retrieved from a specific Piece CID
--allow-local (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
``` ```
#### lotus client retrieve ls ### lotus client ls
``` ```
NAME: NAME:
lotus client retrieve ls - Show object links lotus client ls - Show object links
USAGE: USAGE:
lotus client retrieve ls [command options] [dataCid] lotus client ls [command options] [dataCid]
CATEGORY:
RETRIEVAL
OPTIONS: OPTIONS:
--from value address to send transactions from
--miner value miner address for retrieval, if not present it'll use local discovery
--maxPrice value maximum price the client is willing to consider (default: 0.01 FIL)
--pieceCid value require data to be retrieved from a specific Piece CID
--allow-local (default: false)
--help, -h show help (default: false) --help, -h show help (default: false)
``` ```