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

Improve CLI Text by Adding Verbose Text for Commands #68

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
39 changes: 27 additions & 12 deletions cmd/iceberg/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,21 @@ import (
const usage = `iceberg.

Usage:
iceberg list [options] [PARENT]
iceberg describe [options] [namespace | table] IDENTIFIER
iceberg (schema | spec | uuid | location) [options] TABLE_ID
iceberg drop [options] (namespace | table) IDENTIFIER
iceberg files [options] TABLE_ID [--history]
iceberg rename [options] <from> <to>
iceberg properties [options] get (namespace | table) IDENTIFIER [PROPNAME]
iceberg properties [options] set (namespace | table) IDENTIFIER PROPNAME VALUE
iceberg properties [options] remove (namespace | table) IDENTIFIER PROPNAME
iceberg -h | --help | --version
iceberg [command] [options] [arguments]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this actually work? The library being used docopt actually uses the usage string to perform the parsing and processing. [options] is a special handle thing for docopt, but i don't think that [command] and [arguments] is. So i think this might break the CLI here

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zeroshade Apologies, this slipped through my radar. I don't think that this is breaking the CLI:

~/Software/iceberg-go/cmd/iceberg (improve-cli-help-text*) » ./iceberg --help                                                                                                                             ramasai@Ramasais-MacBook-Air
iceberg.

Usage:
  iceberg [command] [options] [arguments]
  iceberg -h | --help
  iceberg --version

Commands:
  describe    Describe a namespace or a table.
  list        List tables or namespaces.
  schema      Get the schema of the table.
  spec        Return the partition spec of the table.
  uuid        Return the UUID of the table.
  location    Return the location of the table.
  drop        Operations to drop a namespace or table.
  files       List all the files of the table.
  rename      Rename a table.
  properties  Properties on tables/namespaces.

Arguments:
  PARENT         Catalog parent namespace
  IDENTIFIER     fully qualified namespace or table
  TABLE_ID       full path to a table
  PROPNAME       name of a property
  VALUE          value to set

Options:
  --catalog TEXT     specify the catalog type [default: rest]
  --uri TEXT         specify the catalog URI
  --output TYPE      output type (json/text) [default: text]
  --credential TEXT  specify credentials for the catalog
  --warehouse TEXT   specify the warehouse to use

Example Usages
  iceberg list [options] [PARENT]
  iceberg describe [options] [namespace | table] IDENTIFIER
  iceberg (schema | spec | uuid | location) [options] TABLE_ID
  iceberg drop [options] (namespace | table) IDENTIFIER
  iceberg files [options] TABLE_ID [--history]
  iceberg rename [options] <from> <to>
  iceberg properties [options] get (namespace | table) IDENTIFIER [PROPNAME]
  iceberg properties [options] set (namespace | table) IDENTIFIER PROPNAME VALUE
  iceberg properties [options] remove (namespace | table) IDENTIFIER PROPNAME

I tested this before putting up the PR -- unless I am misunderstanding what you mean?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's for the help, did you confirm that it works just fine for the regular usages of calling list/describe/files/etc.? it's just a usage for docopt i hadnt seen before

iceberg -h | --help
iceberg --version

Commands:
describe Describe a namespace or a table.
list List tables or namespaces.
schema Get the schema of the table.
spec Return the partition spec of the table.
uuid Return the UUID of the table.
location Return the location of the table.
drop Operations to drop a namespace or table.
files List all the files of the table.
rename Rename a table.
properties Properties on tables/namespaces.

Arguments:
PARENT Catalog parent namespace
Expand All @@ -53,12 +58,22 @@ Arguments:
VALUE value to set

Options:
-h --help show this helpe messages and exit
--catalog TEXT specify the catalog type [default: rest]
--uri TEXT specify the catalog URI
--output TYPE output type (json/text) [default: text]
--credential TEXT specify credentials for the catalog
--warehouse TEXT specify the warehouse to use`
--warehouse TEXT specify the warehouse to use

Example Usages
iceberg list [options] [PARENT]
iceberg describe [options] [namespace | table] IDENTIFIER
iceberg (schema | spec | uuid | location) [options] TABLE_ID
iceberg drop [options] (namespace | table) IDENTIFIER
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Kept the existing set of usages because this line for example has iceberg command [options] namespace and then an argument -- the namespace part isn't fully captured in the iceberg command [options] [arguments] format. Thought it'd be better to just leave these as examples.

iceberg files [options] TABLE_ID [--history]
iceberg rename [options] <from> <to>
iceberg properties [options] get (namespace | table) IDENTIFIER [PROPNAME]
iceberg properties [options] set (namespace | table) IDENTIFIER PROPNAME VALUE
iceberg properties [options] remove (namespace | table) IDENTIFIER PROPNAME`

func main() {
args, err := docopt.ParseArgs(usage, os.Args[1:], iceberg.Version())
Expand Down
Loading