falyx 0.1.60__py3-none-any.whl → 0.1.61__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.
@@ -52,3 +52,31 @@ class SelectionReturnType(Enum):
52
52
  def _missing_(cls, value: object) -> SelectionReturnType:
53
53
  valid = ", ".join(member.value for member in cls)
54
54
  raise ValueError(f"Invalid DictReturnType: '{value}'. Must be one of: {valid}")
55
+
56
+
57
+ class ConfirmType(Enum):
58
+ """Enum for different confirmation types."""
59
+
60
+ YES_NO = "yes_no"
61
+ YES_CANCEL = "yes_cancel"
62
+ YES_NO_CANCEL = "yes_no_cancel"
63
+ TYPE_WORD = "type_word"
64
+ OK_CANCEL = "ok_cancel"
65
+
66
+ @classmethod
67
+ def choices(cls) -> list[ConfirmType]:
68
+ """Return a list of all hook type choices."""
69
+ return list(cls)
70
+
71
+ def __str__(self) -> str:
72
+ """Return the string representation of the confirm type."""
73
+ return self.value
74
+
75
+ @classmethod
76
+ def _missing_(cls, value: object) -> ConfirmType:
77
+ if isinstance(value, str):
78
+ for member in cls:
79
+ if member.value == value.lower():
80
+ return member
81
+ valid = ", ".join(member.value for member in cls)
82
+ raise ValueError(f"Invalid ConfirmType: '{value}'. Must be one of: {valid}")
@@ -1,11 +1,11 @@
1
1
  from __future__ import annotations
2
2
 
3
- from enum import Enum
4
3
  from typing import Any
5
4
 
6
5
  from prompt_toolkit import PromptSession
7
6
  from rich.tree import Tree
8
7
 
8
+ from falyx.action.action_types import ConfirmType
9
9
  from falyx.action.base_action import BaseAction
10
10
  from falyx.context import ExecutionContext
11
11
  from falyx.execution_registry import ExecutionRegistry as er
@@ -17,25 +17,6 @@ from falyx.themes import OneColors
17
17
  from falyx.validators import word_validator, words_validator
18
18
 
19
19
 
20
- class ConfirmType(Enum):
21
- """Enum for different confirmation types."""
22
-
23
- YES_NO = "yes_no"
24
- YES_CANCEL = "yes_cancel"
25
- YES_NO_CANCEL = "yes_no_cancel"
26
- TYPE_WORD = "type_word"
27
- OK_CANCEL = "ok_cancel"
28
-
29
- @classmethod
30
- def choices(cls) -> list[ConfirmType]:
31
- """Return a list of all hook type choices."""
32
- return list(cls)
33
-
34
- def __str__(self) -> str:
35
- """Return the string representation of the confirm type."""
36
- return self.value
37
-
38
-
39
20
  class ConfirmAction(BaseAction):
