dropshell release 2025.0518.1451
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled
This commit is contained in:
@ -50,33 +50,33 @@ int main(int argc, char* argv[]) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const CommandInfo* info = CommandRegistry::instance().find_command(ctx.command);
|
||||
if (!info) {
|
||||
std::cerr << "Unknown command: " << ctx.command << std::endl;
|
||||
const CommandInfo* cmdinfo = CommandRegistry::instance().find_command(ctx.command);
|
||||
if (!cmdinfo) {
|
||||
error << "Unknown command: " << ctx.command << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (info->requires_config && !gConfig().is_config_set()) {
|
||||
std::cerr << "Valid dropshell configuration required for command: " << ctx.command << std::endl;
|
||||
std::cerr << "Please run 'dropshell edit' to set up the dropshell configuration." << std::endl;
|
||||
if (cmdinfo->requires_config && !gConfig().is_config_set()) {
|
||||
error << "Valid dropshell configuration required for command: " << ctx.command << std::endl;
|
||||
info << "Please run 'dropshell edit' to set up the dropshell configuration." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
if (info->requires_install && !gConfig().is_agent_installed()) {
|
||||
std::cerr << "Dropshell agent not installed for command: " << ctx.command << std::endl;
|
||||
std::cerr << "Please run 'dropshell install' to install the local dropshell agent." << std::endl;
|
||||
if (cmdinfo->requires_install && !gConfig().is_agent_installed()) {
|
||||
error << "Dropshell agent not installed for command: " << ctx.command << std::endl;
|
||||
info << "Please run 'dropshell install' to install the local dropshell agent." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int arg_count = ctx.args.size();
|
||||
if (arg_count < info->min_args || (info->max_args != -1 && arg_count > info->max_args)) {
|
||||
std::cerr << "Invalid number of arguments for command: " << ctx.command << std::endl;
|
||||
std::cerr << "(" << ctx.args.size() << " args provided, " << ctx.command << " requires " << (info->min_args) << " to " << (info->max_args) << " args)" << std::endl;
|
||||
std::cerr << "Usage: " << std::endl;
|
||||
std::cerr << " ";
|
||||
print_left_aligned(info->help_usage,30);
|
||||
std::cout << info->help_description << std::endl;
|
||||
if (arg_count < cmdinfo->min_args || (cmdinfo->max_args != -1 && arg_count > cmdinfo->max_args)) {
|
||||
error << "Invalid number of arguments for command: " << ctx.command << std::endl;
|
||||
debug << "(" << ctx.args.size() << " args provided, " << ctx.command << " requires " << (cmdinfo->min_args) << " to " << (cmdinfo->max_args) << " args)" << std::endl;
|
||||
info << "Usage: " << std::endl;
|
||||
info << " ";
|
||||
info << left_align(cmdinfo->help_usage,30);
|
||||
info << cmdinfo->help_description << std::endl;
|
||||
return 1;
|
||||
}
|
||||
return info->handler(ctx);
|
||||
return cmdinfo->handler(ctx);
|
||||
|
||||
}
|
||||
catch (const std::exception& e) {
|
||||
@ -116,13 +116,6 @@ bool getCLIServices(const std::string & arg2, const std::string & arg3,
|
||||
return true;
|
||||
}
|
||||
|
||||
void printversion() {
|
||||
maketitle("DropShell version " + VERSION);
|
||||
std::cout << "Release date: " << RELEASE_DATE << std::endl;
|
||||
std::cout << "Author: " << AUTHOR << std::endl;
|
||||
std::cout << "License: " << LICENSE << std::endl;
|
||||
}
|
||||
|
||||
auto command_match = [](const std::string& cmd_list, int argc, char* argv[]) -> bool {
|
||||
std::istringstream iss(cmd_list);
|
||||
std::string cmd_item;
|
||||
|
Reference in New Issue
Block a user