Formatting of help text
This commit is contained in:
parent
c2eb854e5a
commit
3d3a706784
|
@ -313,7 +313,9 @@ class Command(BaseModel):
|
|||
if not self.arg_parser:
|
||||
return "No arguments defined."
|
||||
|
||||
return self.arg_parser.get_usage(plain_text=True)
|
||||
command_keys_text = self.arg_parser.get_command_keys_text(plain_text=True)
|
||||
options_text = self.arg_parser.get_options_text(plain_text=True)
|
||||
return f" {command_keys_text:<20} {options_text} "
|
||||
|
||||
def log_summary(self) -> None:
|
||||
if self._context:
|
||||
|
|
|
@ -830,6 +830,7 @@ class Falyx:
|
|||
self.console.print(
|
||||
f"[{OneColors.LIGHT_YELLOW}]⚠️ Unknown command '{choice}'[/]"
|
||||
)
|
||||
else:
|
||||
raise ValidationError(
|
||||
message=f"Unknown command '{choice}'.",
|
||||
cursor_position=len(raw_choices),
|
||||
|
@ -1149,9 +1150,23 @@ class Falyx:
|
|||
f"[{OneColors.CYAN_b}]🚀 Running all commands with tag:[/] "
|
||||
f"{self.cli_args.tag}"
|
||||
)
|
||||
|
||||
for cmd in matching:
|
||||
self._set_retry_policy(cmd)
|
||||
try:
|
||||
await self.run_key(cmd.key)
|
||||
except FalyxError as error:
|
||||
self.console.print(f"[{OneColors.DARK_RED}]❌ Error: {error}[/]")
|
||||
sys.exit(1)
|
||||
except QuitSignal:
|
||||
logger.info("[QuitSignal]. <- Exiting run.")
|
||||
sys.exit(0)
|
||||
except BackSignal:
|
||||
logger.info("[BackSignal]. <- Exiting run.")
|
||||
sys.exit(0)
|
||||
except CancelSignal:
|
||||
logger.info("[CancelSignal]. <- Exiting run.")
|
||||
sys.exit(0)
|
||||
|
||||
if self.cli_args.summary:
|
||||
er.summary()
|
||||
|
|
|
@ -88,22 +88,21 @@ def get_arg_parsers(
|
|||
parser.add_argument("--version", action="store_true", help="Show Falyx version")
|
||||
subparsers = parser.add_subparsers(dest="command")
|
||||
|
||||
run_description = "Run a command by its key or alias."
|
||||
run_epilog = ["commands:"]
|
||||
run_description = ["Run a command by its key or alias.\n"]
|
||||
run_description.append("commands:")
|
||||
if isinstance(commands, dict):
|
||||
for command in commands.values():
|
||||
run_epilog.append(command.usage)
|
||||
run_description.append(command.usage)
|
||||
command_description = command.description or command.help_text
|
||||
run_epilog.append(f" {command_description}")
|
||||
run_epilog.append(" ")
|
||||
run_epilog.append(
|
||||
run_description.append(f"{' '*24}{command_description}")
|
||||
run_epilog = (
|
||||
"Tip: Use 'falyx run ?[COMMAND]' to preview commands by their key or alias."
|
||||
)
|
||||
run_parser = subparsers.add_parser(
|
||||
"run",
|
||||
help="Run a specific command",
|
||||
description=run_description,
|
||||
epilog="\n".join(run_epilog),
|
||||
description="\n".join(run_description),
|
||||
epilog=run_epilog,
|
||||
formatter_class=RawDescriptionHelpFormatter,
|
||||
)
|
||||
run_parser.add_argument("name", help="Run a command by its key or alias")
|
||||
|
|
|
@ -1 +1 @@
|
|||
__version__ = "0.1.41"
|
||||
__version__ = "0.1.42"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
[tool.poetry]
|
||||
name = "falyx"
|
||||
version = "0.1.41"
|
||||
version = "0.1.42"
|
||||
description = "Reliable and introspectable async CLI action framework."
|
||||
authors = ["Roland Thomas Jr <roland@rtj.dev>"]
|
||||
license = "MIT"
|
||||
|
|
Loading…
Reference in New Issue