1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

Merge pull request #2109 from drouhana/cli-refactor

CLI Fixes
This commit is contained in:
Jason Rhinelander 2023-01-10 15:51:00 -04:00 committed by GitHub
commit d1b6ccfbc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 9 deletions

View file

@ -108,11 +108,11 @@ main(int argc, char* argv[])
command_line_options options{};
// flags: boolean values in command_line_options struct
cli.add_flag("v,--verbose", options.verbose, "Verbose");
cli.add_flag("-v,--verbose", options.verbose, "Verbose");
cli.add_flag("--up", options.vpnUp, "Put VPN up");
cli.add_flag("--down", options.vpnDown, "Put VPN down");
cli.add_flag("--status", options.printStatus, "Print VPN status and exit");
cli.add_flag("k,--kill", options.killDaemon, "Kill lokinet daemon");
cli.add_flag("-k,--kill", options.killDaemon, "Kill lokinet daemon");
// options: string values in command_line_options struct
cli.add_option("--exit", options.exitAddress, "Specify exit node address")->capture_default_str();
@ -156,9 +156,9 @@ main(int argc, char* argv[])
case 0:
return exit_error(3, "One of --up/--down/--status/--kill must be specified");
case 1:
return exit_error(3, "Only one of --up/--down/--status/--kill may be specified");
default:
break;
default:
return exit_error(3, "Only one of --up/--down/--status/--kill may be specified");
}
if (options.vpnUp and options.exitAddress.empty())

View file

@ -33,11 +33,13 @@ namespace
bool version = false;
bool generate = false;
bool router = false;
bool force = false;
bool config = false;
bool configOnly = false;
bool overwrite = false;
// string options
// TODO: change this to use a std::filesystem::path once we stop using ghc::filesystem on some
// platforms
std::string configPath;
// windows options
@ -369,10 +371,10 @@ namespace
// flags: boolean values in command_line_options struct
cli.add_flag("--version", options.version, "Lokinet version");
cli.add_flag("g,--generate", options.generate, "Generate default configuration and exit");
cli.add_flag("-g,--generate", options.generate, "Generate default configuration and exit");
cli.add_flag(
"r,--router", options.router, "Run lokinet in routing mode instead of client-only mode");
cli.add_flag("f,--force", options.force, "Force writing config even if file exists");
"-r,--router", options.router, "Run lokinet in routing mode instead of client-only mode");
cli.add_flag("-f,--force", options.overwrite, "Force writing config even if file exists");
// options: string
cli.add_option("--config", options.configPath, "Path to lokinet.ini configuration file")
@ -417,7 +419,12 @@ namespace
}
}
if (options.configOnly)
if (options.generate)
{
options.configOnly = true;
}
if (not options.configPath.empty())
{
configFile = options.configPath;
}