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:
|
if not self.arg_parser:
|
||||||
return "No arguments defined."
|
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:
|
def log_summary(self) -> None:
|
||||||
if self._context:
|
if self._context:
|
||||||
|
|
|
@ -830,10 +830,11 @@ class Falyx:
|
||||||
self.console.print(
|
self.console.print(
|
||||||
f"[{OneColors.LIGHT_YELLOW}]⚠️ Unknown command '{choice}'[/]"
|
f"[{OneColors.LIGHT_YELLOW}]⚠️ Unknown command '{choice}'[/]"
|
||||||
)
|
)
|
||||||
raise ValidationError(
|
else:
|
||||||
message=f"Unknown command '{choice}'.",
|
raise ValidationError(
|
||||||
cursor_position=len(raw_choices),
|
message=f"Unknown command '{choice}'.",
|
||||||
)
|
cursor_position=len(raw_choices),
|
||||||
|
)
|
||||||
return is_preview, None, args, kwargs
|
return is_preview, None, args, kwargs
|
||||||
|
|
||||||
def _create_context(self, selected_command: Command) -> ExecutionContext:
|
def _create_context(self, selected_command: Command) -> ExecutionContext:
|
||||||
|
@ -1149,9 +1150,23 @@ class Falyx:
|
||||||
f"[{OneColors.CYAN_b}]🚀 Running all commands with tag:[/] "
|
f"[{OneColors.CYAN_b}]🚀 Running all commands with tag:[/] "
|
||||||
f"{self.cli_args.tag}"
|
f"{self.cli_args.tag}"
|
||||||
)
|
)
|
||||||
|
|
||||||
for cmd in matching:
|
for cmd in matching:
|
||||||
self._set_retry_policy(cmd)
|
self._set_retry_policy(cmd)
|
||||||
await self.run_key(cmd.key)
|
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:
|
if self.cli_args.summary:
|
||||||
er.summary()
|
er.summary()
|
||||||
|
|
|
@ -88,22 +88,21 @@ def get_arg_parsers(
|
||||||
parser.add_argument("--version", action="store_true", help="Show Falyx version")
|
parser.add_argument("--version", action="store_true", help="Show Falyx version")
|
||||||
subparsers = parser.add_subparsers(dest="command")
|
subparsers = parser.add_subparsers(dest="command")
|
||||||
|
|
||||||
run_description = "Run a command by its key or alias."
|
run_description = ["Run a command by its key or alias.\n"]
|
||||||
run_epilog = ["commands:"]
|
run_description.append("commands:")
|
||||||
if isinstance(commands, dict):
|
if isinstance(commands, dict):
|
||||||
for command in commands.values():
|
for command in commands.values():
|
||||||
run_epilog.append(command.usage)
|
run_description.append(command.usage)
|
||||||
command_description = command.description or command.help_text
|
command_description = command.description or command.help_text
|
||||||
run_epilog.append(f" {command_description}")
|
run_description.append(f"{' '*24}{command_description}")
|
||||||
run_epilog.append(" ")
|
run_epilog = (
|
||||||
run_epilog.append(
|
|
||||||
"Tip: Use 'falyx run ?[COMMAND]' to preview commands by their key or alias."
|
"Tip: Use 'falyx run ?[COMMAND]' to preview commands by their key or alias."
|
||||||
)
|
)
|
||||||
run_parser = subparsers.add_parser(
|
run_parser = subparsers.add_parser(
|
||||||
"run",
|
"run",
|
||||||
help="Run a specific command",
|
help="Run a specific command",
|
||||||
description=run_description,
|
description="\n".join(run_description),
|
||||||
epilog="\n".join(run_epilog),
|
epilog=run_epilog,
|
||||||
formatter_class=RawDescriptionHelpFormatter,
|
formatter_class=RawDescriptionHelpFormatter,
|
||||||
)
|
)
|
||||||
run_parser.add_argument("name", help="Run a command by its key or alias")
|
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]
|
[tool.poetry]
|
||||||
name = "falyx"
|
name = "falyx"
|
||||||
version = "0.1.41"
|
version = "0.1.42"
|
||||||
description = "Reliable and introspectable async CLI action framework."
|
description = "Reliable and introspectable async CLI action framework."
|
||||||
authors = ["Roland Thomas Jr <roland@rtj.dev>"]
|
authors = ["Roland Thomas Jr <roland@rtj.dev>"]
|
||||||
license = "MIT"
|
license = "MIT"
|
||||||
|
|
Loading…
Reference in New Issue