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