falyx 0.1.46__py3-none-any.whl → 0.1.48__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
falyx/falyx.py CHANGED
@@ -83,8 +83,12 @@ class CommandValidator(Validator):
83
83
  self.falyx = falyx
84
84
  self.error_message = error_message
85
85
 
86
- def validate(self, _) -> None:
87
- pass
86
+ def validate(self, document) -> None:
87
+ if not document.text:
88
+ raise ValidationError(
89
+ message=self.error_message,
90
+ cursor_position=len(document.text),
91
+ )
88
92
 
89
93
  async def validate_async(self, document) -> None:
90
94
  text = document.text
@@ -742,12 +746,10 @@ class Falyx:
742
746
  """
743
747
  table = Table(title=self.title, show_header=False, box=box.SIMPLE) # type: ignore[arg-type]
744
748
  visible_commands = [item for item in self.commands.items() if not item[1].hidden]
745
- space = self.console.width // self.columns
746
749
  for chunk in chunks(visible_commands, self.columns):
747
750
  row = []
748
751
  for key, command in chunk:
749
- cell = f"[{key}] [{command.style}]{command.description}"
750
- row.append(f"{cell:<{space}}")
752
+ row.append(f"[{key}] [{command.style}]{command.description}")
751
753
  table.add_row(*row)
752
754
  bottom_row = self.get_bottom_row()
753
755
  for row in chunks(bottom_row, self.columns):
@@ -807,7 +809,7 @@ class Falyx:
807
809
  args, kwargs = await name_map[choice].parse_args(
808
810
  input_args, from_validate
809
811
  )
810
- except CommandArgumentError as error:
812
+ except (CommandArgumentError, Exception) as error:
811
813
  if not from_validate:
812
814
  name_map[choice].show_help()
813
815
  self.console.print(f"[{OneColors.DARK_RED}]❌ [{choice}]: {error}")
falyx/parsers/argparse.py CHANGED
@@ -292,10 +292,10 @@ class CommandArgumentParser:
292
292
  if not isinstance(choice, expected_type):
293
293
  try:
294
294
  coerce_value(choice, expected_type)
295
- except Exception:
295
+ except Exception as error:
296
296
  raise CommandArgumentError(
297
- f"Invalid choice {choice!r}: not coercible to {expected_type.__name__}"
298
- )
297
+ f"Invalid choice {choice!r}: not coercible to {expected_type.__name__} error: {error}"
298
+ ) from error
299
299
  return choices
300
300
 
301
301
  def _validate_default_type(
@@ -305,10 +305,10 @@ class CommandArgumentParser:
305
305
  if default is not None and not isinstance(default, expected_type):
306
306
  try:
307
307
  coerce_value(default, expected_type)
308
- except Exception:
308
+ except Exception as error:
309
309
  raise CommandArgumentError(
310
- f"Default value {default!r} for '{dest}' cannot be coerced to {expected_type.__name__}"
311
- )
310
+ f"Default value {default!r} for '{dest}' cannot be coerced to {expected_type.__name__} error: {error}"
311
+ ) from error
312
312
 
313
313
  def _validate_default_list_type(
314
314
  self, default: list[Any], expected_type: type, dest: str
@@ -318,10 +318,10 @@ class CommandArgumentParser:
318
318
  if not isinstance(item, expected_type):
319
319
  try:
320
320
  coerce_value(item, expected_type)
321
- except Exception:
321
+ except Exception as error:
322
322
  raise CommandArgumentError(
323
- f"Default list value {default!r} for '{dest}' cannot be coerced to {expected_type.__name__}"
324
- )
323
+ f"Default list value {default!r} for '{dest}' cannot be coerced to {expected_type.__name__} error: {error}"
324
+ ) from error
325
325
 
326
326
  def _validate_resolver(
327
327
  self, action: ArgumentAction, resolver: BaseAction | None
@@ -597,10 +597,10 @@ class CommandArgumentParser:
597
597
 
598
598
  try:
599
599
  typed = [coerce_value(value, spec.type) for value in values]
600
- except Exception:
600
+ except Exception as error:
601
601
  raise CommandArgumentError(
602
- f"Invalid value for '{spec.dest}': expected {spec.type.__name__}"
603
- )
602
+ f"Invalid value for '{spec.dest}': {error}"
603
+ ) from error
604
604
  if spec.action == ArgumentAction.ACTION:
605
605
  assert isinstance(
606
606
  spec.resolver, BaseAction
@@ -684,10 +684,10 @@ class CommandArgumentParser:
684
684
  typed_values = [
685
685
  coerce_value(value, spec.type) for value in values
686
686
  ]
687
- except ValueError:
687
+ except ValueError as error:
688
688
  raise CommandArgumentError(
689
- f"Invalid value for '{spec.dest}': expected {spec.type.__name__}"
690
- )
689
+ f"Invalid value for '{spec.dest}': {error}"
690
+ ) from error
691
691
  try:
692
692
  result[spec.dest] = await spec.resolver(*typed_values)
693
693
  except Exception as error:
@@ -715,10 +715,10 @@ class CommandArgumentParser:
715
715
  typed_values = [
716
716
  coerce_value(value, spec.type) for value in values
717
717
  ]
718
- except ValueError:
718
+ except ValueError as error:
719
719
  raise CommandArgumentError(
720
- f"Invalid value for '{spec.dest}': expected {spec.type.__name__}"
721
- )
720
+ f"Invalid value for '{spec.dest}': {error}"
721
+ ) from error
722
722
  if spec.nargs is None:
723
723
  result[spec.dest].append(spec.type(values[0]))
724
724
  else:
@@ -732,10 +732,10 @@ class CommandArgumentParser:
732
732
  typed_values = [
733
733
  coerce_value(value, spec.type) for value in values
734
734
  ]
735
- except ValueError:
735
+ except ValueError as error:
736
736
  raise CommandArgumentError(
737
- f"Invalid value for '{spec.dest}': expected {spec.type.__name__}"
738
- )
737
+ f"Invalid value for '{spec.dest}': {error}"
738
+ ) from error
739
739
  result[spec.dest].extend(typed_values)
740
740
  consumed_indices.update(range(i, new_i))
741
741
  i = new_i
@@ -745,10 +745,10 @@ class CommandArgumentParser:
745
745
  typed_values = [
746
746
  coerce_value(value, spec.type) for value in values
747
747
  ]
748
- except ValueError:
748
+ except ValueError as error:
749
749
  raise CommandArgumentError(
750
- f"Invalid value for '{spec.dest}': expected {spec.type.__name__}"
751
- )
750
+ f"Invalid value for '{spec.dest}': {error}"
751
+ ) from error
752
752
  if not typed_values and spec.nargs not in ("*", "?"):
753
753
  raise CommandArgumentError(
754
754
  f"Expected at least one value for '{spec.dest}'"
@@ -31,11 +31,16 @@ def infer_args_from_func(
31
31
  ):
32
32
  continue
33
33
 
34
- arg_type = (
35
- param.annotation if param.annotation is not inspect.Parameter.empty else str
36
- )
37
- if isinstance(arg_type, str):
38
- arg_type = str
34
+ if metadata.get("type"):
35
+ arg_type = metadata["type"]
36
+ else:
37
+ arg_type = (
38
+ param.annotation
39
+ if param.annotation is not inspect.Parameter.empty
40
+ else str
41
+ )
42
+ if isinstance(arg_type, str):
43
+ arg_type = str
39
44
  default = param.default if param.default is not inspect.Parameter.empty else None
40
45
  is_required = param.default is inspect.Parameter.empty
41
46
  if is_required:
falyx/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.46"
1
+ __version__ = "0.1.48"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: falyx
3
- Version: 0.1.46
3
+ Version: 0.1.48
4
4
  Summary: Reliable and introspectable async CLI action framework.
5
5
  License: MIT
6
6
  Author: Roland Thomas Jr
@@ -29,7 +29,7 @@ falyx/context.py,sha256=NfBpxzFzn-dYP6I3wrtGFucqm__UZo4SSBLmM8yYayE,10330
29
29
  falyx/debug.py,sha256=IRpYtdH8yeXJEsfP5rASALmBQb2U_EwrTudF2GIDdZY,1545
30
30
  falyx/exceptions.py,sha256=kK9k1v7LVNjJSwYztRa9Krhr3ZOI-6Htq2ZjlYICPKg,922
31
31
  falyx/execution_registry.py,sha256=rctsz0mrIHPToLZqylblVjDdKWdq1x_JBc8GwMP5sJ8,4710
32
- falyx/falyx.py,sha256=59Dqh8U7sR4MZcklmNoJJVEOGcpUULWiEcy-uGZeQ0U,48002
32
+ falyx/falyx.py,sha256=7MeQUdvJd71tamEZoNmgkJgWmLOJaveLU5NSjPctDpk,48091
33
33
  falyx/hook_manager.py,sha256=TFuHQnAncS_rk6vuw-VSx8bnAppLuHfrZCrzLwqcO9o,2979
34
34
  falyx/hooks.py,sha256=xMfQROib0BNsaQF4AXJpmCiGePoE1f1xpcdibgnVZWM,2913
35
35
  falyx/init.py,sha256=VZ3rYMxo7g01EraYATdl_pRN4ZqrsVueo2ZFx54gojo,3326
@@ -38,9 +38,9 @@ falyx/menu.py,sha256=E580qZsx08bnWcqRVjJuD2Fy8Zh_1zIexp5f0lC7L2c,3745
38
38
  falyx/options_manager.py,sha256=dFAnQw543tQ6Xupvh1PwBrhiSWlSACHw8K-sHP_lUh4,2842
39
39
  falyx/parsers/.pytyped,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
40
40
  falyx/parsers/__init__.py,sha256=ZfPmbtEUechDvgl99-lWhTXmFnXS_FMXJ_xb8KGEJLo,448
41
- falyx/parsers/argparse.py,sha256=lXhGvumL2XRHhJzE0anVnTy23XZLikCn7nZAkMf8ZdE,37301
41
+ falyx/parsers/argparse.py,sha256=5fIGDLrI-Aec0pTgDDTg5crGrHjE-EPadpSJmT8H-Ac,37396
42
42
  falyx/parsers/parsers.py,sha256=MXWC8OQ3apDaeKfY0O4J8NnkxofWVOCRnKatC00lGm0,8796
43
- falyx/parsers/signature.py,sha256=PfDe432PYcJDhDXguNzumFqWjDLk13s6jhZF33r__AM,2326
43
+ falyx/parsers/signature.py,sha256=cCa-yKUcbbET0Ho45oFZWWHFGCX5a_LaAOWRP7b87po,2465
44
44
  falyx/parsers/utils.py,sha256=w_UzvvP62EDKXWSf3jslEsJfd45usGyFqXKNziQhLRI,2893
45
45
  falyx/prompt_utils.py,sha256=qgk0bXs7mwzflqzWyFhEOTpKQ_ZtMIqGhKeg-ocwNnE,1542
46
46
  falyx/protocols.py,sha256=-9GbCBUzzsEgw2_KOCYqxxzWJuez0eHmwnZp_ShY0jc,493
@@ -53,9 +53,9 @@ falyx/themes/__init__.py,sha256=1CZhEUCin9cUk8IGYBUFkVvdHRNNJBEFXccHwpUKZCA,284
53
53
  falyx/themes/colors.py,sha256=4aaeAHJetmeNInI0Zytg4E3YqKfPFelpf04vtjSvsS8,19776
54
54
  falyx/utils.py,sha256=U45xnZFUdoFC4xiji_9S1jHS5V7MvxSDtufP8EgB0SM,6732
55
55
  falyx/validators.py,sha256=t5iyzVpY8tdC4rfhr4isEfWpD5gNTzjeX_Hbi_Uq6sA,1328
56
- falyx/version.py,sha256=X3e_85I7oZGwZD8nW9SBKEUbQU7-_3W9FXuicrfxHjc,23
57
- falyx-0.1.46.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
58
- falyx-0.1.46.dist-info/METADATA,sha256=sKgexNI7YEsZiUNO2LTxZSmlJheEm_nj0WnVkZsZXhI,5561
59
- falyx-0.1.46.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
60
- falyx-0.1.46.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
61
- falyx-0.1.46.dist-info/RECORD,,
56
+ falyx/version.py,sha256=HQG3McjdVzmICa25LtGfE6oXxlwg6YdEcj9EoChMH00,23
57
+ falyx-0.1.48.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
58
+ falyx-0.1.48.dist-info/METADATA,sha256=t0yc7XPob84f7Rd4Nh3d0u1NhHYawf9w18jALzc1yII,5561
59
+ falyx-0.1.48.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
60
+ falyx-0.1.48.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
61
+ falyx-0.1.48.dist-info/RECORD,,
File without changes