style (cli): Clean up 'key-code' cmd
* Rename 'key-code' -> 'key' (better grammar for the sub cmds) * Rename 'key-gen' -> 'gen' Now the 'key' cmds are 'sparkd key gen/encrypt/decrypt'
This commit is contained in:
1 parent
978a1e8566
commit
fd3de056c1
3 files changed
+26
-26
No files matched your search
@@ -1,4 +1,4 @@
|
||||
#include "KeyCode.h"
|
||||
#include "KeyCmd.h"
|
||||
|
||||
#include "lib/config/config.h"
|
||||
#include "lib/config/protos/keycode.pb.h"
|
||||
@@ -192,40 +192,40 @@ static void key_gen(const KeyGenArgs &args) {
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
struct KeyCode::Args {
|
||||
struct KeyCmd::Args {
|
||||
EncryptArgs encrypt;
|
||||
DecryptArgs decrypt;
|
||||
KeyGenArgs key_gen;
|
||||
};
|
||||
|
||||
KeyCode::KeyCode()
|
||||
: CLI::App("Manage keycodes", "key-code"), _args(new KeyCode::Args()) {
|
||||
KeyCmd::KeyCmd()
|
||||
: CLI::App("Manage keycodes", "key"), args_(new KeyCmd::Args()) {
|
||||
// check ips
|
||||
add_subcommand("check-ips")->callback(check_ips);
|
||||
|
||||
// decrypt
|
||||
auto *decrypt_cmd = add_subcommand("decrypt");
|
||||
decrypt_cmd->add_option("--key-file", _args->decrypt.keyfile)->required();
|
||||
decrypt_cmd->add_option("--source", _args->decrypt.source);
|
||||
decrypt_cmd->callback([&] { decrypt(_args->decrypt); });
|
||||
decrypt_cmd->add_option("--key-file", args_->decrypt.keyfile)->required();
|
||||
decrypt_cmd->add_option("--source", args_->decrypt.source);
|
||||
decrypt_cmd->callback([&] { decrypt(args_->decrypt); });
|
||||
|
||||
// encrypt
|
||||
auto *encrypt_cmd = add_subcommand("encrypt");
|
||||
encrypt_cmd->add_flag("--allow-concurrent", _args->encrypt.allow_concurrent);
|
||||
encrypt_cmd->add_option("--expiration", _args->encrypt.expiration);
|
||||
encrypt_cmd->add_option("--ip", _args->encrypt.ip);
|
||||
encrypt_cmd->add_option("--key-file", _args->encrypt.keyfile)->required();
|
||||
encrypt_cmd->add_option("--pass", _args->encrypt.pass);
|
||||
encrypt_cmd->add_option("--port", _args->encrypt.port);
|
||||
encrypt_cmd->add_option("--users", _args->encrypt.users);
|
||||
encrypt_cmd->callback([&] { encrypt(_args->encrypt); });
|
||||
encrypt_cmd->add_flag("--allow-concurrent", args_->encrypt.allow_concurrent);
|
||||
encrypt_cmd->add_option("--expiration", args_->encrypt.expiration);
|
||||
encrypt_cmd->add_option("--ip", args_->encrypt.ip);
|
||||
encrypt_cmd->add_option("--key-file", args_->encrypt.keyfile)->required();
|
||||
encrypt_cmd->add_option("--pass", args_->encrypt.pass);
|
||||
encrypt_cmd->add_option("--port", args_->encrypt.port);
|
||||
encrypt_cmd->add_option("--users", args_->encrypt.users);
|
||||
encrypt_cmd->callback([&] { encrypt(args_->encrypt); });
|
||||
|
||||
// key-gen
|
||||
auto *keygen_cmd = add_subcommand("key-gen");
|
||||
keygen_cmd->add_option("--out", _args->key_gen.out_path_prefix)->required();
|
||||
keygen_cmd->callback([&] { key_gen(_args->key_gen); });
|
||||
// gen
|
||||
auto *gen_cmd = add_subcommand("gen");
|
||||
gen_cmd->add_option("--out", args_->key_gen.out_path_prefix)->required();
|
||||
gen_cmd->callback([&] { key_gen(args_->key_gen); });
|
||||
}
|
||||
|
||||
KeyCode::~KeyCode() {}
|
||||
KeyCmd::~KeyCmd() {}
|
||||
|
||||
} // namespace bts::cmds
|
||||
@@ -17,13 +17,13 @@ class KeyCode;
|
||||
|
||||
namespace bts::cmds {
|
||||
|
||||
struct KeyCode : public CLI::App {
|
||||
KeyCode();
|
||||
~KeyCode();
|
||||
struct KeyCmd : public CLI::App {
|
||||
KeyCmd();
|
||||
~KeyCmd();
|
||||
|
||||
private:
|
||||
struct Args;
|
||||
std::unique_ptr<Args> _args;
|
||||
std::unique_ptr<Args> args_;
|
||||
};
|
||||
|
||||
} // namespace bts::cmds
|
||||
@@ -3,7 +3,7 @@
|
||||
#include "server/sparkd/cmds/AdminReport.h"
|
||||
#include "server/sparkd/cmds/Benchmark.h"
|
||||
#include "server/sparkd/cmds/ConfigCmd.h"
|
||||
#include "server/sparkd/cmds/KeyCode.h"
|
||||
#include "server/sparkd/cmds/KeyCmd.h"
|
||||
#include "server/sparkd/cmds/Md.h"
|
||||
#include "server/sparkd/cmds/QuickTest.h"
|
||||
#include "server/sparkd/cmds/Run.h"
|
||||
@@ -32,7 +32,7 @@ int main(int argc, char **argv) {
|
||||
app.add_subcommand(CLI::App_p(new cmds::QuickTest()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Run()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Spartan()));
|
||||
app.add_subcommand((CLI::App_p(new cmds::KeyCode())));
|
||||
app.add_subcommand(CLI::App_p(new cmds::KeyCmd()));
|
||||
app.add_subcommand(CLI::App_p(new cmds::Web()));
|
||||
app.add_subcommand(
|
||||
"test", "Run unit test(s)"); // so this shows up in help
|
||||
|
||||
Reference in new issue
Block a user