40
21
  """
41
22
  Action to confirm an operation with the user.
@@ -66,7 +47,7 @@ class ConfirmAction(BaseAction):
66
47
  message: str = "Confirm?",
67
48
  confirm_type: ConfirmType | str = ConfirmType.YES_NO,
68
49
  prompt_session: PromptSession | None = None,
69
- confirm: bool = True,
50
+ never_prompt: bool = False,
70
51
  word: str = "CONFIRM",
71
52
  return_last_result: bool = False,
72
53
  inject_last_result: bool = True,
@@ -88,11 +69,11 @@ class ConfirmAction(BaseAction):
88
69
  name=name,
89
70
  inject_last_result=inject_last_result,
90
71
  inject_into=inject_into,
72
+ never_prompt=never_prompt,
91
73
  )
92
74
  self.message = message
93
75
  self.confirm_type = self._coerce_confirm_type(confirm_type)
94
76
  self.prompt_session = prompt_session or PromptSession()
95
- self.confirm = confirm
96
77
  self.word = word
97
78
  self.return_last_result = return_last_result
98
79
 
@@ -165,11 +146,9 @@ class ConfirmAction(BaseAction):
165
146
  try:
166
147
  await self.hooks.trigger(HookType.BEFORE, context)
167
148
  if (
168
- not self.confirm
149
+ self.never_prompt
169
150
  or self.options_manager
170
- and not should_prompt_user(
171
- confirm=self.confirm, options=self.options_manager
172
- )
151
+ and not should_prompt_user(confirm=True, options=self.options_manager)
173
152
  ):
174
153
  logger.debug(
175
154
  "Skipping confirmation for action '%s' as 'confirm' is False or options manager indicates no prompt.",
@@ -209,7 +188,7 @@ class ConfirmAction(BaseAction):
209
188
  )
210
189
  tree.add(f"[bold]Message:[/] {self.message}")
211
190
  tree.add(f"[bold]Type:[/] {self.confirm_type.value}")
212
- tree.add(f"[bold]Prompt Required:[/] {'Yes' if self.confirm else 'No'}")
191
+ tree.add(f"[bold]Prompt Required:[/] {'No' if self.never_prompt else 'Yes'}")
213
192
  if self.confirm_type == ConfirmType.TYPE_WORD:
214
193
  tree.add(f"[bold]Confirmation Word:[/] {self.word}")
215
194
  if parent is None:
@@ -395,7 +395,7 @@ class CommandArgumentParser:
395
395
  help: str = "",
396
396
  dest: str | None = None,
397
397
  resolver: BaseAction | None = None,
398
- lazy_resolver: bool = False,
398
+ lazy_resolver: bool = True,
399
399
  ) -> None:
400
400
  """Add an argument to the parser.
401
401
  For `ArgumentAction.ACTION`, `nargs` and `type` determine how many and what kind
@@ -852,6 +852,10 @@ class CommandArgumentParser:
852
852
  and spec.lazy_resolver
853
853
  and from_validate
854
854
  ):
855
+ if not args:
856
+ raise CommandArgumentError(
857
+ f"Missing required argument '{spec.dest}': {spec.get_choice_text()}{help_text}"
858
+ )
855
859
  continue # Lazy resolvers are not validated here
