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 CLAP/CLI #47

Merged
merged 12 commits into from
Jan 19, 2020
197 changes: 84 additions & 113 deletions src/cli.yml
Original file line number Diff line number Diff line change
@@ -1,117 +1,88 @@
name: Lucid
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
subcommands:
-
cli:
about: 'Spawn to the command line interface'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
-
help:
help: 'Prints CLI help information'
short: h
long: help
-
init:
about: 'Initialize Lucid and generate configuration file'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
-
secret:
help: 'Set the JWT secret'
short: s
long: secret
- cli:
about: "Spawn to the command line interface"
args:
- help:
help: "Prints CLI help information"
short: h
long: help
- init:
about: "Initialize Lucid and generate configuration file"
args:
- secret:
help: "Set the JWT secret"
short: s
long: secret
takes_value: true
- force:
help: "Initialize Lucid and overwrite existing configuration file"
short: f
long: force
takes_value: false
- config:
help: "Specify the Lucid configuration file location"
short: c
long: config
takes_value: true
- server:
about: "Run a new Lucid server instance"
args:
- config:
help: "Specify the Lucid configuration file"
short: c
long: config
takes_value: true
- settings:
about: "Manage Lucid configuration file"
subcommands:
- set:
about: "Update a setting parameter"
- get:
about: "Get a setting parameter"
args:
- config:
help: "Specify the Lucid configuration file"
short: c
long: config
takes_value: true
- store:
about: "Play with the KV store (get/set)"
- tokens:
about: "Manage JWT Tokens (issue, revoke etc.)"
subcommands:
- revoke:
about: "Revoke a JWT Token"
args:
- token:
help: "Token to revoke"
index: 1
- issue:
about: "Issue a new JWT Token"
args:
- expiration:
help: "Specify the expiration date of the JWT Token (timestamp)"
short: e
long: expiration
takes_value: true
-
force:
help: 'Initialize Lucid and overwrite existing configuration file'
short: f
long: force
takes_value: false
-
config:
help: 'Specify the Lucid configuration file location'
- count:
help: "Number of tokens to issue "
short: c
long: config
takes_value: true
-
server:
about: 'Run a new Lucid server instance'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
-
config:
help: 'Specify the Lucid configuration file'
short: c
long: config
takes_value: true
-
settings:
about: 'Manage Lucid configuration file'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
subcommands:
- set:
about: 'Update a setting parameter'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
- get:
about: 'Get a setting parameter'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
- config:
help: 'Specify the Lucid configuration file'
short: c
long: config
takes_value: true
-
store:
about: 'Play with the KV store (get/set)'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
-
tokens:
about: 'Manage JWT Tokens (issue, revoke etc.)'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
subcommands:
-
revoke:
about: 'Revoke a JWT Token'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
-
token:
help: 'Token to revoke'
index: 1
-
issue:
about: 'Issue a new JWT Token'
author: 'Written in Rust by Clint.Network (twitter.com/clint_network)'
args:
-
expiration:
help: 'Specify the expiration date of the JWT Token (timestamp)'
short: e
long: expiration
takes_value: true
- count:
help: 'Number of tokens to issue '
short: c
long: count
index: 1
args:
- config:
help: 'Specify the Lucid configuration file'
short: c
long: config
takes_value: true
long: count
index: 1
args:
- config:
help: "Specify the Lucid configuration file"
short: c
long: config
takes_value: true
args:
-
help:
help: 'Prints help information'
short: h
long: help
takes_value: false
-
version:
help: 'Prints version information'
short: v
long: version
takes_value: false
- help:
help: "Prints help information"
short: h
long: help
takes_value: false
- version:
help: "Prints version information"
short: v
long: version
takes_value: false
7 changes: 4 additions & 3 deletions src/lucid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ impl Lucid {
██║ ██║ ██║██║ ██║██║ ██║ ██╔═██╗ ╚██╗ ██╔╝
██████╗╚██████╔╝╚██████╗██║██████╔╝ ██║ ██╗ ╚████╔╝
╚═════╝ ╚═════╝ ╚═════╝╚═╝╚═════╝ ╚═╝ ╚═╝ ╚═══╝
"###);

A Fast, Secure and Distributed KV store with an HTTP API.
Written in Rust by Clint.Network (twitter.com/clint_network)"###);
}

fn show_version(&self) {
Expand All @@ -59,8 +61,7 @@ impl Lucid {

pub fn initialize(&mut self) -> Result<(), std::io::Error> {
let cli_yaml = load_yaml!("cli.yml");
let mut commands = App::from_yaml(cli_yaml)
.name(crate_description!());
let mut commands = App::from_yaml(cli_yaml);
self.show_banner();
match self.handle_cli(&mut commands) {
Some(usage) => println!("{}{}", usage, match usage.to_owned().contains("USAGE") {
Expand Down