1
1
# Why ` arguably ` ?
2
2
3
- With plenty of other tools out there, why use ` arguably ` ? Aren't ` click ` and ` typer ` good enough?
3
+ With plenty of other tools out there, why use ` arguably ` ? Aren't other ones ( ` click ` , ` typer ` , etc) good enough?
4
4
5
- The short answer is: yeah, probably! They're really great tools. But they still make you write quite a bit of code.
6
- That's where ` arguably ` comes in.
5
+ The short answer is: yeah, probably! Python already has great tools for building CLIs . But they still make you write
6
+ quite a bit of code. That's where ` arguably ` comes in.
7
7
8
8
## An unobtrusive API
9
9
10
- What ` arguably ` does best is get out of your way. Set up a function signature and docstring, annotate with
11
- ` @arguably.command ` , and you've set up a CLI. That's it, that's the API. No need for ` typer.Option() ` or
12
- ` click.option() ` . That's because ` arguably ` was built from the ground-up with a focus on providing most of the features
13
- of these libraries (and a few extra) with few code changes necessary on your part.
10
+ What ` arguably ` does best is get out of your way.
14
11
15
- Your decorated functions still look and behave like regular functions.
12
+ Set up a * function signature* and * docstring* , annotate with ` @arguably.command ` , and you've set up a CLI. That's it,
13
+ that's the API.
14
+
15
+ No need for ` typer.Option() ` or ` click.option() ` . That's because ` arguably ` was built from the ground-up with a focus on
16
+ providing most of the features of these libraries (and a few extra) with few code changes necessary on your part.
17
+ Because of this, your CLI functions still look and behave like regular functions.
16
18
17
19
<div align =" right " class =" code-source " ><sub >
18
20
<a href="https://github.com/treykeown/arguably/blob/main/etc/scripts/intro.py">[source]</a>
@@ -39,12 +41,6 @@ if __name__ == "__main__":
39
41
arguably.run()
40
42
```
41
43
42
- ``` pycon
43
- >>> from intro import some_function
44
- >>> some_function(" asdf" , 0 , 7 , 8 , 9 , option = 2.71 )
45
- required='asdf', not_required=0, others=(7, 8, 9), option=2.71
46
- ```
47
-
48
44
``` console
49
45
user@machine:~ $ ./intro.py -h
50
46
usage: intro.py [-h] [-x OPTION] required [not-required] [others ...]
@@ -61,6 +57,17 @@ options:
61
57
-x, --option OPTION an option, short name is in brackets (type: float, default: 3.14)
62
58
```
63
59
60
+ ``` pycon
61
+ >>> from intro import some_function
62
+ >>> some_function(" asdf" , 0 , 7 , 8 , 9 , option = 2.71 )
63
+ required='asdf', not_required=0, others=(7, 8, 9), option=2.71
64
+ ```
65
+
66
+ ``` console
67
+ user@machine:~ $ ./intro.py " asdf" 0 7 8 9 --option 2.71
68
+ required='asdf', not_required=0, others=(7, 8, 9), option=2.71
69
+ ```
70
+
64
71
## Zero-effort CLI
65
72
66
73
Taking inspiration from [ Python Fire] ( https://google.github.io/python-fire/guide/#version-4-fire-without-code-changes ) ,
0 commit comments