Skip to content

Commit 130a5bf

Browse files
committed
Update README.md
1 parent 4fe7c7a commit 130a5bf

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,26 @@ $ python cli.py Alex --age 35 --greet
5656
Hello Alex (35)!
5757
```
5858

59+
Alternatively, you can also use `Radicli.call`:
60+
61+
```python
62+
# cli.py
63+
from radicli import Radicli, Arg
64+
65+
def hello(name: str, age: int):
66+
print(f"Hello {name} ({age})!")
67+
68+
if __name__ == "__main__":
69+
args = dict(name=Arg(help="Your name"), age=Arg("--age", "-a", help="Your age"))
70+
command = Command.from_function("hello", args, hello)
71+
Radicli().call(command)
72+
```
73+
74+
```
75+
$ python cli.py Alex --age 35
76+
Hello Alex (35)!
77+
```
78+
5979
### Subcommands
6080

6181
`radicli` supports one level of nested subcommands. The parent command may exist independently, but it doesn't have to.

0 commit comments

Comments
 (0)