falyx 0.1.54__py3-none-any.whl → 0.1.55__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.
@@ -0,0 +1,53 @@
1
+ import shlex
2
+ from typing import Iterable
3
+
4
+ from prompt_toolkit.completion import Completer, Completion
5
+
6
+ from falyx.parser.command_argument_parser import CommandArgumentParser
7
+
8
+
9
+ class FalyxCompleter(Completer):
10
+ def __init__(self, falyx: "Falyx") -> None:
11
+ self.falyx = falyx
12
+
13
+ def get_completions(self, document, complete_event) -> Iterable[Completion]:
14
+ text = document.text_before_cursor.strip()
15
+ if not text:
16
+ yield from self._complete_command("")
17
+ return
18
+
19
+ try:
20
+ tokens = shlex.split(text)
21
+ except ValueError:
22
+ return # unmatched quotes or syntax error
23
+
24
+ if not tokens:
25
+ yield from self._complete_command("")
26
+ return
27
+
28
+ command_token = tokens[0]
29
+ command_key = command_token.lstrip("?").upper()
30
+ command = self.falyx._name_map.get(command_key)
31
+
32
+ if command is None:
33
+ yield from self._complete_command(command_token)
34
+ return
35
+
36
+ used_flags = set(tokens[1:]) # simplistic
37
+ parser: CommandArgumentParser = command.arg_parser or CommandArgumentParser()
38
+ for arg in parser._keyword_list:
39
+ for flag in arg.flags:
40
+ if flag not in used_flags:
41
+ yield Completion(flag, start_position=0)
42
+
43
+ for dest, arg in parser._positional.items():
44
+ if dest not in used_flags:
45
+ yield Completion(arg.dest, start_position=0)
46
+
47
+ def _complete_command(self, prefix: str) -> Iterable[Completion]:
48
+ seen = set()
49
+ for cmd in self.falyx.commands.values():
50
+ for key in [cmd.key] + cmd.aliases:
51
+ if key not in seen and key.upper().startswith(prefix.upper()):
52
+ yield Completion(key, start_position=-len(prefix))
53
+ seen.add(key)
@@ -645,8 +645,6 @@ class CommandArgumentParser:
645
645
  if arg in self._keyword:
646
646
  next_flagged_index = index
647
647
  break
648
- print(f"next_flagged_index: {next_flagged_index}")
649
- print(f"{self._keyword_list=}")
650
648
  if next_flagged_index == -1:
651
649
  next_flagged_index = len(args)
652
650
  args_consumed = await self._consume_all_positional_args(
falyx/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "0.1.54"
1
+ __version__ = "0.1.55"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: falyx
3
- Version: 0.1.54
3
+ Version: 0.1.55
4
4
  Summary: Reliable and introspectable async CLI action framework.
5
5
  License: MIT
6
6
  Author: Roland Thomas Jr
@@ -33,6 +33,7 @@ falyx/debug.py,sha256=pguI0XQcZ-7jte5YUPexAufa1oxxalYO1JgmO6GU3rI,1557
33
33
  falyx/exceptions.py,sha256=58D4BYkyJ7PlpZoNk37GsUsFThm_gIlb2Ex2XXhLklI,1099
34
34
  falyx/execution_registry.py,sha256=7t_96-Q7R7MAJBvWwAt5IAERp0TjbGZPGeeJ1s24ey8,7628
35
35
  falyx/falyx.py,sha256=IGNgkaSgrF0jydQQulJUl0hJZT56tmy2UCDmC9DSWB8,49773
36
+ falyx/falyx_completer.py,sha256=DH6SIkRU1dVdhzJ2NdKRhWaAhdlDe8xLm5aMgWih_oA,1836
36
37
  falyx/hook_manager.py,sha256=TFuHQnAncS_rk6vuw-VSx8bnAppLuHfrZCrzLwqcO9o,2979
37
38
  falyx/hooks.py,sha256=xMfQROib0BNsaQF4AXJpmCiGePoE1f1xpcdibgnVZWM,2913
38
39
  falyx/init.py,sha256=F9jg7mLPoBWXdJnc_fyWG7zVQSnrAO8ueDiP8AJxDWE,3331
@@ -43,7 +44,7 @@ falyx/parser/.pytyped,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
43
44
  falyx/parser/__init__.py,sha256=NbxAovKIY-duFTs6DAsdM_OzL7s3VIu19KMOmltX9ts,512
44
45
  falyx/parser/argument.py,sha256=25fyytWj6sH5UROSL-MEEKlDYXm-LwONCBTsn6pbzZ0,3443
45
46
  falyx/parser/argument_action.py,sha256=rNVeth0eMpkZRU_eT1RPVxOGzD4pbdAMx9Kq07T4mG4,709
46
- falyx/parser/command_argument_parser.py,sha256=nIWjwCxSvGHQMUqAG1_VFAYcV5kmcD_aY2s-KhWxCv0,34014
47
+ falyx/parser/command_argument_parser.py,sha256=ajd2_coCZKU37VWXEZGFN1qp54gnjiw1ziCa6FHKUpY,33907
47
48
  falyx/parser/parsers.py,sha256=X3eEltxBbwRwWG5Q1A1GqSdQCJZAYN5Eub0_U6dlBN4,9159
48
49
  falyx/parser/signature.py,sha256=fSltLEr8ctj1qpbU-OvTMnREjlb8OTG5t-guJFR7j4E,2529
49
50
  falyx/parser/utils.py,sha256=HYoTRR9-XbuzV2cz2BCfcHaGlzzFj4j3tlfuAx6-9t4,2942
@@ -58,9 +59,9 @@ falyx/themes/__init__.py,sha256=1CZhEUCin9cUk8IGYBUFkVvdHRNNJBEFXccHwpUKZCA,284
58
59
  falyx/themes/colors.py,sha256=4aaeAHJetmeNInI0Zytg4E3YqKfPFelpf04vtjSvsS8,19776
59
60
  falyx/utils.py,sha256=U45xnZFUdoFC4xiji_9S1jHS5V7MvxSDtufP8EgB0SM,6732
60
61
  falyx/validators.py,sha256=Pbdxh5777Y03HxyArAh2ApeVSx23in4w4K38G43Vt98,5197
61
- falyx/version.py,sha256=0U9S9zRz7MduvARyiWFUbfYZNKDf9XCo9-1NqTcx3CU,23
62
- falyx-0.1.54.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
63
- falyx-0.1.54.dist-info/METADATA,sha256=kQeZSj95kTb7PTH-BuWbKia2ai2ssAXzQXo3AducOOI,5561
64
- falyx-0.1.54.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
65
- falyx-0.1.54.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
66
- falyx-0.1.54.dist-info/RECORD,,
62
+ falyx/version.py,sha256=mSfkicuxJWIsRzwvWTgXF6azCtmLwU9PYRQ4CHsYpxE,23
63
+ falyx-0.1.55.dist-info/LICENSE,sha256=B0yqgaHuSdhN7T3OBmgQSiDTy8HqT5Oe_dLypRe4Ra4,1073
64
+ falyx-0.1.55.dist-info/METADATA,sha256=MSU6PxGHEDBtNBDvI1irbtRBFf1Sf-SqgfRpZxTjjDM,5561
65
+ falyx-0.1.55.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
66
+ falyx-0.1.55.dist-info/entry_points.txt,sha256=j8owOSl2j1Ss8DtGMnKfgehKaolqnIPhVFHaUBLUnMs,45
67
+ falyx-0.1.55.dist-info/RECORD,,
File without changes