blob: 22dca968bb9094cc8ea9184ba1af9057a581e4bc [file] [log] [blame] [view]
Matthew Maurer32e76692020-06-02 11:15:15 -07001# v0.3.14 (2020-04-22)
2
3* Minor documentation improvements.
4
5# v0.3.13 (2020-04-9)
6
7* Bump `proc-macro-error` to `1.0`.
8
9# v0.3.12 (2020-03-18)
10
11* Fixed [bug in `external_subcommand`](https://github.com/TeXitoi/structopt/issues/359).
12
13# v0.3.11 (2020-03-01)
14
15* `syn`'s "full" feature is now explicitly enabled. It must have been, but hasn't.
16
17# v0.3.10 (2020-03-01) - YANKED
18
19* Fixed the breakage due to a required `syn` feature was not enabled.
20
21# v0.3.9 (2020-02-01) - YANKED
22
23* `clippy` warnings triggered by generated code shall not annoy you anymore!
24 Except for those from `clippy::correctness`, these lints are useful even
25 for auto generated code.
26* Improved error messages.
27
28# v0.3.8 (2020-1-19) - YANKED
29
30* You don't have to apply `#[no_version]` to every `enum` variant anymore.
31 Just annotate the `enum` and the setting will be propagated down
32 ([#242](https://github.com/TeXitoi/structopt/issues/242)).
33* [Auto-default](https://docs.rs/structopt/0.3/structopt/#default-values).
34* [External subcommands](https://docs.rs/structopt/0.3/structopt/#external-subcommands).
35* [Flattening subcommands](https://docs.rs/structopt/0.3.8/structopt/#flattening-subcommands).
36
37# v0.3.7 (2019-12-28)
38
39Nothing's new. Just re-release of `v0.3.6` due to
40[the mess with versioning](https://github.com/TeXitoi/structopt/issues/315#issuecomment-568502792).
41
42You may notice that `structopt-derive` was bumped to `v0.4.0`, that's OK, it's not a breaking change.
43`structopt` will pull the right version in on its on.
44
45# v0.3.6 (2019-12-22) - YANKED
46
47This is unusually big patch release. It contains a number of bugfixes and
48new features, some of them may theoretically be considered breaking. We did our best
49to avoid any problems on user's side but, if it wasn't good enough, please
50[file an issue ASAP](https://github.com/TeXitoi/structopt/issues).
51
52## Bugfixes
53
54* `structopt` used to treat `::path::to::type::Vec<T>` as `Vec<T>`
55 special type. [This was considered erroneous](https://github.com/TeXitoi/structopt/pull/287).
56 (same for `Option<T>` and `bool`). Now only exact `Vec<T>` match is a special type.
57
58* `#[structopt(version = expr)]` where `expr` is not a string literal used to get
59 overridden by auto generated `.version()` call,
60 [incorrectly](https://github.com/TeXitoi/structopt/issues/283). Now it doesn't.
61
62* Fixed bug with top-level `App::*` calls on multiple `struct`s, see
63 [#289](https://github.com/TeXitoi/structopt/issues/265).
64
65* Positional `bool` args with no explicit `#[structopt(parse(...))]` annotation are
66 now prohibited. This couldn't work well anyway, see
67 [this example](https://github.com/TeXitoi/structopt/blob/master/examples/true_or_false.rs)
68 for details.
69
70* Now we've instituted strict priority between doc comments, about, help, and the like.
71 See [the documentation](https://docs.rs/structopt/0.3/structopt/#help-messages).
72
73 **HUGE THANKS to [`@ssokolow`](https://github.com/ssokolow)** for tidying up our documentation,
74 teaching me English and explaining why our doc used to suck. I promise I'll make the rest
75 of the doc up to your standards... sometime later!
76
77## New features
78
79* Implement `StructOpt` for `Box<impl StructOpt>` so from now on you can use `Box<T>`
80 with `flatten` and `subcommand` ([#304](https://github.com/TeXitoi/structopt/issues/304)).
81
82 ```rust
83 enum Command {
84 #[structopt(name = "version")]
85 PrintVersion,
86
87 #[structopt(name = "second")]
88 DoSomething {
89 #[structopt(flatten)]
90 config: Box<DoSomethingConfig>,
91 },
92
93 #[structopt(name = "first")]
94 DoSomethingElse {
95 #[structopt(flatten)]
96 config: Box<DoSomethingElseConfig>,
97 }
98 }
99 ```
100
101* Introduced `#[structopt(verbatim_doc_comment)]` attribute that keeps line breaks in
102 doc comments, see
103 [the documentation](https://docs.rs/structopt/0.3/structopt/#doc-comment-preprocessing-and-structoptverbatim_doc_comment).
104
105* Introduced `#[structopt(rename_all_env)]` and `#[structopt(env)]` magical methods
106 so you can derive env var's name from field's name. See
107 [the documentation](https://docs.rs/structopt/0.3/structopt/#auto-deriving-environment-variables).
108
109## Improvements
110
111* Now we have nice README for our examples,
112 [check it out](https://github.com/TeXitoi/structopt/tree/master/examples)!
113
114* Some error messages were improved and clarified, thanks for all people involved!
115
116
117# v0.3.5 (2019-11-22)
118
119* `try_from_str` functions are now called with a `&str` instead of a `&String` ([#282](https://github.com/TeXitoi/structopt/pull/282))
120
121# v0.3.4 (2019-11-08)
122
123* `rename_all` does not apply to fields that were annotated with explicit
124 `short/long/name = "..."` anymore ([#265](https://github.com/TeXitoi/structopt/issues/265))
125* Now raw idents are handled correctly ([#269](https://github.com/TeXitoi/structopt/issues/269))
126* Some documentation improvements and clarification.
127
128# v0.3.3 (2019-10-10)
129
130* Add `from_flag` custom parser to create flags from non-bool types.
131 Fixes [#185](https://github.com/TeXitoi/structopt/issues/185)
132
133# v0.3.2 (2019-09-18)
134
135* `structopt` does not replace `:` with `, ` inside "author" strings while inside `<...>`.
136 Fixes [#156](https://github.com/TeXitoi/structopt/issues/156)
137* Introduced [`#[structopt(skip = expr)]` syntax](https://docs.rs/structopt/0.3.2/structopt/#skipping-fields).
138
139# v0.3.1 (2019-09-06)
140
141* Fix error messages ([#241](https://github.com/TeXitoi/structopt/issues/241))
142* Fix "`skip` plus long doc comment" bug ([#245](https://github.com/TeXitoi/structopt/issues/245))
143* Now `structopt` emits dummy `StructOpt` implementation along with an error. It suppresses
144 meaningless errors like `from_args method is not found for Opt`
145* `.version()` not get generated if `CARGO_PKG_VERSION` is not set anymore.
146
147# v0.3.0 (2019-08-30)
148
149## Breaking changes
150
151### Bump minimum rustc version to 1.36 by [@TeXitoi](https://github.com/TeXitoi)
152Now `rustc` 1.36 is the minimum compiler version supported by `structopt`,
153it likely won't work with older compilers.
154
155### Remove "nightly" feature
156Once upon a time this feature had been used to enable some of improvements
157in `proc-macro2` crate that were available only on nightly. Nowadays this feature doesn't
158mean anything so it's now removed.
159
160### Support optional vectors of arguments for distinguishing between `-o 1 2`, `-o` and no option provided at all by [@sphynx](https://github.com/sphynx) ([#180](https://github.com/TeXitoi/structopt/issues/188)).
161
162```rust
163#[derive(StructOpt)]
164struct Opt {
165 #[structopt(long)]
166 fruit: Option<Vec<String>>,
167}
168
169fn main() {
170 assert_eq!(Opt::from_args(&["test"]), None);
171 assert_eq!(Opt::from_args(&["test", "--fruit"]), Some(vec![]));
172 assert_eq!(Opt::from_args(&["test", "--fruit=apple orange"]), Some(vec!["apple", "orange"]));
173}
174```
175
176If you need to fall back to the old behavior you can use a type alias:
177```rust
178type Something = Vec<String>;
179
180#[derive(StructOpt)]
181struct Opt {
182 #[structopt(long)]
183 fruit: Option<Something>,
184}
185```
186
187### Change default case from 'Verbatim' into 'Kebab' by [@0ndorio](https://github.com/0ndorio) ([#202](https://github.com/TeXitoi/structopt/issues/202)).
188`structopt` 0.3 uses field renaming to deduce a name for long options and subcommands.
189
190```rust
191#[derive(StructOpt)]
192struct Opt {
193 #[structopt(long)]
194 http_addr: String, // will be renamed to `--http-addr`
195
196 #[structopt(subcommand)]
197 addr_type: AddrType // this adds `addr-type` subcommand
198}
199```
200
201`structopt` 0.2 used to leave things "as is", not renaming anything. If you want to keep old
202behavior add `#[structopt(rename_all = "verbatim")]` on top of a `struct`/`enum`.
203
204### Change `version`, `author` and `about` attributes behavior.
205Proposed by [@TeXitoi](https://github.com/TeXitoi) [(#217)](https://github.com/TeXitoi/structopt/issues/217), implemented by [@CreepySkeleton](https://github.com/CreepySkeleton) [(#229)](https://github.com/TeXitoi/structopt/pull/229).
206
207`structopt` have been deducing `version`, `author`, and `about` properties from `Cargo.toml`
208for a long time (more accurately, from `CARGO_PKG_...` environment variables).
209But many users found this behavior somewhat confusing, and a hack was added to cancel out
210this behavior: `#[structopt(author = "")]`.
211
212In `structopt` 0.3 this has changed.
213* `author` and `about` are no longer deduced by default. You should use `#[structopt(author, about)]`
214 to explicitly request `structopt` to deduce them.
215* Contrary, `version` **is still deduced by default**. You can use `#[structopt(no_version)]` to
216 cancel it out.
217* `#[structopt(author = "", about = "", version = "")]` is no longer a valid syntax
218 and will trigger an error.
219* `#[structopt(version = "version", author = "author", about = "about")]` syntax
220 stays unaffected by this changes.
221
222### Raw attributes are removed ([#198](https://github.com/TeXitoi/structopt/pull/198)) by [@sphynx](https://github.com/sphynx)
223In `structopt` 0.2 you were able to use any method from `clap::App` and `clap::Arg` via
224raw attribute: `#[structopt(raw(method_name = "arg"))]`. This syntax was kind of awkward.
225
226```rust
227#[derive(StructOpt, Debug)]
228#[structopt(raw(
229 global_settings = "&[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands]"
230))]
231struct Opt {
232 #[structopt(short = "l", long = "level", raw(aliases = r#"&["set-level", "lvl"]"#))]
233 level: Vec<String>,
234}
235```
236
237Raw attributes were removed in 0.3. Now you can use any method from `App` and `Arg` *directly*:
238```rust
239#[derive(StructOpt)]
240#[structopt(global_settings(&[AppSettings::ColoredHelp, AppSettings::VersionlessSubcommands]))]
241struct Opt {
242 #[structopt(short = "l", long = "level", aliases(&["set-level", "lvl"]))]
243 level: Vec<String>,
244}
245```
246
247## Improvements
248
249### Support skipping struct fields
250Proposed by [@Morganamilo](https://github.com/Morganamilo) in ([#174](https://github.com/TeXitoi/structopt/issues/174))
251implemented by [@sphynx](https://github.com/sphynx) in ([#213](https://github.com/TeXitoi/structopt/issues/213)).
252
253Sometimes you want to include some fields in your `StructOpt` `struct` that are not options
254and `clap` should know nothing about them. In `structopt` 0.3 it's possible via the
255`#[structopt(skip)]` attribute. The field in question will be assigned with `Default::default()`
256value.
257
258```rust
259#[derive(StructOpt)]
260struct Opt {
261 #[structopt(short, long)]
262 speed: f32,
263
264 car: String,
265
266 // this field should not generate any arguments
267 #[structopt(skip)]
268 meta: Vec<u64>
269}
270```
271
272### Add optional feature to support `paw` by [@gameldar](https://github.com/gameldar) ([#187](https://github.com/TeXitoi/structopt/issues/187))
273
274### Significantly improve error reporting by [@CreepySkeleton](https://github.com/CreepySkeleton) ([#225](https://github.com/TeXitoi/structopt/pull/225/))
275Now (almost) every error message points to the location it originates from:
276
277```text
278error: default_value is meaningless for bool
279 --> $DIR/bool_default_value.rs:14:24
280 |
28114 | #[structopt(short, default_value = true)]
282 | ^^^^^^^^^^^^^
283```
284
285# v0.2.16 (2019-05-29)
286
287### Support optional options with optional argument, allowing `cmd [--opt[=value]]` by [@sphynx](https://github.com/sphynx) ([#188](https://github.com/TeXitoi/structopt/issues/188))
288Sometimes you want to represent an optional option that optionally takes an argument,
289i.e `[--opt[=value]]`. This is represented by `Option<Option<T>>`
290
291```rust
292#[derive(StructOpt)]
293struct Opt {
294 #[structopt(long)]
295 fruit: Option<Option<String>>,
296}
297
298fn main() {
299 assert_eq!(Opt::from_args(&["test"]), None);
300 assert_eq!(Opt::from_args(&["test", "--fruit"]), Some(None));
301 assert_eq!(Opt::from_args(&["test", "--fruit=apple"]), Some("apple"));
302}
303```
304
305# v0.2.15 (2019-03-08)
306
307* Fix [#168](https://github.com/TeXitoi/structopt/issues/168) by [@TeXitoi](https://github.com/TeXitoi)
308
309# v0.2.14 (2018-12-10)
310
311* Introduce smarter parsing of doc comments by [@0ndorio](https://github.com/0ndorio)
312
313# v0.2.13 (2018-11-01)
314
315* Automatic naming of fields and subcommands by [@0ndorio](https://github.com/0ndorio)
316
317# v0.2.12 (2018-10-11)
318
319* Fix minimal clap version by [@TeXitoi](https://github.com/TeXitoi)
320
321# v0.2.11 (2018-10-05)
322
323* Upgrade syn to 0.15 by [@konstin](https://github.com/konstin)
324
325# v0.2.10 (2018-06-07)
326
327* 1.21.0 is the minimum required rustc version by
328 [@TeXitoi](https://github.com/TeXitoi)
329
330# v0.2.9 (2018-06-05)
331
332* Fix a bug when using `flatten` by
333 [@fbenkstein](https://github.com/fbenkstein)
334* Update syn, quote and proc_macro2 by
335 [@TeXitoi](https://github.com/TeXitoi)
336* Fix a regression when there is multiple authors by
337 [@windwardly](https://github.com/windwardly)
338
339# v0.2.8 (2018-04-28)
340
341* Add `StructOpt::from_iter_safe()`, which returns an `Error` instead of
342 killing the program when it fails to parse, or parses one of the
343 short-circuiting flags. ([#98](https://github.com/TeXitoi/structopt/pull/98)
344 by [@quodlibetor](https://github.com/quodlibetor))
345* Allow users to enable `clap` features independently by
346 [@Kerollmops](https://github.com/Kerollmops)
347* Fix a bug when flattening an enum
348 ([#103](https://github.com/TeXitoi/structopt/pull/103) by
349 [@TeXitoi](https://github.com/TeXitoi)
350
351# v0.2.7 (2018-04-12)
352
353* Add flattening, the insertion of options of another StructOpt struct
354 into another ([#92](https://github.com/TeXitoi/structopt/pull/92))
355 by [@birkenfeld](https://github.com/birkenfeld)
356* Fail compilation when using `default_value` or `required` with
357 `Option` ([#88](https://github.com/TeXitoi/structopt/pull/88)) by
358 [@Kerollmops](https://github.com/Kerollmops)
359
360# v0.2.6 (2018-03-31)
361
362* Fail compilation when using `default_value` or `required` with `bool` ([#80](https://github.com/TeXitoi/structopt/issues/80)) by [@TeXitoi](https://github.com/TeXitoi)
363* Fix compilation with `#[deny(warnings)]` with the `!` type (https://github.com/rust-lang/rust/pull/49039#issuecomment-376398999) by [@TeXitoi](https://github.com/TeXitoi)
364* Improve first example in the documentation ([#82](https://github.com/TeXitoi/structopt/issues/82)) by [@TeXitoi](https://github.com/TeXitoi)
365
366# v0.2.5 (2018-03-07)
367
368* Work around breakage when `proc-macro2`'s nightly feature is enabled. ([#77](https://github.com/Texitoi/structopt/pull/77) and [proc-macro2#67](https://github.com/alexcrichton/proc-macro2/issues/67)) by [@fitzgen](https://github.com/fitzgen)
369
370# v0.2.4 (2018-02-25)
371
372* Fix compilation with `#![deny(missig_docs]` ([#74](https://github.com/TeXitoi/structopt/issues/74)) by [@TeXitoi](https://github.com/TeXitoi)
373* Fix [#76](https://github.com/TeXitoi/structopt/issues/76) by [@TeXitoi](https://github.com/TeXitoi)
374* Re-licensed to Apache-2.0/MIT by [@CAD97](https://github.com/cad97)
375
376# v0.2.3 (2018-02-16)
377
378* An empty line in a doc comment will result in a double linefeed in the generated about/help call by [@TeXitoi](https://github.com/TeXitoi)
379
380# v0.2.2 (2018-02-12)
381
382* Fix [#66](https://github.com/TeXitoi/structopt/issues/66) by [@TeXitoi](https://github.com/TeXitoi)
383
384# v0.2.1 (2018-02-11)
385
386* Fix a bug around enum tuple and the about message in the global help by [@TeXitoi](https://github.com/TeXitoi)
387* Fix [#65](https://github.com/TeXitoi/structopt/issues/65) by [@TeXitoi](https://github.com/TeXitoi)
388
389# v0.2.0 (2018-02-10)
390
391## Breaking changes
392
393### Don't special case `u64` by [@SergioBenitez](https://github.com/SergioBenitez)
394
395If you are using a `u64` in your struct to get the number of occurence of a flag, you should now add `parse(from_occurrences)` on the flag.
396
397For example
398```rust
399#[structopt(short = "v", long = "verbose")]
400verbose: u64,
401```
402must be changed by
403```rust
404#[structopt(short = "v", long = "verbose", parse(from_occurrences))]
405verbose: u64,
406```
407
408This feature was surprising as shown in [#30](https://github.com/TeXitoi/structopt/issues/30). Using the `parse` feature seems much more natural.
409
410### Change the signature of `Structopt::from_clap` to take its argument by reference by [@TeXitoi](https://github.com/TeXitoi)
411
412There was no reason to take the argument by value. Most of the StructOpt users will not be impacted by this change. If you are using `StructOpt::from_clap`, just add a `&` before the argument.
413
414### Fail if attributes are not used by [@TeXitoi](https://github.com/TeXitoi)
415
416StructOpt was quite fuzzy in its attribute parsing: it was only searching for interresting things, e. g. something like `#[structopt(foo(bar))]` was accepted but not used. It now fails the compilation.
417
418You should have nothing to do here. This breaking change may highlight some missuse that can be bugs.
419
420In future versions, if there is cases that are not highlighed, they will be considerated as bugs, not breaking changes.
421
422### Use `raw()` wrapping instead of `_raw` suffixing by [@TeXitoi](https://github.com/TeXitoi)
423
424The syntax of raw attributes is changed to improve the syntax.
425
426You have to change `foo_raw = "bar", baz_raw = "foo"` by `raw(foo = "bar", baz = "foo")` or `raw(foo = "bar"), raw(baz = "foo")`.
427
428## New features
429
430* Add `parse(from_occurrences)` parser by [@SergioBenitez](https://github.com/SergioBenitez)
431* Support 1-uple enum variant as subcommand by [@TeXitoi](https://github.com/TeXitoi)
432* structopt-derive crate is now an implementation detail, structopt reexport the custom derive macro by [@TeXitoi](https://github.com/TeXitoi)
433* Add the `StructOpt::from_iter` method by [@Kerollmops](https://github.com/Kerollmops)
434
435## Documentation
436
437* Improve doc by [@bestouff](https://github.com/bestouff)
438* All the documentation is now on the structopt crate by [@TeXitoi](https://github.com/TeXitoi)
439
440# v0.1.7 (2018-01-23)
441
442* Allow opting out of clap default features by [@ski-csis](https://github.com/ski-csis)
443
444# v0.1.6 (2017-11-25)
445
446* Improve documentation by [@TeXitoi](https://github.com/TeXitoi)
447* Fix bug [#31](https://github.com/TeXitoi/structopt/issues/31) by [@TeXitoi](https://github.com/TeXitoi)
448
449# v0.1.5 (2017-11-14)
450
451* Fix a bug with optional subsubcommand and Enum by [@TeXitoi](https://github.com/TeXitoi)
452
453# v0.1.4 (2017-11-09)
454
455* Implement custom string parser from either `&str` or `&OsStr` by [@kennytm](https://github.com/kennytm)
456
457# v0.1.3 (2017-11-01)
458
459* Improve doc by [@TeXitoi](https://github.com/TeXitoi)
460
461# v0.1.2 (2017-11-01)
462
463* Fix bugs [#24](https://github.com/TeXitoi/structopt/issues/24) and [#25](https://github.com/TeXitoi/structopt/issues/25) by [@TeXitoi](https://github.com/TeXitoi)
464* Support of methods with something else that a string as argument thanks to `_raw` suffix by [@Flakebi](https://github.com/Flakebi)
465
466# v0.1.1 (2017-09-22)
467
468* Better formating of multiple authors by [@killercup](https://github.com/killercup)
469
470# v0.1.0 (2017-07-17)
471
472* Subcommand support by [@williamyaoh](https://github.com/williamyaoh)
473
474# v0.0.5 (2017-06-16)
475
476* Using doc comment to populate help by [@killercup](https://github.com/killercup)
477
478# v0.0.3 (2017-02-11)
479
480* First version with flags, arguments and options support by [@TeXitoi](https://github.com/TeXitoi)