argenta 1.0.0b1__py3-none-any.whl → 1.0.1__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.
@@ -1,1340 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: argenta
3
- Version: 1.0.0b1
4
- Summary: Python library for creating TUI
5
- Author-email: kolo <kolo.is.main@gmail.com>
6
- License: MIT
7
- License-File: LICENSE
8
- Requires-Python: <4.0,>=3.11
9
- Requires-Dist: art<7.0,>=6.4
10
- Requires-Dist: pyreadline3<4.0.0,>=3.5.4
11
- Requires-Dist: rich<15.0.0,>=14.0.0
12
- Description-Content-Type: text/markdown
13
-
14
- # Argenta
15
-
16
- ### Python library for creating TUI
17
-
18
- ---
19
-
20
- <details>
21
-
22
- <summary>Contents</summary>
23
-
24
- - [**Installing**](#installing)
25
- - [**Quick Start**](#quick-start)
26
- - [**Documentation**](#documentation)
27
- - [**App** Objects](#app-objects)
28
- - [set\_description\_message\_pattern](#set\_description\_message\_pattern)
29
- - [set\_invalid\_input\_flags\_handler](#set\_invalid\_input\_flags\_handler)
30
- - [set\_repeated\_input\_flags\_handler](#set\_repeated\_input\_flags\_handler)
31
- - [set\_unknown\_command\_handler](#set\_unknown\_command\_handler)
32
- - [set\_empty\_command\_handler](#set\_empty\_command\_handler)
33
- - [set\_exit\_command\_handler](#set\_exit\_command\_handler)
34
- - [run\_polling](#run\_polling)
35
- - [include\_router](#include\_router)
36
- - [include\_routers](#include\_routers)
37
- - [add\_message\_on\_startup](#add\_message\_on\_startup)
38
- - [**AutoCompleter** Objects](#autocompleter-objects)
39
- - [**PredefinedMessages** Objects](#predefinedmessages-objects)
40
- - [**StaticDividingLine** Objects](#staticdividingline-objects)
41
- - [get\_full\_static\_line](#get\_full\_static\_line)
42
- - [**DynamicDividingLine** Objects](#dynamicdividingline-objects)
43
- - [get\_full\_dynamic\_line](#get\_full\_dynamic\_line)
44
- - [**NoRegisteredHandlersException** Objects](#noregisteredhandlersexception-objects)
45
- - [**UnprocessedInputFlagException** Objects](#unprocessedinputflagexception-objects)
46
- - [**RepeatedInputFlagsException** Objects](#repeatedinputflagsexception-objects)
47
- - [**EmptyInputCommandException** Objects](#emptyinputcommandexception-objects)
48
- - [**PredefinedFlags** Objects](#predefinedflags-objects)
49
- - [**InputFlag** Objects](#inputflag-objects)
50
- - [get\_value](#get\_value)
51
- - [**Flag** Objects](#flag-objects)
52
- - [**Flags** Objects](#flags-objects)
53
- - [get\_flags](#get\_flags)
54
- - [add\_flag](#add\_flag)
55
- - [add\_flags](#add\_flags)
56
- - [get\_flag](#get\_flag)
57
- - [**InputFlags** Objects](#inputflags-objects)
58
- - [get\_flags](#get\_flags)
59
- - [add\_flag](#add\_flag)
60
- - [add\_flags](#add\_flags)
61
- - [get\_flag](#get\_flag)
62
- - [**Command** Objects](#command-objects)
63
- - [**PositionalArgument** Objects](#positionalargument-objects)
64
- - [**OptionalArgument** Objects](#optionalargument-objects)
65
- - [**BooleanArgument** Objects](#booleanargument-objects)
66
- - [**ArgParse** Objects](#argparse-objects)
67
- - [set\_args](#set\_args)
68
- - [**Orchestrator** Objects](#orchestrator-objects)
69
- - [start\_polling](#start\_polling)
70
- - [get\_input\_args](#get\_input\_args)
71
- - [**Router** Objects](#router-objects)
72
- - [@command](#@command)
73
- - [set\_invalid\_input\_flag\_handler](#set\_invalid\_input\_flag\_handler)
74
- - [input\_command\_handler](#input\_command\_handler)
75
- - [set\_command\_register\_ignore](#set\_command\_register\_ignore)
76
- - [get\_triggers](#get\_triggers)
77
- - [get\_aliases](#get\_aliases)
78
- - [get\_title](#get\_title)
79
- - [set\_title](#set\_title)
80
- - [**RepeatedFlagNameException** Objects](#repeatedflagnameexception-objects)
81
- - [**TooManyTransferredArgsException** Objects](#toomanytransferredargsexception-objects)
82
- - [**RequiredArgumentNotPassedException** Objects](#requiredargumentnotpassedexception-objects)
83
- - [**IncorrectNumberOfHandlerArgsException** Objects](#incorrectnumberofhandlerargsexception-objects)
84
- - [**TriggerContainSpacesException** Objects](#triggercontainspacesexception-objects)
85
- - [**Tests**](#tests)
86
- </details>
87
-
88
- ---
89
-
90
- ![preview](https://github.com/koloideal/Argenta/blob/kolo/imgs/mock_app_preview4.png?raw=True)
91
- An example of the TUI appearance
92
-
93
- ---
94
-
95
- # Installing
96
- ```bash
97
- pip install argenta
98
- ```
99
- or
100
- ```bash
101
- poetry add argenta
102
- ```
103
-
104
- ---
105
-
106
- # Quick start
107
-
108
- Example of the simplest TUI with a single command
109
- ```python
110
- # routers.py
111
- from argenta.router import Router
112
- from argenta.command import Command
113
-
114
-
115
- router = Router()
116
-
117
- @router.command(Command("hello"))
118
- def handler():
119
- print("Hello, world!")
120
- ```
121
-
122
- ```python
123
- # main.py
124
- from argenta.app import App
125
- from argenta.orchestrator import Orchestrator
126
- from routers import router
127
-
128
- app: App = App()
129
- orchestrator: Orchestrator = Orchestrator()
130
-
131
-
132
- def main() -> None:
133
- app.include_router(router)
134
- orchestrator.start_polling(app)
135
-
136
-
137
- if __name__ == '__main__':
138
- main()
139
- ```
140
- Example TUI with a command that has processed flags
141
-
142
- ```python
143
- # routers.py
144
- import re
145
- from argenta.router import Router
146
- from argenta.command import Command
147
- from argenta.orchestrator import Orchestrator
148
- from argenta.command.flag.defaults import PredefinedFlags
149
- from argenta.command.flag import Flags, Flag, InputFlags
150
-
151
- router = Router()
152
-
153
- registered_flags = Flags(PredefinedFlags.HOST,
154
- Flag('port', '--', re.compile(r'^[0-9]{1,4}$')))
155
-
156
-
157
- @router.command(Command("hello"))
158
- def handler():
159
- print("Hello, world!")
160
-
161
-
162
- @router.command(Command(trigger="ssh",
163
- description='connect via ssh',
164
- flags=registered_flags))
165
- def handler_with_flags(flags: InputFlags):
166
- for flag in flags:
167
- print(f'Flag name: {flag.get_name()}\n'
168
- f'Flag value: {flag.get_value()}')
169
- ```
170
-
171
- ---
172
-
173
- # Documentation
174
-
175
- <a id="argenta.app.models"></a>
176
-
177
- # `.app`
178
-
179
- <a id="argenta.app.models.App"></a>
180
-
181
- ## App Objects
182
-
183
- ```python
184
- class App(BaseApp)
185
- ```
186
-
187
- <a id="argenta.app.models.App.__init__"></a>
188
-
189
- #### \_\_init\_\_
190
-
191
- ```python
192
- def __init__(prompt: str = 'What do you want to do?',
193
- initial_message: str = 'Argenta',
194
- farewell_message: str = 'See you',
195
- exit_command: Command = Command('Q', 'Exit command'),
196
- system_router_title: str | None = 'System points:',
197
- ignore_command_register: bool = True,
198
- dividing_line: StaticDividingLine | DynamicDividingLine = StaticDividingLine(),
199
- repeat_command_groups: bool = True,
200
- override_system_messages: bool = False,
201
- autocompleter: AutoCompleter = AutoCompleter(),
202
- print_func: Callable[[str], None] = Console().print) -> None
203
- ```
204
-
205
- Public. The essence of the application itself.
206
-
207
- Configures and manages all aspects of the behavior and presentation of the user interacting with the user
208
-
209
- **Arguments**:
210
-
211
- - `prompt`: displayed before entering the command
212
- - `initial_message`: displayed at the start of the app
213
- - `farewell_message`: displayed at the end of the app
214
- - `exit_command`: the entity of the command that will be terminated when entered
215
- - `system_router_title`: system router title
216
- - `ignore_command_register`: whether to ignore the case of the entered commands
217
- - `dividing_line`: the entity of the dividing line
218
- - `repeat_command_groups`: whether to repeat the available commands and their description
219
- - `override_system_messages`: whether to redefine the default formatting of system messages
220
- - `autocompleter`: the entity of the autocompleter
221
- - `print_func`: system messages text output function
222
-
223
- **Returns**:
224
-
225
- `None`
226
-
227
- ---
228
-
229
- <a id="argenta.app.models.BaseApp.set_description_message_pattern"></a>
230
-
231
- #### set\_description\_message\_pattern
232
-
233
- ```python
234
- def set_description_message_pattern(pattern: Callable[[str, str], str]) -> None
235
- ```
236
-
237
- Public. Sets the output pattern of the available commands
238
-
239
- **Arguments**:
240
-
241
- - `pattern`: output pattern of the available commands
242
-
243
- **Returns**:
244
-
245
- `None`
246
-
247
- ---
248
-
249
- <a id="argenta.app.models.BaseApp.set_invalid_input_flags_handler"></a>
250
-
251
- #### set\_invalid\_input\_flags\_handler
252
-
253
- ```python
254
- def set_invalid_input_flags_handler(handler: Callable[[str], None]) -> None
255
- ```
256
-
257
- Public. Sets the handler for incorrect flags when entering a command
258
-
259
- **Arguments**:
260
-
261
- - `handler`: handler for incorrect flags when entering a command
262
-
263
- **Returns**:
264
-
265
- `None`
266
-
267
- ---
268
-
269
- <a id="argenta.app.models.BaseApp.set_repeated_input_flags_handler"></a>
270
-
271
- #### set\_repeated\_input\_flags\_handler
272
-
273
- ```python
274
- def set_repeated_input_flags_handler(handler: Callable[[str], None]) -> None
275
- ```
276
-
277
- Public. Sets the handler for repeated flags when entering a command
278
-
279
- **Arguments**:
280
-
281
- - `handler`: handler for repeated flags when entering a command
282
-
283
- **Returns**:
284
-
285
- `None`
286
-
287
- ---
288
-
289
- <a id="argenta.app.models.BaseApp.set_unknown_command_handler"></a>
290
-
291
- #### set\_unknown\_command\_handler
292
-
293
- ```python
294
- def set_unknown_command_handler(handler: Callable[[str], None]) -> None
295
- ```
296
-
297
- Public. Sets the handler for unknown commands when entering a command
298
-
299
- **Arguments**:
300
-
301
- - `handler`: handler for unknown commands when entering a command
302
-
303
- **Returns**:
304
-
305
- `None`
306
-
307
- ---
308
-
309
- <a id="argenta.app.models.BaseApp.set_empty_command_handler"></a>
310
-
311
- #### set\_empty\_command\_handler
312
-
313
- ```python
314
- def set_empty_command_handler(handler: Callable[[], None]) -> None
315
- ```
316
-
317
- Public. Sets the handler for empty commands when entering a command
318
-
319
- **Arguments**:
320
-
321
- - `handler`: handler for empty commands when entering a command
322
-
323
- **Returns**:
324
-
325
- `None`
326
-
327
- ---
328
-
329
- <a id="argenta.app.models.BaseApp.set_exit_command_handler"></a>
330
-
331
- #### set\_exit\_command\_handler
332
-
333
- ```python
334
- def set_exit_command_handler(handler: Callable[[], None]) -> None
335
- ```
336
-
337
- Public. Sets the handler for exit command when entering a command
338
-
339
- **Arguments**:
340
-
341
- - `handler`: handler for exit command when entering a command
342
-
343
- **Returns**:
344
-
345
- `None`
346
-
347
- ---
348
-
349
- <a id="argenta.app.models.App.include_router"></a>
350
-
351
- #### include\_router
352
-
353
- ```python
354
- def include_router(router: Router) -> None
355
- ```
356
-
357
- Public. Registers the router in the application
358
-
359
- **Arguments**:
360
-
361
- - `router`: registered router
362
-
363
- **Returns**:
364
-
365
- `None`
366
-
367
- ---
368
-
369
- <a id="argenta.app.models.App.include_routers"></a>
370
-
371
- #### include\_routers
372
-
373
- ```python
374
- def include_routers(*routers: Router) -> None
375
- ```
376
-
377
- Public. Registers the routers in the application
378
-
379
- **Arguments**:
380
-
381
- - `routers`: registered routers
382
-
383
- **Returns**:
384
-
385
- `None`
386
-
387
- ---
388
-
389
- <a id="argenta.app.models.App.add_message_on_startup"></a>
390
-
391
- #### add\_message\_on\_startup
392
-
393
- ```python
394
- def add_message_on_startup(message: str) -> None
395
- ```
396
-
397
- Public. Adds a message that will be displayed when the application is launched
398
-
399
- **Arguments**:
400
-
401
- - `message`: the message being added
402
-
403
- **Returns**:
404
-
405
- `None`
406
-
407
- ---
408
-
409
- <a id="argenta.app.autocompleter.entity"></a>
410
-
411
- # `.app.autocompleter`
412
-
413
- <a id="argenta.app.autocompleter.entity.AutoCompleter"></a>
414
-
415
- ## AutoCompleter Objects
416
-
417
- ```python
418
- class AutoCompleter()
419
- ```
420
-
421
- <a id="argenta.app.autocompleter.entity.AutoCompleter.__init__"></a>
422
-
423
- #### \_\_init\_\_
424
-
425
- ```python
426
- def __init__(history_filename: str = False,
427
- autocomplete_button: str = 'tab') -> None
428
- ```
429
-
430
- Public. Configures and implements auto-completion of input command
431
-
432
- **Arguments**:
433
-
434
- - `history_filename`: the name of the file for saving the history of the autocompleter
435
- - `autocomplete_button`: the button for auto-completion
436
-
437
- **Returns**:
438
-
439
- `None`
440
-
441
- ---
442
-
443
- <a id="argenta.app.defaults"></a>
444
-
445
- # `.app.defaults`
446
-
447
- <a id="argenta.app.defaults.PredefinedMessages"></a>
448
-
449
- ## PredefinedMessages Objects
450
-
451
- ```python
452
- @dataclass
453
- class PredefinedMessages()
454
- ```
455
-
456
- Public. A dataclass with predetermined messages for quick use
457
-
458
- ---
459
-
460
- <a id="argenta.app.dividing_line.models"></a>
461
-
462
- # `.app.dividing_line`
463
-
464
- <a id="argenta.app.dividing_line.models.StaticDividingLine"></a>
465
-
466
- ## StaticDividingLine Objects
467
-
468
- ```python
469
- class StaticDividingLine(BaseDividingLine)
470
- ```
471
-
472
- <a id="argenta.app.dividing_line.models.StaticDividingLine.__init__"></a>
473
-
474
- #### \_\_init\_\_
475
-
476
- ```python
477
- def __init__(unit_part: str = '-', length: int = 25) -> None
478
- ```
479
-
480
- Public. The static dividing line
481
-
482
- **Arguments**:
483
-
484
- - `unit_part`: the single part of the dividing line
485
- - `length`: the length of the dividing line
486
-
487
- **Returns**:
488
-
489
- `None`
490
-
491
- ---
492
-
493
- <a id="argenta.app.dividing_line.models.DynamicDividingLine"></a>
494
-
495
- ## DynamicDividingLine Objects
496
-
497
- ```python
498
- class DynamicDividingLine(BaseDividingLine)
499
- ```
500
-
501
- <a id="argenta.app.dividing_line.models.DynamicDividingLine.__init__"></a>
502
-
503
- #### \_\_init\_\_
504
-
505
- ```python
506
- def __init__(unit_part: str = '-') -> None
507
- ```
508
-
509
- Public. The dynamic dividing line
510
-
511
- **Arguments**:
512
-
513
- - `unit_part`: the single part of the dividing line
514
-
515
- **Returns**:
516
-
517
- `None`
518
-
519
- ---
520
-
521
- <a id="argenta.app.exceptions"></a>
522
-
523
- # `.app.exceptions`
524
-
525
- <a id="argenta.app.exceptions.NoRegisteredHandlersException"></a>
526
-
527
- ## NoRegisteredHandlersException Objects
528
-
529
- ```python
530
- class NoRegisteredHandlersException(Exception)
531
- ```
532
-
533
- The router has no registered handlers
534
-
535
- ---
536
-
537
- <a id="argenta.command.exceptions"></a>
538
-
539
- # `.command.exceptions`
540
-
541
- <a id="argenta.command.exceptions.BaseInputCommandException"></a>
542
-
543
- ## UnprocessedInputFlagException Objects
544
-
545
- ```python
546
- class UnprocessedInputFlagException(BaseInputCommandException)
547
- ```
548
-
549
- Private. Raised when an unprocessed input flag is detected
550
-
551
- ---
552
-
553
- <a id="argenta.command.exceptions.RepeatedInputFlagsException"></a>
554
-
555
- ## RepeatedInputFlagsException Objects
556
-
557
- ```python
558
- class RepeatedInputFlagsException(BaseInputCommandException)
559
- ```
560
-
561
- Private. Raised when repeated input flags are detected
562
-
563
- ---
564
-
565
- <a id="argenta.command.exceptions.EmptyInputCommandException"></a>
566
-
567
- ## EmptyInputCommandException Objects
568
-
569
- ```python
570
- class EmptyInputCommandException(BaseInputCommandException)
571
- ```
572
-
573
- Private. Raised when an empty input command is detected
574
-
575
- ---
576
-
577
- <a id="argenta.command.flag.defaults"></a>
578
-
579
- # `.command.flag.defaults`
580
-
581
- <a id="argenta.command.flag.defaults.PredefinedFlags"></a>
582
-
583
- ## PredefinedFlags Objects
584
-
585
- ```python
586
- @dataclass
587
- class PredefinedFlags()
588
- ```
589
-
590
- Public. A dataclass with predefined flags and most frequently used flags for quick use
591
-
592
- ---
593
-
594
- <a id="argenta.command.flag.models"></a>
595
-
596
- # `.command.flag`
597
-
598
- <a id="argenta.command.flag.models.InputFlag"></a>
599
-
600
- ## InputFlag Objects
601
-
602
- ```python
603
- class InputFlag(BaseFlag)
604
- ```
605
-
606
- <a id="argenta.command.flag.models.InputFlag.__init__"></a>
607
-
608
- #### \_\_init\_\_
609
-
610
- ```python
611
- def __init__(name: str,
612
- prefix: Literal['-', '--', '---'] = '--',
613
- value: str = None)
614
- ```
615
-
616
- Public. The entity of the flag of the entered command
617
-
618
- **Arguments**:
619
-
620
- - `name`: the name of the input flag
621
- - `prefix`: the prefix of the input flag
622
- - `value`: the value of the input flag
623
-
624
- **Returns**:
625
-
626
- `None`
627
-
628
- ---
629
-
630
- <a id="argenta.command.flag.models.InputFlag.get_value"></a>
631
-
632
- #### get\_value
633
-
634
- ```python
635
- def get_value() -> str | None
636
- ```
637
-
638
- Public. Returns the value of the flag
639
-
640
- **Returns**:
641
-
642
- the value of the flag as str
643
-
644
- ---
645
-
646
- <a id="argenta.command.flag.models.Flag"></a>
647
-
648
- ## Flag Objects
649
-
650
- ```python
651
- class Flag(BaseFlag)
652
- ```
653
-
654
- <a id="argenta.command.flag.models.Flag.__init__"></a>
655
-
656
- #### \_\_init\_\_
657
-
658
- ```python
659
- def __init__(name: str,
660
- prefix: Literal['-', '--', '---'] = '--',
661
- possible_values: list[str] | Pattern[str] | False = True) -> None
662
- ```
663
-
664
- Public. The entity of the flag being registered for subsequent processing
665
-
666
- **Arguments**:
667
-
668
- - `name`: The name of the flag
669
- - `prefix`: The prefix of the flag
670
- - `possible_values`: The possible values of the flag, if False then the flag cannot have a value
671
-
672
- **Returns**:
673
-
674
- `None`
675
-
676
- ---
677
-
678
- <a id="argenta/command/flag/models.Flags"></a>
679
-
680
- ## Flags Objects
681
-
682
- ```python
683
- class Flags(BaseFlags)
684
- ```
685
-
686
- <a id="argenta/command/flag/models.Flags.__init__"></a>
687
-
688
- #### \_\_init\_\_
689
-
690
- ```python
691
- def __init__(*flags: Flag)
692
- ```
693
-
694
- Public. A model that combines the registered flags
695
-
696
- **Arguments**:
697
-
698
- - `flags`: the flags that will be registered
699
-
700
- **Returns**:
701
-
702
- `None`
703
-
704
- ---
705
- <a id="argenta.command.flag.models.BaseFlags.get_flags"></a>
706
-
707
- #### get\_flags
708
-
709
- ```python
710
- def get_flags() -> list[Flag]
711
- ```
712
-
713
- Public. Returns a list of flags
714
-
715
- **Returns**:
716
-
717
- list of flags as list[Flag]
718
-
719
- ---
720
-
721
- <a id="argenta.command.flag.models.BaseFlags.add_flag"></a>
722
-
723
- #### add\_flag
724
-
725
- ```python
726
- def add_flag(flag: Flag) -> None
727
- ```
728
-
729
- Public. Adds a flag to the list of flags
730
-
731
- **Arguments**:
732
-
733
- - `flag`: flag to add
734
-
735
- **Returns**:
736
-
737
- `None`
738
-
739
- ---
740
-
741
- <a id="argenta.command.flag.models.BaseFlags.add_flags"></a>
742
-
743
- #### add\_flags
744
-
745
- ```python
746
- def add_flags(flags: list[Flag]) -> None
747
- ```
748
-
749
- Public. Adds a list of flags to the list of flags
750
-
751
- **Arguments**:
752
-
753
- - `flags`: list of flags to add
754
-
755
- **Returns**:
756
-
757
- `None`
758
-
759
- ---
760
-
761
- <a id="argenta.command.flag.models.BaseFlags.get_flag"></a>
762
-
763
- #### get\_flag
764
-
765
- ```python
766
- def get_flag(name: str) -> Flag | None
767
- ```
768
-
769
- Public. Returns the flag entity by its name or None if not found
770
-
771
- **Arguments**:
772
-
773
- - `name`: the name of the flag to get
774
-
775
- **Returns**:
776
-
777
- entity of the flag or None
778
-
779
- ---
780
-
781
- <a id="argenta/command/flag/models.InputFlags"></a>
782
-
783
- ## InputFlags Objects
784
-
785
- ```python
786
- class InputFlags(BaseFlags)
787
- ```
788
-
789
- <a id="argenta/command/flag/models.InputFlags.__init__"></a>
790
-
791
- #### \_\_init\_\_
792
-
793
- ```python
794
- def __init__(*flags: InputFlag)
795
- ```
796
-
797
- Public. A model that combines the input flags of the input command
798
-
799
- **Arguments**:
800
-
801
- - `flags`: all input flags
802
-
803
- **Returns**:
804
-
805
- `None`
806
-
807
- ---
808
-
809
- <a id="argenta.command.flag.models.BaseFlags.get_flags"></a>
810
-
811
- #### get\_flags
812
-
813
- ```python
814
- def get_flags() -> list[InputFlag]
815
- ```
816
-
817
- Public. Returns a list of flags
818
-
819
- **Returns**:
820
-
821
- list of flags
822
-
823
- ---
824
-
825
- <a id="argenta.command.flag.models.BaseFlags.add_flag"></a>
826
-
827
- #### add\_flag
828
-
829
- ```python
830
- def add_flag(flag: InputFlag) -> None
831
- ```
832
-
833
- Public. Adds a flag to the list of flags
834
-
835
- **Arguments**:
836
-
837
- - `flag`: flag to add
838
-
839
- **Returns**:
840
-
841
- `None`
842
-
843
- ---
844
-
845
- <a id="argenta.command.flag.models.BaseFlags.add_flags"></a>
846
-
847
- #### add\_flags
848
-
849
- ```python
850
- def add_flags(flags: list[InputFlag]) -> None
851
- ```
852
-
853
- Public. Adds a list of flags to the list of flags
854
-
855
- **Arguments**:
856
-
857
- - `flags`: list of flags to add
858
-
859
- **Returns**:
860
-
861
- `None`
862
-
863
- ---
864
-
865
- <a id="argenta.command.flag.models.BaseFlags.get_flag"></a>
866
-
867
- #### get\_flag
868
-
869
- ```python
870
- def get_flag(name: str) -> InputFlag
871
- ```
872
-
873
- Public. Returns the flag entity by its name or None if not found
874
-
875
- **Arguments**:
876
-
877
- - `name`: the name of the flag to get
878
-
879
- **Returns**:
880
-
881
- entity of the flag or None
882
-
883
- ---
884
-
885
- <a id="argenta.command.models"></a>
886
-
887
- # `.command.models`
888
-
889
- <a id="argenta.command.models.Command"></a>
890
-
891
- ## Command Objects
892
-
893
- ```python
894
- class Command(BaseCommand)
895
- ```
896
-
897
- <a id="argenta.command.models.Command.__init__"></a>
898
-
899
- #### \_\_init\_\_
900
-
901
- ```python
902
- def __init__(trigger: str,
903
- description: str = None,
904
- flags: Flag | Flags = None,
905
- aliases: list[str] = None)
906
- ```
907
-
908
- Public. The command that can and should be registered in the Router
909
-
910
- **Arguments**:
911
-
912
- - `trigger`: A string trigger, which, when entered by the user, indicates that the input corresponds to the command
913
- - `description`: the description of the command
914
- - `flags`: processed commands
915
- - `aliases`: string synonyms for the main trigger
916
-
917
- ---
918
-
919
- <a id="argenta.orchestrator.argparse.arguments.models"></a>
920
-
921
- # `.orchestrator.argparse.arguments`
922
-
923
- <a id="argenta.orchestrator.argparse.arguments.models.PositionalArgument"></a>
924
-
925
- ## PositionalArgument Objects
926
-
927
- ```python
928
- class PositionalArgument(BaseArgument)
929
- ```
930
-
931
- <a id="argenta.orchestrator.argparse.arguments.models.PositionalArgument.__init__"></a>
932
-
933
- #### \_\_init\_\_
934
-
935
- ```python
936
- def __init__(name: str)
937
- ```
938
-
939
- Public. Required argument at startup
940
-
941
- **Arguments**:
942
-
943
- - `name`: name of the argument, must not start with minus (-)
944
-
945
- ---
946
-
947
- <a id="argenta.orchestrator.argparse.arguments.models.OptionalArgument"></a>
948
-
949
- ## OptionalArgument Objects
950
-
951
- ```python
952
- class OptionalArgument(BaseArgument)
953
- ```
954
-
955
- <a id="argenta.orchestrator.argparse.arguments.models.OptionalArgument.__init__"></a>
956
-
957
- #### \_\_init\_\_
958
-
959
- ```python
960
- def __init__(name: str, prefix: Literal['-', '--', '---'] = '--')
961
- ```
962
-
963
- Public. Optional argument, must have the value
964
-
965
- **Arguments**:
966
-
967
- - `name`: name of the argument
968
- - `prefix`: prefix of the argument
969
-
970
- ---
971
-
972
- <a id="argenta.orchestrator.argparse.arguments.models.BooleanArgument"></a>
973
-
974
- ## BooleanArgument Objects
975
-
976
- ```python
977
- class BooleanArgument(BaseArgument)
978
- ```
979
-
980
- <a id="argenta.orchestrator.argparse.arguments.models.BooleanArgument.__init__"></a>
981
-
982
- #### \_\_init\_\_
983
-
984
- ```python
985
- def __init__(name: str,
986
- prefix: Literal['-', '--', '---'] = '--')
987
- ```
988
-
989
- Public. Boolean argument, does not require a value
990
-
991
- **Arguments**:
992
-
993
- - `name`: name of the argument
994
- - `prefix`: prefix of the argument
995
-
996
- ---
997
-
998
- <a id="argenta.orchestrator.argparse.entity"></a>
999
-
1000
- # `.orchestrator.argparser`
1001
-
1002
- <a id="argenta.orchestrator.argparse.entity.ArgParser"></a>
1003
-
1004
- ## ArgParse Objects
1005
-
1006
- ```python
1007
- class ArgParse()
1008
- ```
1009
-
1010
- <a id="argenta.orchestrator.argparse.entity.ArgParse.__init__"></a>
1011
-
1012
- #### \_\_init\_\_
1013
-
1014
- ```python
1015
- def __init__(processed_args: list[PositionalArgument | OptionalArgument | BooleanArgument],
1016
- name: str = 'Argenta',
1017
- description: str = 'Argenta available arguments',
1018
- epilog: str = 'github.com/koloideal/Argenta | made by kolo') -> None
1019
- ```
1020
-
1021
- Public. Cmd argument parser and configurator at startup
1022
-
1023
- **Arguments**:
1024
-
1025
- - `name`: the name of the ArgParse instance
1026
- - `description`: the description of the ArgParse instance
1027
- - `epilog`: the epilog of the ArgParse instance
1028
- - `processed_args`: registered and processed arguments
1029
-
1030
- ---
1031
-
1032
- <a id="argenta.orchestrator.argparse.entity.ArgParse.set_args"></a>
1033
-
1034
- #### set\_args
1035
-
1036
- ```python
1037
- def set_args(*args: PositionalArgument | OptionalArgument | BooleanArgument) -> None
1038
- ```
1039
-
1040
- Public. Sets the arguments to be processed
1041
-
1042
- **Arguments**:
1043
-
1044
- - `args`: processed arguments
1045
-
1046
- **Returns**:
1047
-
1048
- `None`
1049
-
1050
- ---
1051
-
1052
- # `.orchestrator`
1053
-
1054
- <a id="argenta.orchestrator.entity.Orchestrator"></a>
1055
-
1056
- ## Orchestrator Objects
1057
-
1058
- ```python
1059
- class Orchestrator()
1060
- ```
1061
-
1062
- <a id="argenta.orchestrator.entity.Orchestrator.__init__"></a>
1063
-
1064
- #### \_\_init\_\_
1065
-
1066
- ```python
1067
- def __init__(arg_parser: ArgParse = False)
1068
- ```
1069
-
1070
- Public. An orchestrator and configurator that defines the behavior of an integrated system, one level higher than the App
1071
-
1072
- **Arguments**:
1073
-
1074
- - `arg_parser`: Cmd argument parser and configurator at startup
1075
-
1076
- **Returns**:
1077
-
1078
- `None`
1079
-
1080
- ---
1081
-
1082
- <a id="argenta.orchestrator.entity.Orchestrator.start_polling"></a>
1083
-
1084
- #### start\_polling
1085
-
1086
- ```python
1087
- @staticmethod
1088
- def start_polling(app: App) -> None
1089
- ```
1090
-
1091
- Public. Starting the user input processing cycle
1092
-
1093
- **Arguments**:
1094
-
1095
- - `app`: a running application
1096
-
1097
- **Returns**:
1098
-
1099
- `None`
1100
-
1101
- ---
1102
-
1103
- <a id="argenta.orchestrator.entity.Orchestrator.get_input_args"></a>
1104
-
1105
- #### get\_input\_args
1106
-
1107
- ```python
1108
- def get_input_args() -> Namespace | None
1109
- ```
1110
-
1111
- Public. Returns the arguments parsed
1112
-
1113
- **Returns**:
1114
-
1115
- `None`
1116
-
1117
- ---
1118
-
1119
- <a id="argenta.router.entity"></a>
1120
-
1121
- # `.router`
1122
-
1123
- <a id="argenta.router.entity.Router"></a>
1124
-
1125
- ## Router Objects
1126
-
1127
- ```python
1128
- class Router()
1129
- ```
1130
-
1131
- <a id="argenta.router.entity.Router.__init__"></a>
1132
-
1133
- #### \_\_init\_\_
1134
-
1135
- ```python
1136
- def __init__(title: str = None)
1137
- ```
1138
-
1139
- Public. Directly configures and manages handlers
1140
-
1141
- **Arguments**:
1142
-
1143
- - `title`: the title of the router, displayed when displaying the available commands
1144
-
1145
- **Returns**:
1146
-
1147
- `None`
1148
-
1149
- ---
1150
-
1151
- <a id="argenta.router.entity.Router.command"></a>
1152
-
1153
- #### @command
1154
-
1155
- ```python
1156
- def command(command: Command) -> Callable
1157
- ```
1158
-
1159
- Public. Registers handler
1160
-
1161
- **Arguments**:
1162
-
1163
- - `command`: Registered command
1164
-
1165
- **Returns**:
1166
-
1167
- decorated handler as Callable[[Any], Any]
1168
-
1169
- ---
1170
-
1171
- <a id="argenta.router.entity.Router.set_invalid_input_flag_handler"></a>
1172
-
1173
- #### set\_invalid\_input\_flag\_handler
1174
-
1175
- ```python
1176
- def set_invalid_input_flag_handler(func) -> None
1177
- ```
1178
-
1179
- Public. Registers handler for invalid input flag
1180
-
1181
- **Arguments**:
1182
-
1183
- - `func`: registered handler
1184
-
1185
- **Returns**:
1186
-
1187
- `None`
1188
-
1189
- ---
1190
-
1191
- <a id="argenta.router.entity.Router.get_triggers"></a>
1192
-
1193
- #### get\_triggers
1194
-
1195
- ```python
1196
- def get_triggers() -> list[str]
1197
- ```
1198
-
1199
- Public. Gets registered triggers
1200
-
1201
- **Returns**:
1202
-
1203
- registered in router triggers as list[str]
1204
-
1205
- ---
1206
-
1207
- <a id="argenta.router.entity.Router.get_aliases"></a>
1208
-
1209
- #### get\_aliases
1210
-
1211
- ```python
1212
- def get_aliases() -> list[str]
1213
- ```
1214
-
1215
- Public. Gets registered aliases
1216
-
1217
- **Returns**:
1218
-
1219
- registered in router aliases as list[str]
1220
-
1221
- ---
1222
-
1223
- <a id="argenta.router.entity.Router.get_title"></a>
1224
-
1225
- #### get\_title
1226
-
1227
- ```python
1228
- def get_title() -> str | None
1229
- ```
1230
-
1231
- Public. Gets title of the router
1232
-
1233
- **Returns**:
1234
-
1235
- the title of the router as str or None
1236
-
1237
- ---
1238
-
1239
- <a id="argenta.router.entity.Router.set_title"></a>
1240
-
1241
- #### set\_title
1242
-
1243
- ```python
1244
- def set_title(title: str) -> None
1245
- ```
1246
-
1247
- Public. Sets the title of the router
1248
-
1249
- **Arguments**:
1250
-
1251
- - `title`: title that will be setted
1252
-
1253
- **Returns**:
1254
-
1255
- `None`
1256
-
1257
- ---
1258
-
1259
- <a id="argenta.router.exceptions"></a>
1260
-
1261
- # `.router.exceptions`
1262
-
1263
- <a id="argenta.router.exceptions.RepeatedFlagNameException"></a>
1264
-
1265
- ## RepeatedFlagNameException Objects
1266
-
1267
- ```python
1268
- class RepeatedFlagNameException(Exception)
1269
- ```
1270
-
1271
- Private. Raised when a repeated flag name is registered
1272
-
1273
- ---
1274
-
1275
- <a id="argenta.router.exceptions.TooManyTransferredArgsException"></a>
1276
-
1277
- ## TooManyTransferredArgsException Objects
1278
-
1279
- ```python
1280
- class TooManyTransferredArgsException(Exception)
1281
- ```
1282
-
1283
- Private. Raised when too many arguments are passed
1284
-
1285
- ---
1286
-
1287
- <a id="argenta.router.exceptions.RequiredArgumentNotPassedException"></a>
1288
-
1289
- ## RequiredArgumentNotPassedException Objects
1290
-
1291
- ```python
1292
- class RequiredArgumentNotPassedException(Exception)
1293
- ```
1294
-
1295
- Private. Raised when a required argument is not passed
1296
-
1297
- ---
1298
-
1299
- <a id="argenta.router.exceptions.IncorrectNumberOfHandlerArgsException"></a>
1300
-
1301
- ## IncorrectNumberOfHandlerArgsException Objects
1302
-
1303
- ```python
1304
- class IncorrectNumberOfHandlerArgsException(Exception)
1305
- ```
1306
-
1307
- Private. Raised when incorrect number of arguments are passed
1308
-
1309
- ---
1310
-
1311
- <a id="argenta.router.exceptions.TriggerContainSpacesException"></a>
1312
-
1313
- ## TriggerContainSpacesException Objects
1314
-
1315
- ```python
1316
- class TriggerContainSpacesException(Exception)
1317
- ```
1318
-
1319
- Private. Raised when there is a space in the trigger being registered
1320
-
1321
- <a id="argenta.router"></a>
1322
-
1323
- ---
1324
-
1325
- # Tests
1326
-
1327
- Run tests:
1328
-
1329
- ```bash
1330
- python -m unittest discover
1331
- ```
1332
- or
1333
- ```bash
1334
- python -m unittest discover -v
1335
- ```
1336
-
1337
- ---
1338
-
1339
- # made by kolo `MIT` `2025`
1340
-