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
@@ -96,9 +96,14 @@ v2 is in earlier state but the baseline is stable:
96
96
- extensible codecs and providers for loading from data sources
97
97
98
98
- Three kinds of config files are searched and loaded via `loaders.NewConfigFileLoader()`:
99
-
- Primary: main config, shipped with installable package.
100
-
- Secondary: 2ndry config. Wrapped by reseller(s).
101
-
- Alternative: user's local config, writeable. The runtime changeset will be written back to this file while app stopping.
99
+
1.__Primary__: main config, shipped with installable package.
100
+
2.__Secondary__: 2ndry config. Wrapped by reseller(s).
101
+
3.__Alternative__: user's local config, writeable. The runtime changeset will be written back to this file while app stopping.
102
+
103
+
- Variety of approaches for building command system with attached flags
104
+
1. traditional stream calls (`app.Cmd("verbose", "v").Action(onVerbose)`)
105
+
2. concise modes by [`Create`](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) and cmd/xxcmd.go
106
+
3. use [`Create.BuildFrom`](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) to build cmdsys from a struct value via `[App.FromStruct]`, see example [#example_Create_buildFromStructValue](https://pkg.go.dev/github.com/hedzr/cmdr/v2/#example_Create_buildFromStructValue); or, attaching subcmds and flags to a subcmd by `app.Cmd().FromStruct(&root{})` following any traditional calls.
@@ -114,38 +119,56 @@ v2 is in earlier state but the baseline is stable:
114
119
[^3]: `hedzr/logg` provides a slog like and colorful logging library
115
120
[^4]: `hedzr/is` is a basic environ detectors library
116
121
117
-
Getting started from [New](https://pkg.go.dev/github.com/hedzr/cmdr/v2#New) or [Create](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) function.
118
-
119
122
More minor details need to be evaluated and reimplemented if it's still meaningful in v2.
120
123
121
-
### cmdr-loaders
124
+
### News
125
+
126
+
Getting started from [New](https://pkg.go.dev/github.com/hedzr/cmdr/v2#New) or [Create](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) function, and see the quickstart docs at [Concise Version - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/g02-concise-version/) and [Step by step - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/steps/).
122
127
123
128
Since v2.0.3, loaders had been splitted as a standalone repo so that we can keep cmdr v2 smaller and independer. See the relevant subproject [cmdr-loaders](https://github.com/hedzr/cmdr-loaders)[^5].
124
129
125
130
Since v2.1.12, we did main alternative features like autocompletion generating, manpage reading and generating, and made quite a lot of fixes and improvments. Now the main APIs come to stable.
126
131
127
-
Since v2.1.26, we added `App.FromStruct(structValue, opts...)` to build the command system from a struct-value, which deconstructs the given struct's definitions and constrcts the cmd-sys. For more detail, see also []
132
+
Since v2.1.26, we added `App.FromStruct(structValue, opts...)` to build the command system from a struct-value, which deconstructs the given struct's definitions and constrcts the cmd-sys. And we also added `App.Cmd().FromStruct(&root{})` to build for a subcmd in a later release. Now the parsed cmdline args will be written into your struct value. For more detail, see also [From struct-value and Tag - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/steps/g13-build-from-struct/)
128
133
129
134
The full-functional tests and examples are moved into [cmdr-tests](https://github.com/hedzr/cmdr-tests).
130
135
131
136
[^5]: `hedzr/cmdr-loaders` provides an external config file loaders with GNU File Standard supports.
132
137
133
138
## History
134
139
135
-
v2.1 is a stable version:
140
+
v2.2 would be a stable version:
136
141
137
142
- v2.2.0 PLANNED: the final stable version for v2.
138
143
- v2.1.x: preview version for the new APIs.
139
144
- Full list: [CHANGELOG](https://github.com/hedzr/cmdr/blob/master/CHANGELOG)
140
145
141
146
## Guide
142
147
148
+
Please go to our docsite for these pages:
149
+
150
+
-[Concise Version - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/g02-concise-version/)
151
+
-[Step by step - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/steps/)
152
+
- ...
153
+
143
154
You can build command system by kinds of forms:
144
155
145
-
-traditional stream calls from `[New()](https://pkg.go.dev/github.com/hedzr/cmdr/v2#New)` (`cmdr.New().Cmd("verbose", "v").Action(onVerbose)`)
146
-
-concise modes by `[Create()](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create)` and cmd/xxcmd.go
147
-
-use `[Create().BuildFrom()](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create)` to build cmdsys from a struct value via `[App.FromStruct()](https://pkg.go.dev/github.com/hedzr/cmdr/v2/cli#App)`, see example [#example_Create_buildFromStructValue](https://pkg.go.dev/github.com/hedzr/cmdr/v2/#example_Create_buildFromStructValue)
2.concise modes by [`Create`](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) and cmd/xxcmd.go
158
+
3.use [`Create.BuildFrom`](https://pkg.go.dev/github.com/hedzr/cmdr/v2#Create) to build cmdsys from a struct value via `[App.FromStruct]`, see example [#example_Create_buildFromStructValue](https://pkg.go.dev/github.com/hedzr/cmdr/v2/#example_Create_buildFromStructValue); or, attaching subcmds and flags to a subcmd by `app.Cmd().FromStruct(&root{})` following any traditional calls.
148
159
160
+
### Traditional style
161
+
162
+
```go
163
+
app.Cmd("soundex", "snd", "sndx", "sound").
164
+
Description("soundex test").
165
+
Group("Test").
166
+
TailPlaceHolders("[text1, text2, ...]").
167
+
OnAction(soundex).
168
+
Build()
169
+
```
170
+
171
+
### Concise version
149
172
150
173
A typical cli-app can be (its concise version at [examples/tiny/concise/main.go](https://github.com/hedzr/cmdr/blob/master/examples/tiny/concise/main.go)):
For the detail, or check out its bindable version, go to [From struct-value and Tag - hzDocs](https://docs.hedzr.com/en/docs/cmdr.v2/guide/steps/g13-build-from-struct/).
430
+
431
+
### Next Step
432
+
295
433
More examples please go to [cmdr-tests/examples](https://github.com/hedzr/cmdr-tests/tree/master/examples).
0 commit comments