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

Abstract the tools framework to allow merging multiple CLI tools together #1471

Closed
wants to merge 1 commit into from

Conversation

sijie
Copy link
Member

@sijie sijie commented Jun 4, 2018

Descriptions of the changes in this PR:

Motivation

There are multiple CLI tools spreading across multiple places, e.g. new bookkeeper cli, stream storage cli and dlog. There have similar implementations. It would be better to consolidate all these tools in one place bookkeeper-tools.

This is a PR to prepare moving stream/cli to be part of bookkeeper-tools.

Solution

  • Abstract the CLI logic in bookkeeper-tools into a simple tools framework that can be reused in a extensible way to unify multiple tools together.
  • organize the tools module into tools/framework and tools/all

Result

Example output of the tool using this framework is listed as below:

$ bin/bkctl
bkctl interacts and operates Apache BookKeeper clusters

Usage:  bkctl [flags] [command group] [commands]

Commands:

    bookie          Commands on operating a single bookie
    bookies         Commands on operating a cluster of bookies
    cluster         Commands on administrating bookkeeper clusters
    ledger          Commands on interacting with ledgers
    namespace       Commands on operating namespaces
    table           Commands on interacting with tables
    tables          Commands on operating tables

    help            Display help information about it

Flags:

    -c, --conf
        Configuration file

    -n, --namespace
        Namespace scope to run commands (only valid for table service for now)

    -u, --service-uri
        Service Uri


    -h, --help
        Display help information

Use "bkctl [command] --help" or "bkctl help [command]" for more information
about a command

result from help sub-command

$ bin/bkctl help table
Commands on interacting with tables

Usage:  bkctl table [command] [command options]

Commands:

    get         Get key/value pair from a table
    inc         Increment the amount of a key in a table
    put         Put key/value pair to a table

    help        Display help information about it

Use "bkctl table [command] --help" or "bkctl table help [command]" for more
information about a command

result from help sub-sub-command

$ bin/bkctl table help inc
Increment the amount of a key in a table

Usage:  bkctl table inc [flags] <table> <key> <amount>

Flags:


    -h, --help
        Display help information

Master Issue: #1000

*Motivation*

There are multiple CLI tools spreading across multiple places, e.g. new bookkeeper cli, stream storage cli and dlog.
There have similar implementations. It would be better to consolidate all these tools in one place `bookkeeper-tools`

*Solution*

- Abstract the CLI logic in new bookkeeper CLI into a simple tools framework to unify multiple tools together.
- organize the tools module into tools/framework and tools/all
@sijie
Copy link
Member Author

sijie commented Jun 4, 2018

retest this please

2 similar comments
@sijie
Copy link
Member Author

sijie commented Jun 4, 2018

retest this please

@sijie
Copy link
Member Author

sijie commented Jun 4, 2018

retest this please

@sijie sijie self-assigned this Jun 4, 2018
@sijie sijie closed this in 8792531 Jun 4, 2018
sijie added a commit that referenced this pull request Jun 5, 2018
Descriptions of the changes in this PR:

*Motivation*

#1471  introduces a new tools framework based on jcommander. This PR is changing the new bookkeeper-tools to leverage that framework.

*Solution*

- Changed the related classes to use the new framework.
- Rename `BookKeeperCLI` to `BKCtl` and `bookkeeper-cli` to `bkctl`
- Use service loader to load command groups to allow better extensibility
- Rename command group `cluster` to `bookies`

*Results*

Example output of this change:

```
$ bin/bkctl
bkctl interacts and operates Apache BookKeeper clusters

Usage:  bkctl [flags] [command group] [commands]

Commands:

    bookie      Commands on operating a single bookie
    bookies     Commands on operating a cluster of bookies
    ledger      Commands on interacting with ledgers

    help        Display help information about it

Flags:

    -c, --conf
        Configuration file

    -u, --service-uri
        Service Uri

    -h, --help
        Display help information

Use "bkctl [command] --help" or "bkctl help [command]" for more information
about a command
```

*sub command*
```
$ bin/bkctl help bookie
Commands on operating a single bookie

Usage:  bkctl bookie [command] [command options]

Commands:

    lastmark        Print last log marker

    help            Display help information about it

Use "bkctl bookie [command] --help" or "bkctl bookie help [command]" for more
information about a command
```

*sub-sub command*

```
$ bin/bkctl bookie help lastmark
Print last log marker

Usage:  bkctl bookie lastmark [flags]

Flags:

    -h, --help
        Display help information
```

Author: Sijie Guo <sijie@apache.org>

Reviewers: Jia Zhai <None>

This closes #1478 from sijie/bkctl_tools
@sijie sijie deleted the tools_framework branch July 16, 2018 02:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants