File tree Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Expand file tree Collapse file tree 3 files changed +50
-1
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,34 @@ Argument parser based on pydantic v2.
8
8
pip install pydantic-argparse-next
9
9
```
10
10
11
+ ### Base usage:
12
+
13
+ #
14
+
15
+ ``` python
16
+ from pydantic import BaseModel, Field
17
+ import pydantic_argparse_next as pa
18
+
19
+
20
+ class Temp (BaseModel ):
21
+ # Positional arguments
22
+ a: str = pa.Arg(description = " This is a required positional argument." )
23
+ b: str = pa.Arg(" defalut_value" , description = " This is a OPTIONAL positional argument." )
24
+
25
+ # Keyword arguments
26
+ # Simple attributes or pydantic.Field are keyword arguments.
27
+ c: str
28
+ d: str = Field(None , description = " This is a OPTIONAL keyword argument." )
29
+ e: str = pa.KwArg(description = " This is a required keyword argument." )
30
+ ```
31
+
32
+ ```
33
+ Input: appname "test1" --c "test2" --e="test3"
34
+ Output: a='test1' b='defalut_value' c='test2' d=None e='test3'
35
+ ```
36
+
37
+ ** More details in the documentation**
38
+
11
39
### Supports:
12
40
13
41
✅ Positional arguments
@@ -46,6 +74,8 @@ pip install pydantic-argparse-next
46
74
47
75
⬜ Easy load config from file
48
76
77
+ ** More details in the documentation**
78
+
49
79
### Docs and examples:
50
80
51
81
1 . [ Base usage] ( https://github.com/overgodofchaos/pydantic-argparse-next/blob/main/docs/BaseUsage.md )
Original file line number Diff line number Diff line change
1
+ from pydantic import BaseModel , Field
2
+ import pydantic_argparse_next as pa
3
+
4
+
5
+ class Temp (BaseModel ):
6
+ # Positional arguments
7
+ a : str = pa .Arg (description = "This is a required positional argument." )
8
+ b : str = pa .Arg ("defalut_value" , description = "This is a OPTIONAL positional argument." )
9
+
10
+ # Keyword arguments
11
+ # Simple attributes or pydantic.Field are keyword arguments.
12
+ c : str
13
+ d : str = Field (None , description = "This is a OPTIONAL keyword argument." )
14
+ e : str = pa .KwArg (description = "This is a required keyword argument." )
15
+
16
+
17
+ cliargs = pa .parse (Temp , program_name = "Example program" , description = "The example program description" )
18
+
19
+ print (cliargs )
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
5
5
[project ]
6
6
name = " pydantic-argparse-next"
7
- version = " 1.0.4 "
7
+ version = " 1.0.5 "
8
8
description = " Pydantic 2 argparse."
9
9
readme = " README.md"
10
10
requires-python = " >=3.11"
You can’t perform that action at this time.
0 commit comments