You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Readme.md
+25-26Lines changed: 25 additions & 26 deletions
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ include support following field types:
20
20
21
21
Additional types could be supported by using `Register`, see [github.com/hujun-open/shouchantypes](https://github.com/hujun-open/shouchantypes) for example.
22
22
23
+
## curent release is `github.com/hujun-open/shouchan/v2`
24
+
23
25
## CLI & YAML Support
24
26
25
27
- YAML: shouchan uses [extyaml](https://pkg.go.dev/github.com/hujun-open/extyaml) for YAML marshal and unmarshal
@@ -35,30 +37,27 @@ Output:
35
37
36
38
- Usage
37
39
```
38
-
.\test.exe -?
39
-
flag provided but not defined: -?
40
+
.\test.exe --help
40
41
shouchan example
41
-
- addr: employee address
42
-
default:defAddrPointer
43
-
- employer-name: company name
44
-
default:defCom
45
-
- ipaddr: employee IP address
46
-
default:1.2.3.4
47
-
- jointtime: employee join time
48
-
default:2023-01-02 13:22:33
49
-
- mac: employee MAC address
50
-
default:11:22:33:44:55:66
51
-
- n2addr:
52
-
default:1.1.1.1
53
-
- naddr:
54
-
default:2.2.2.2
55
-
- name: employee name
56
-
default:defName
57
-
- subnet: employee IP subnet
58
-
default:192.168.1.0/24
59
-
60
-
-cfgfromfile: load configuration from the specified file
--employer-name string company name (default "defCom")
50
+
-h, --help help for example
51
+
--ipaddr net.IP employee IP address (default 1.2.3.4)
52
+
--jointtime time.Time employee join time (default 2023-01-02 13:22:33)
53
+
--mac net.HardwareAddr employee MAC address (default 11:22:33:44:55:66)
54
+
--n2addr (default 1.1.1.1)
55
+
--naddr (default 2.2.2.2)
56
+
--name string employee name (default "defName")
57
+
--r retired
58
+
--subnet net.IPNet employee IP subnet (default 192.168.1.0/24)
59
+
ferr failed to open config file test.yaml, open test.yaml: The system cannot find the file specified.,aerr <nil>
60
+
final result is &{Name:defName Addr:0xc000028ee0 Naddr:2.2.2.2 N2addr:1.1.1.1 IPAddr:1.2.3.4 Subnet:{IP:192.168.1.0 Mask:ffffff00} MAC:11:22:33:44:55:66 JointTime:2023-01-02 13:22:33 +0000 UTC IsRetired:false Employer:{Name:defCom}}
62
61
```
63
62
64
63
- no command line args, no config file, default is used
@@ -70,19 +69,19 @@ final result is &{Name:defName Addr:0xc0000528b0 Naddr:2.2.2.2 N2addr:1.1.1.1 IP
70
69
71
70
- config file via "-f" command args, value from file take procedence
72
71
```
73
-
.\test.exe -cfgfromfile cfg.yaml
72
+
.\test.exe --cfgfromfile cfg.yaml
74
73
ferr <nil>,aerr <nil>
75
74
final result is &{Name:nameFromFile Addr:0xc0000528b0 Naddr:2.2.2.2 N2addr:1.1.1.1 IPAddr:1.2.3.4 Subnet:{IP:192.168.1.0 Mask:ffffff00} MAC:11:22:33:44:55:66 JointTime:2023-01-02 13:22:33 +0000 UTC Employer:{Name:comFromFile}}
76
75
```
77
76
- mix command line args and config file, args to override employee name:
final result is &{Name:nameFromArg Addr:0xc000088880 Naddr:2.2.2.2 N2addr:1.1.1.1 IPAddr:1.2.3.4 Subnet:{IP:192.168.1.0 Mask:ffffff00} MAC:11:22:33:44:55:66 JointTime:2023-01-02 13:22:33 +0000 UTC Employer:{Name:comFromFile}}
82
81
```
83
82
- mix command line args and config file, args to override company name:
final result is &{Name:nameFromFile Addr:0xc000104880 Naddr:2.2.2.2 N2addr:1.1.1.1 IPAddr:1.2.3.4 Subnet:{IP:192.168.1.0 Mask:ffffff00} MAC:11:22:33:44:55:66 JointTime:2023-01-02 13:22:33 +0000 UTC Employer:{Name:comFromArg}}
0 commit comments