856
860
  raise CommandArgumentError(
857
861
  f"Missing required argument '{spec.dest}': {spec.get_choice_text()}{help_text}"
falyx/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.60"
1
+ __version__ = "0.1.61"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: falyx
3
- Version: 0.1.60
3
+ Version: 0.1.61
4
4
  Summary: Reliable and introspectable async CLI action framework.
5
5
  License: MIT
6
6
  Author: Roland Thomas Jr
@@ -7,10 +7,10 @@ falyx/action/action.py,sha256=Pm9lnxKhJoI1vs-fadAJrXkcDGYcBCMwvQ81HHxd0HA,5879
7
7
  falyx/action/action_factory.py,sha256=WosLeaYf79e83XHAAkxKi62zi8jJEiVlzvgOC84Z7t0,4840
8
8
  falyx/action/action_group.py,sha256=RQdHOWCa8XRUme3S5YGJTICLozIApAlIpRUgEeFaiyw,7728
9
9
  falyx/action/action_mixins.py,sha256=oUrjbweCeateshg3tqtbQiGuV8u4GvlioIZCUr9D1m4,1244
10
- falyx/action/action_types.py,sha256=TfzZ8y560h9RWu8Sh1HAbQVRlSAWJZcTdBMbQ-STbQY,1467
10
+ falyx/action/action_types.py,sha256=TjUdwbnWVNzp5B5pFjgwRdA-P-MiY4bwe1dRSz-Ur3s,2318
11
11
  falyx/action/base_action.py,sha256=o9Nml70-SEVTXnu9J0-VYnO-t5wZZM0o59lYDth24Po,5829
12
12
  falyx/action/chained_action.py,sha256=TNJz25jnzQQAIwXM6uaK8mzhq4bgRks5n7IZ2nDQM6Q,9614
13
- falyx/action/confirm_action.py,sha256=oXPnZswkQFJ-F-s73vddpF-BRg1wJeVnHjR4K2yN7ow,9085
13
+ falyx/action/confirm_action.py,sha256=rBtkaMuMYJEXcLu5VeWA0YPO6Yvj0gJBiGDAfoAkCEI,8601
14
14
  falyx/action/fallback_action.py,sha256=3FGWfoR1MIgY0ZkDNOpKu8p3JqPWzh5ON3943mfgDGs,1708
15
15
  falyx/action/http_action.py,sha256=DNeSBWh58UTFGlfFyTk2GnhS54hpLAJLC0QNbq2cYic,5799
16
16
  falyx/action/io_action.py,sha256=V888tQgAynqsVvkhICnEeE4wRs2vvdTcdlEpDSEbHqo,6128
@@ -47,7 +47,7 @@ falyx/parser/.pytyped,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
47
47
  falyx/parser/__init__.py,sha256=NbxAovKIY-duFTs6DAsdM_OzL7s3VIu19KMOmltX9ts,512
48
48
  falyx/parser/argument.py,sha256=MIKUj-hrdLDUK8xuW84_l9ms_t5CoNFpVDmxMZIbW-I,4105
49
49
  falyx/parser/argument_action.py,sha256=Lcpb9siYr_q2T8qU-jXVtqFb11bFPPKEGH3gurJv2NM,757
50
- falyx/parser/command_argument_parser.py,sha256=lWPeoYj0NUMbBsXrf-Z3KUo4osYrRERoXA_Uu3HmF9w,41264
50
+ falyx/parser/command_argument_parser.py,sha256=W6vfj5acUx9wiA5TDjDO3CYlzsgGHrMM86-Gs19q-Eo,41482
51
51
  falyx/parser/parser_types.py,sha256=DLLuIXE8cAVLS41trfsNy-XJmtqSa1HfnJVAYIIc42w,315
52
52
  falyx/parser/parsers.py,sha256=vb-l_NNh5O9L98Lcafhz91flRLxC1BnW6U8JdeabRCw,14118
53
53
  falyx/parser/signature.py,sha256=fSltLEr8ctj1qpbU-OvTMnREjlb8OTG5t-guJFR7j4E,2529
@@ -63,9 +63,9 @@ falyx/themes/__init__.py,sha256=1CZhEUCin9cUk8IGYBUFkVvdHRNNJBEFXccHwpUKZCA,284
63
63
  falyx/themes/colors.py,sha256=4aaeAHJetmeNInI0Zytg4E3YqKfPFelpf04vtjSvsS8,19776
64
64
  falyx/utils.py,sha256=U45xnZFUdoFC4xiji_9S1jHS5V7MvxSDtufP8EgB0SM,6732
65
65
  falyx/validators.py,sha256=AXpMGnk1_7J7MAbbol6pkMAiSIdNHoF5pwtA2-xS6H8,6029
66
- falyx/version.py,sha256=SH6dBtwKkjChke7DXHi0Y5HbtzV16-5wAfhv91d_D0A,23
67
- falyx-0.1.60.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
68
- falyx-0.1.60.dist-info/METADATA,sha256=8GLh3rrDHvaz6XtiNJCau_CDE9iJGeHVYnlrDlFMXc4,5561
69
- falyx-0.1.60.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
70
- falyx-0.1.60.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
71
- falyx-0.1.60.dist-info/RECORD,,
66
+ falyx/version.py,sha256=CjOPJsj7rCFM2zpom_253GmmHGb2RQ8NuZwsEg0ZmF0,23
67
+ falyx-0.1.61.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
68
+ falyx-0.1.61.dist-info/METADATA,sha256=JdPjGhW2VQKmq-EPF5IfR5m7lRVx8Xlq6Yb4hb11WR4,5561
69
+ falyx-0.1.61.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
70
+ falyx-0.1.61.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
71
+ falyx-0.1.61.dist-info/RECORD,,
File without changes