Skip to content

Commit

Permalink
CLI: amend 'ais archive get' help, add inline examples
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Aizman <[email protected]>
  • Loading branch information
alex-aizman committed Aug 14, 2023
1 parent 3d9545b commit 3a0b5b4
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
15 changes: 13 additions & 2 deletions cmd/cli/cli/arch_hdlr.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,19 @@ var (

// archive get
archGetCmd = cli.Command{
Name: objectCmdGet.Name,
Usage: objectCmdGet.Usage,
Name: objectCmdGet.Name,
// NOTE: compare with objectCmdGet.Usage
Usage: "get a shard and extract its content; get an archived file;\n" +
indent4 + "\twrite the content locally with destination options including: filename, directory, STDOUT ('-'), or '/dev/null' (discard);\n" +
indent4 + "\tassorted options further include:\n" +
indent4 + "\t- '--prefix' to get multiple shards in one shot (empty prefix for the entire bucket);\n" +
indent4 + "\t- '--progress' and '--refresh' to watch progress bar;\n" +
indent4 + "\t- '-v' to produce verbose output when getting multiple objects.\n" +
indent1 + "Examples:\n" +
indent4 + "\t- ais archive get ais://abc/trunk-0123.tar.lz4 /tmp/outi - extract entire shard to /tmp/out/trunk...\n" +
indent4 + "\t- ais archive get ais://abc/trunk-0123.tar.lz4/file456 /tmp/out - extract one named file\n" +
indent4 + "\t- ais archive get ais://abc/trunk-0123.tar.lz4 --archpath file456 /tmp/out - same as above\n" +
indent4 + "\t- ais archive get ais://abc/trunk-0123.tar.lz4/file456 /tmp/out/file456.new - same as above w/ rename",
ArgsUsage: getShardArgument,
Flags: rmFlags(objectCmdGet.Flags, checkObjCachedFlag, lengthFlag, offsetFlag),
Action: getArchHandler,
Expand Down
9 changes: 4 additions & 5 deletions cmd/cli/cli/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,11 @@ func getHandler(c *cli.Context) error {
archpath = parseStrFlag(c, archpathGetFlag)
}
if actionIsHandler(c.Command.Action, getArchHandler) {
if flagIsSet(c, extractFlag) {
return fmt.Errorf("'ais archive get': flag %s is redundant (implied)", qflprn(extractFlag))
}
extract = true
extract = true // extractFlag is implied unless:

if oname, fname := splitObjnameShardBoundary(objName); fname != "" {
if archpath != "" {
extract = false
} else if oname, fname := splitObjnameShardBoundary(objName); fname != "" {
objName = oname
archpath = fname
extract = false
Expand Down

0 comments on commit 3a0b5b4

Please sign in to comment.