Commit graph

7561 commits

Author SHA1 Message Date
Pavan Kumar Sunkara
9422677030 chore: Refactored travis config 2020-01-31 12:11:25 +01:00
CreepySkeleton
752262ee9a
Bump rustversion to stable release v1 #1647 2020-01-31 11:46:29 +03:00
lzutao
dbc7988d23
Bump rustversion to stable release v1 2020-01-31 14:58:00 +07:00
CreepySkeleton
8be0a94951
Merge pull request #1638 from pksunkara/derive
Subtree merge clap_derive into this repo
2020-01-31 02:28:58 +03:00
Pavan Kumar Sunkara
e1ae505c23
Merge pull request #1637 from danielthegray/use-USAGE-error-exit-code
imp: Add exitcode::USAGE exit code as suggested in #1327
2020-01-30 20:30:36 +01:00
Pavan Kumar Sunkara
afa9ec5e32 Address review comments
Co-Authored-By: CreepySkeleton <creepy-skeleton@yandex.ru>
2020-01-19 06:08:22 +05:30
Pavan Kumar Sunkara
7e0d820aa6 Run clap_derive tests in CI 2020-01-18 19:04:11 +05:30
Pavan Kumar Sunkara
5e8f424dfe Merged clap_derive using git-subtree 2020-01-18 17:40:07 +05:30
Daniel Gray
a1445b0f3b imp: Add exitcode::USAGE exit code as suggested in #1327
The reason to do this is described well in issue #1327. It is also a
recommendation of the Rust book itself:
https://rust-cli.github.io/book/in-depth/exit-code.html
2020-01-17 11:20:45 -04:00
Luca Bruno
f3683a9792 output: get rid of an unsafe block (#1636)
* parse: fix build in debug mode

This fixes a build failure in debug mode, as the value to be printed
does not implement Display.

* output: get rid of an unsafe block

This get rid of an unsafe block which is not necessary, and only used
when building in debug mode.
2020-01-17 19:05:18 +05:30
danieleades
af45420027 style: format code with rustfmt (#1632)
> incidentally, how do we feel about adding a rustfmt check to the CI(s)?
yes we should be doing that. you can send another pr that adds the check to the Ci
2020-01-11 23:45:46 +05:30
Jeremy Stucki
2e1acb648c Refactor mkeymap (#1618)
* refactor(mkeymap): Use iterators

* refactor(mkeymap): Implement contains method

* refactor(mkeymap): Deprecate methods

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-09 23:00:22 +05:30
Pavan Kumar Sunkara
0352bb30c8 Ported all the commits from structopt (#23)
* Automatic naming of fields and subcommands (#143)

* Introduce smarter parsing of doc comments. (#146)

* Fix invalid structopt syntax error message (#154)

There was a typo preventing the probematic attr to be shown to the user.

* Fix spelling: occurences -> occurrences, (#158)

was found in comments and code, but required no user-facing API change.

* Remove line-ending periods from short help. (#161)

* Fix #168

* Support Option<Option<T>> field types (#190)

* Support Option<Vec<T>> field type (#191)

* Fix use of deprecated function

* Fix some clippy lints

* Update deprecated function and provide more info about the parsing error (#193)

* Improve ChangeLog as suggested by @ErichDonGubler (#194)

* [Casing] Change default from verbatim to kebab. (#204)

.. fixes TeXitoi/structopt#202

* Use trybuild for testing expected proc macro errors (#205)

* Custom attributes parser (#198)

* update README.md for 0.3

fix #208

* Small fixes: clippy and typos (#215)

* Add example for environment variables (#160) (#216)

* Support skipping struct fields (#213)

* Now error messages highlight the error location (#225)

* Minor fixes

* Change behavior of `about/author/version` and ad `no_version`

* Emit error about `raw` removal

* Update changelog

* Update keyvalue example (#234)

* Update documentation and changelog (#236)

* Update dependencies (#227)

* Bump minimum rustc version to 1.36

* Fix issues

* Fix structopt-derive permissions (#239)

* Fix #245 (#246)

* Emit dummy impls on error (#248)

* Fix changelog example (#250)

* Do not call .verison() when CARGO_PKG_VERSION is not set

* Update and improve docs

* Propagate span info from origin code to generated code

Most of `quote!` invocations are replaced with `quote_spanned!` ones.
Now everywhere - sometimes it's pointless, sometimes we don't have
any meaningless location to toke a span from, sometimes I just can't
workaround the current implementation - too much changes.

* Fix nightly tests

* Do not mangle `author` string inside `<...>`

* Support `skip = value` syntax

* Fix code formatting

* Fix nightly tests

* Run ui tests only on stable

* Add from_flag parser (#271)

* Clarify docs and error messages (#277)

* Fix parse for OptionVec (#279)

ref pull #191

* Fix #269 and #265 (#278)

* Pass the try_from_str functions a &str instead of a &String. (#282)

In most cases this doesn't matter, as &String is coerced to a &str, but
this fails for generic functions like CString::new.

* Add an example of a negative flag (i.e. --no-verbose)

Question from https://github.com/TeXitoi/structopt/issues/280

* Fix #283 (#284)

Fix #283

* Add `examples/README.md` and do some cleanup

* Handle special types correctly

* cargo clippy

* Handle inter-expansion top-level args properly

* Cleanup tests

* Update proc-macro-error to v0.4

* Offer helpful suggestion on `raw(...)` error

* Add `after_help` example

* Prohibit positional `bool` args

* Add tests/utils.rs

* fixed typo, removed misleading doc

* Remove CHANGELOG additions

* Rust 2018

* Addressed review

Co-authored-by: rnd <bruno.kirschner@online.de>
Co-authored-by: Robin Lambertz <github@roblab.la>
Co-authored-by: florianjacob <accounts+github@florianjacob.de>
Co-authored-by: Ted Driggs <ted.driggs@outlook.com>
Co-authored-by: Guillaume P. <TeXitoi@users.noreply.github.com>
Co-authored-by: Ivan Veselov <veselov@gmail.com>
Co-authored-by: Owen Walpole <owenthewizard@hotmail.com>
Co-authored-by: Robin Stocker <robin.stocker@gmail.com>
Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
Co-authored-by: Ophir LOJKINE <ophir.lojkine@auto-grid.com>
Co-authored-by: kpcyrd <git@rxv.cc>
Co-authored-by: Luiz F. A. de Prá <luizdepra@users.noreply.github.com>
Co-authored-by: Andy Weiss <wvvwwvw@gmail.com>
Co-authored-by: xiaoniu-578fa6bff964d005 <32661032+xiaoniu-578fa6bff964d005@users.noreply.github.com>
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
Co-authored-by: Renê Couto e Silva <31329678+csrene@users.noreply.github.com>
2020-01-07 15:47:23 +05:30
Gregor Pfeifer
8b5ecf92e4 fix: Typos in Arg::conflicts_with_everything` (#1625)
Related to https://github.com/clap-rs/clap/pull/1624
2020-01-06 00:50:15 +05:30
Gregor Pfeifer
6180d42c00 feat: Add Arg::conflicts_with_everything method #1583 (#1624)
* feat: Add `Arg::conflicts_with_everything` method #1583

* fix: Typo in  src/build/arg/mod.rs

Co-Authored-By: Dylan DPC <dylan.dpc@gmail.com>

Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-06 00:16:28 +05:30
Eric Mink
1c3958c56e Clarify documentation usage as help text for subcommands (#1620)
* Clarify documentation usage as help text for subcommands

As outlined in https://github.com/clap-rs/clap/issues/1619 I did not understand why the `SUBCOMMANDS` section of `help` would not print a String `/// A subcommand for controlling testing` for the `Test` subcommand.

This PR updates the README to hopefully make this clearer.

The only change is adding a doc line:
```rust
#[derive(Clap)]
enum SubCommand {
    /// A help message for the Test subcommand
    Test(Test),
}
```

* Move annotation to the variant

Still regarding https://github.com/clap-rs/clap/issues/1619

I think the line that set the version of the subcommand was at the wrong place.
2020-01-04 19:54:33 +05:30
xidaxmb
f402f7a113 imp(usage_parser.rs): add default value support (#1522)
Co-authored-by: Dylan DPC <dylan.dpc@gmail.com>
2020-01-03 17:18:09 +05:30
dylan_DPC
1c79bb5b28 fix subcommand is private bug 2020-01-01 23:28:06 +05:30
Dylan DPC
2622165be3
Merge pull request #21 from deg4uss3r/derive_public_parse_fn
Adding pub to the parse functions
2019-12-27 22:55:56 +05:30
ncaq
fc359e3c46 fixed: failed of multiple_occurrences with env (#1609)
The example code.

~~~rust
use clap::{App, Arg};

fn main() {
  let matches = App::new("My Super Program")
    .arg(
      Arg::with_name("verbose")
        .help("Sets the level of verbosity")
        .short('v')
        .long("verbose")
        .takes_value(false)
        .multiple_occurrences(true)
        .env("VERBOSE"),
    )
    .get_matches();

  match matches.occurrences_of("verbose") {
    0 => println!("0 No verbose info"),
    1 => println!("1 Some verbose info"),
    2 => println!("2 Tons of verbose info"),
    3 | _ => println!("3 >= Don't be crazy"),
  }
}
~~~

It code use multiple_occurrences with env.
But it do not work.
`env` method set require take value.

It result see under.

~~~console
% cargo run -- -v
    Finished dev [unoptimized + debuginfo] target(s) in 0.01s
     Running `target/debug/foo -v`
error: The argument '--verbose <verbose>...' requires a value but none was supplied

USAGE:
    foo [OPTIONS]

For more information try --help
~~~

And, structopt or clap_derive may be create similar code.
So I am confused by structopt.

This to fix code small.
2019-12-22 23:03:23 +05:30
dylan_DPC
a2f9fb5f6c update bitflag to avoid cant find macro import on lower (1.0) versions 2019-11-30 02:06:52 +01:00
Matthew Fisher
bb9631eb3f fix(README): fix compiler errors for first example (#1599)
The first example doesn't compile. The Test structure is missing a `struct` statement, and the `.config` field exists as `.file`. Looking at the flag fields, `config` seems like the expected field name.

Using 

```
[dependencies]
clap = { git = "https://github.com/clap-rs/clap", features = ["wrap_help"] }
```

Signed-Off-By: Matthew Fisher <matt.fisher@microsoft.com>
2019-11-30 00:35:26 +01:00
Mara Bos
2a2969aee4 Don't write --version output directly to stdout. (#1602)
Fixes #1390.
2019-11-26 18:39:12 +01:00
Dylan DPC
335f34bee2 fix broken CI 2019-11-11 14:28:30 +01:00
Dylan DPC
dd6c8e08ad use 2018 edition and minor refactors 2019-11-11 12:54:55 +01:00
Dylan DPC
92c2b5df3f
Merge pull request #1593 from Shnatsel/one-less-unsafe
Drop unnecessary `unsafe`
2019-11-06 15:55:12 +01:00
Kevin K
750796b9ca
Merge branch 'master' into one-less-unsafe 2019-11-03 14:21:56 -05:00
Kevin K
2a50c2ef80
Merge pull request #1388 from scampi/issue-861
feat(Error): add a cause field to the Error struct
2019-11-03 14:17:38 -05:00
Stéphane Campinas
4d69942db7
fix(Error): remove Copy trait bound by formatting both plain and colored error cause at the same time 2019-11-02 21:36:16 +01:00
Stéphane Campinas
991b839069
refactor(Error): add cause field to group_conflict error 2019-11-02 21:36:16 +01:00
Stéphane Campinas
15ad5954b0
feat(Error): add a cause field to the Error struct
The cause field is the actual error described in the message field,
however without extra information like usage.

Close #861
2019-11-02 21:36:11 +01:00
Sergey "Shnatsel" Davidoff
0a010a4371 Add comment on performance 2019-11-02 21:03:35 +01:00
Sergey "Shnatsel" Davidoff
925956d594 Do not leak a new string on every invocation of crate_authors! 2019-11-02 20:18:57 +01:00
Sergey "Shnatsel" Davidoff
0085bb7ee2 Make code actually work 2019-11-02 19:48:16 +01:00
Sergey "Shnatsel" Davidoff
63829a2a9f Drop unnecessary unsafe 2019-11-02 18:33:17 +01:00
Dylan DPC
85f820fa04
Merge pull request #1592 from Razican/term_update
Upgraded ansi_term dependency
2019-10-31 17:06:27 +01:00
Razican
4f97d51f1e
Upgraded ansi_term dependency 2019-10-31 09:05:47 +01:00
Kevin K
2af7c7ca34
Merge pull request #1591 from clap-rs/issue-1589
fixes the custom derive example in the readme
2019-10-30 21:54:37 -04:00
Kevin K
9d58bbee24
docs(README.md): fixes the custom derive example in the readme
Closes #1589
2019-10-30 20:30:29 -04:00
Kevin K
269a5d2bb6
Merge pull request #1523 from shua/master
imp(macros): add subcommand expr macro
2019-10-30 20:29:52 -04:00
Kevin K
c3eca6cdd7
Merge pull request #1588 from lucab/ups/parser-quote-name-v3
app: quote field names in errors
2019-10-30 20:28:39 -04:00
Kevin K
04a3faa39b
Merge branch 'master' into ups/parser-quote-name-v3 2019-10-30 18:31:31 -04:00
Kevin K
cd76c9a146
Merge branch 'master' into master 2019-10-30 18:31:03 -04:00
Kevin K
7f046f28ab
Merge pull request #1590 from clap-rs/msrv-1.36
Msrv 1.36
2019-10-30 18:30:44 -04:00
Kevin K
85eba760e4
chore: adds a meta tag for clog 2019-10-30 16:57:06 -04:00
Kevin K
98e8cfe0c4
meta: Bump the minimum supported Rust to 1.36 2019-10-30 16:56:27 -04:00
Dylan DPC
5318342112
Update README.md 2019-10-30 10:28:37 +01:00
Luca BRUNO
d74e0646d2
app: quote field names in errors
This quotes all field names in errors. It makes easier for humans to
disambiguate common network-related cases which currently end up in
messages like "address is already in use".
2019-10-30 08:30:10 +00:00
shua
452b80d334 add subcommand expr macro 2019-10-30 00:22:05 -04:00
Kevin K
4fdca7b4e6
docs: corrects notes about v2 vs v3 branches 2019-10-29 22:30:17 -04:00