diff --git a/falyx/command.py b/falyx/command.py index 64b1fad..4ffbdd3 100644 --- a/falyx/command.py +++ b/falyx/command.py @@ -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: diff --git a/falyx/falyx.py b/falyx/falyx.py index e2d22e2..1459223 100644 --- a/falyx/falyx.py +++ b/falyx/falyx.py @@ -830,10 +830,11 @@ class Falyx: self.console.print( f"[{OneColors.LIGHT_YELLOW}]⚠️ Unknown command '{choice}'[/]" ) - raise ValidationError( - message=f"Unknown command '{choice}'.", - cursor_position=len(raw_choices), - ) + else: + raise ValidationError( + message=f"Unknown command '{choice}'.", + cursor_position=len(raw_choices), + ) return is_preview, None, args, kwargs def _create_context(self, selected_command: Command) -> ExecutionContext: @@ -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) - 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: er.summary() diff --git a/falyx/parsers/parsers.py b/falyx/parsers/parsers.py index a5c0273..3391523 100644 --- a/falyx/parsers/parsers.py +++ b/falyx/parsers/parsers.py @@ -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") diff --git a/falyx/version.py b/falyx/version.py index 6e862d0..6728003 100644 --- a/falyx/version.py +++ b/falyx/version.py @@ -1 +1 @@ -__version__ = "0.1.41" +__version__ = "0.1.42" diff --git a/pyproject.toml b/pyproject.toml index f40d2b4..2127479 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 "] license = "MIT"