dropshell release 2025.0521.1906
Some checks failed
Dropshell Test / Build_and_Test (push) Has been cancelled

This commit is contained in:
Your Name
2025-05-21 19:06:50 +12:00
parent 1b16741288
commit 7a710b525f
6 changed files with 78 additions and 10 deletions

View File

@ -55,6 +55,11 @@ void help_autocomplete(const CommandContext& ctx) {
}
void show_command(const std::string& cmd) {
// get console width
int width = get_console_width() - 6; // 5 for [INF] + 1 for space
int firstcol = 34;
int secondcol = width - firstcol - 3;
const auto& cmd_info = CommandRegistry::instance().find_command(cmd);
if (!cmd_info)
{
@ -62,9 +67,22 @@ void show_command(const std::string& cmd) {
return;
}
info << " ";
info << left_align(cmd_info->help_usage, 32);
info << cmd_info->help_description << std::endl;
if (cmd_info->help_usage.length() < width-secondcol)
{
std::string remaining_description = cmd_info->help_description;
info << " " << left_align(cmd_info->help_usage, firstcol) << get_line_wrap(remaining_description, secondcol);
while (!remaining_description.empty())
info << " " << left_align(" ",firstcol) << get_line_wrap(remaining_description, secondcol-1);
}
else
{
info << " " << cmd_info->help_usage << std::endl;
std::string remaining_description = cmd_info->help_description;
info << " " << left_align(" ",firstcol) << get_line_wrap(remaining_description, secondcol);
while (!remaining_description.empty())
info << " " << left_align(" ",firstcol) << get_line_wrap(remaining_description, secondcol-1);
}
}
extern const std::string VERSION;
@ -106,7 +124,7 @@ int help_handler(const CommandContext& ctx) {
if (ctx.args.size() > 0)
return show_command_help(ctx.args[0]);
info << std::endl;
std::cout << std::endl;
maketitle("DropShell version " + VERSION);
info << std::endl;
info << "A tool for managing remote servers, by " << AUTHOR << std::endl;
@ -120,16 +138,17 @@ int help_handler(const CommandContext& ctx) {
{
// show more!
show_command("list");
std::cout << std::endl;
info << std::endl;
show_command("install");
show_command("uninstall");
show_command("nuke");
std::cout << std::endl;
info << std::endl;
show_command("start");
show_command("stop");
std::cout << std::endl;
info << std::endl;
show_command("ssh");
std::cout << std::endl;
info << std::endl;
show_command("create-service");
}
return 0;
}