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

fix and document console-aliases.txt, following points are not includ… #44402

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
[Part2] Prelaude of the following points:
-alias --help gives no info.
-alias not listed in help
  • Loading branch information
Chu3laMan committed Nov 23, 2024
commit c262042d3c8372892115f698da961cc6f3337b63
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,22 @@ public CommandResult execute(CommandInvocation commandInvocation) throws Command
return CommandResult.SUCCESS;
}
}

@CommandDefinition(name = "alias", description = "Display alias usage", aliases = { "a" })
public static class AliasCommand implements Command {

@Override
public CommandResult execute(CommandInvocation commandInvocation) throws CommandException, InterruptedException {
commandInvocation.getShell().writeln("The following commands are available for alias:\n");
commandInvocation.getShell().writeln("Usage: alias [name[=value] ... ]\n");
commandInvocation.getShell().writeln("Commands:");
commandInvocation.getShell().writeln(" alias List all aliases");
commandInvocation.getShell().writeln(" alias name Show the command for 'name' alias");
commandInvocation.getShell().writeln(" alias name=value Create/update an alias");
commandInvocation.getShell().writeln(" alias name='value' Create/update an alias with spaces");
commandInvocation.getShell().writeln(" alias --help Show this help message\n");

return CommandResult.SUCCESS;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.logging.Level;
import java.util.stream.Collectors;

import org.aesh.terminal.utils.Config;
import org.jboss.logging.Logger;
import org.jboss.logmanager.LogManager;

Expand Down Expand Up @@ -168,9 +169,23 @@ public void accept(String args) {
}));
}
commands.add(new ConsoleCommand('q', "Quit the application", null, this::exitQuarkus));
commands.add(new ConsoleCommand('a', "Alias usage", null, this::aliasUsage));
context.reset(commands.toArray(new ConsoleCommand[0]));
}

private String aliasUsage() {
StringBuilder help = new StringBuilder();
help.append("Usage: alias [name[=value] ... ]").append(Config.getLineSeparator());
help.append("Options:").append(Config.getLineSeparator());
help.append(" --help Show this help message").append(Config.getLineSeparator());
help.append("Examples:").append(Config.getLineSeparator());
help.append(" alias List all aliases").append(Config.getLineSeparator());
help.append(" alias name Show the command for 'name' alias").append(Config.getLineSeparator());
help.append(" alias name=value Create/update an alias").append(Config.getLineSeparator());
help.append(" alias name='value' Create/update an alias with spaces").append(Config.getLineSeparator());
return help.toString();
}

private void forceRestart() {
RuntimeUpdatesProcessor.INSTANCE.doScan(true, true);
}
Expand Down