Commit graph

1848 commits

Author SHA1 Message Date
Kevin K
fb7057cc7a
refactor(Arg): removes duplicate and uses Base, Switched, and Valued internally now 2017-02-20 19:06:36 -05:00
Kevin K
65b12f9107
chore: clippy run 2017-02-20 19:06:36 -05:00
Niklas Claesson
1971209c0c Fix minor documentation bug 2017-02-20 23:13:06 +01:00
Kevin K
e0f6b35187
Merge branch 'master' of github.com:kbknapp/clap-rs 2017-02-19 13:31:25 -05:00
Homu
e5159f77e7 Auto merge of #862 - pkgw:pr-atty, r=kbknapp
refactor: use the atty crate for isatty() detection

Not only does this remove some unsafe code from clap itself, `atty` does the right thing on Windows too. This isn't relevant now since we don't currently support colorized output on Windows, but will come in handy if/when we implement that feature (#836).
2017-02-20 03:30:39 +09:00
Peter Williams
68e03681d8 refactor: use the atty crate for isatty() detection
Not only does this remove some unsafe code from clap itself, `atty` does the
right thing on Windows too. This isn't relevant now since we don't currently
support colorized output on Windows, but will come in handy if/when we
implement that feature (#836).
2017-02-19 11:12:55 -05:00
Kevin K
595926382e
Merge branch 'master' of github.com:kbknapp/clap-rs 2017-02-18 11:45:48 -05:00
Kevin K
6f9a0baff2 chore: increase version (#858) 2017-02-18 11:45:30 -05:00
Kevin K
9626a1fbe7
chore: increase version 2017-02-18 11:44:38 -05:00
Homu
afd55dda1d Auto merge of #857 - eddyb:patch-1, r=kbknapp
Add missing fragment specifier to a clap_app! rule.

Introduced in #238, this bug affects both `clap` `1.*` and `2.*` and was found by rust-lang/rust#39419.
I'd suggest releasing not only `2.20.5`, but also `1.5.6`, to cover downstream crates still on `1.5.5`.
2017-02-19 01:39:53 +09:00
Eduard-Mihai Burtescu
f28b2353b2 Add missing fragment specifier to a clap_app! rule. 2017-02-18 12:03:41 +02:00
Homu
cb81ce59e5 Auto merge of #855 - pkgw:pr-testfix, r=kbknapp
tests: fix clap_app! doctest

I need these changes to get all of the tests to pass on Linux.
2017-02-17 11:13:46 +09:00
Peter Williams
e635658dad tests: fix clap_app! doctest 2017-02-16 10:48:34 -07:00
Kevin K
e3296e566b Docs (#854)
* docs(App::template) adds missing categories and fixes descriptions

* docs(clap_app): documents all the shorthand syntax

Closes #736

* chore: fixes crates.io category...hopefully
2017-02-16 09:44:44 -05:00
Homu
649f14a452 Auto merge of #852 - kbknapp:issue-846, r=kbknapp
Issue 846
2017-02-16 03:24:07 +09:00
Kevin K
31a6b17a92
chore: increase version 2017-02-15 11:06:48 -05:00
Kevin K
cb1818f23a
chore: fixes crates.io category 2017-02-15 11:04:55 -05:00
Kevin K
5e9b9cf4dd
fix(Completions): fixes a bug that tried to propogate global args multiple times when generating multiple completion scripts
Closes #846
2017-02-15 11:01:41 -05:00
Homu
3f71a017d6 Auto merge of #844 - crazymerlyn:master, r=kbknapp
docs: Fix examples link in CONTRIBUTING.md

The current link to examples doesn't work. Probably left behind from when CONTRIBUTING.md was in the root directory.
2017-02-10 00:47:54 +09:00
Ankit Goel
60cf875d67 docs: Fix examples link in CONTRIBUTING.md 2017-02-08 01:26:58 +05:30
Kevin K
92919f5f67 Call this PR "Raid" cause it's squashin bugs! (#843)
* tests: adds tests for default values triggering conditional requirements

* fix: fixes a bug where default values should have triggered a conditional requirement but didnt

Closes #831

* tests: adds tests for missing conditional requirements in usage string of errors

* fix: fixes a bug where conditionally required args werent appearing in errors

* tests: adds tests for completion generators

* tests: adds tests for completions with binaries names that have underscores

* fix: fixes a bug where ZSH completions would panic if the binary name had an underscore in it

Closes #581

* fix: fixes bash completions for commands that have an underscore in the name

Closes #581

* chore: fix the category for crates.io

* docs(Macros): adds a warning about changing values in Cargo.toml not triggering a rebuild automatically

Closes #838

* fix(Completions): fixes a bug where global args weren't included in the generated completion scripts

Closes #841

* fix: fixes a println->debugln typo

* chore: increase version
2017-02-03 17:43:49 -05:00
Kevin K
07d985d8c5 Issues 839,840 (#842)
* fix: fixes a critical bug where subcommand settings were being propogated too far

Closes #832

* imp: adds ArgGroup::multiple to the supported YAML fields for building ArgGroups from YAML

Closes #840

* chore: increase version
2017-02-03 15:46:25 -05:00
Kevin K
75e815aa3a chore: increase version (#837) 2017-01-30 20:55:02 -05:00
Homu
e9e01e13dd Auto merge of #832 - mgeisler:fix-wrapping-bugs, r=kbknapp
Fix wrapping bugs

I've been working towards integrating my [textwrap][1] crate and along the way, I found some small problems in the existing `wrap_help` function in clap. I basically added new code that calls both `textwrap::fill` and `wrap_help` and panicked on any difference:
```
fn wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    let input = help.clone();
    let mut old = help.clone();
    old_wrap_help(&mut old, longest_w, avail_chars);

    let mut wrapped = String::with_capacity(help.len());
    for (i, line) in help.lines().enumerate() {
        if i > 0 {
            wrapped.push('\n');
        }
        wrapped.push_str(&textwrap::fill(line, avail_chars));
    }

    // TODO: move up, This keeps old behavior of not wrapping at all
    // if one of the words would overflow the line
    if longest_w < avail_chars {
        *help = wrapped;
    }

    if *old != *help {
        println!("********************************");
        println!("longest_w: {}, avail_chars: {}", longest_w, avail_chars);
        println!("help: {:3} bytes: {:?}", input.len(), input);
        println!("old:  {:3} bytes: {:?}", old.len(), old);
        println!("new:  {:3} bytes: {:?}", help.len(), help);
        println!("********************************");
        panic!("bad wrap");
    }
}

fn old_wrap_help(help: &mut String, longest_w: usize, avail_chars: usize) {
    // ... as before
```

This PR fixes two small problems discovered this way, one of which became #828.

[1]: https://crates.io/crates/textwrap
2017-01-31 08:53:31 +09:00
Martin Geisler
564c5f0f17 fix: allow final word to be wrapped in wrap_help
Before, inserting a newline did not move the prev_space index forward.
This meant that the next word was measured incorrectly since the
length was measured back to the word before the newly inserted
linebreak.

Fixes #828.
2017-01-30 18:33:48 +01:00
Martin Geisler
563a539a8e tests: show how final word is not always wrapped
This is #828.
2017-01-30 18:33:48 +01:00
Martin Geisler
84d8c5476d fix: actually show character in debug output
The &help[j..j] string slice was empty so nothing was shown.
2017-01-30 18:33:48 +01:00
Martin Geisler
aff4ba18da fix: include final character in line lenght
Before, wrapping the help text at, say, 80 characters really meant
that every line could be at most 79 characters wide.

Lines can now be up to and including avail_chars columns wide.

If needed, a desired margin or padding can be subtracted from the
avail_chars argument at a later point.
2017-01-30 18:33:48 +01:00
Homu
72d7bf39b9 Auto merge of #830 - kbknapp:issue-826, r=kbknapp
Issue 826
2017-01-30 13:32:01 +09:00
Kevin K
8e2e7448e9
chore: increase version 2017-01-29 21:24:40 -05:00
Kevin K
e112cdd7de
chore: updates pinned rustc nightly 2017-01-29 21:19:00 -05:00
Kevin K
69bd16c410
chore: clippy run 2017-01-29 21:19:00 -05:00
Kevin K
6802ac4a59
imp: updates libc and term_size deps for the libc version conflict 2017-01-29 21:18:57 -05:00
Jimmy Cuadra
c0bccaa474 Relax dependency version constraints. (#823)
It's good practice for a library not to depend on exact versions of any
other libraries, so that downstream programs are able to update
dependencies they have in common at their leisure.

This is described in the Cargo documentation at:
http://doc.crates.io/faq.html#why-do-binaries-have-cargolock-in-version-control-but-not-libraries

An example of the problem an exact version depedency creates can be seen
at https://gist.github.com/jimmycuadra/ac26eca5f11960c357d6fba841640f2f.

This patch modifies Cargo.toml to allow semver-compatible updates to
clap's dependencies.
2017-01-29 18:14:46 -08:00
Richard Janis Goldschmidt (Beckert)
f9f778e8a4 Fix finding required arguments in group arguments (#829)
This fixes #827. The problem was that the check `grp.args.contains(&grp.args[i])` was a) trivially fulfilled (of course `grp.args[i]` is contained in `grp.args`) and b) causing an out-of-bounds error, since the indices were taken from `.required.len()`.

With this change the argument in the group will be removed from the list of required arguments, as intended.
2017-01-29 18:14:04 -08:00
Martin Geisler
d6743bb70d Fix compilation warnings (#825)
* tests: remove unnecessary mut

When building the projec, I was told

    warning: variable does not need to be mutable, #[warn(unused_mut)]
    on by default
      --> tests/macros.rs:39:9
       |
    39 |     let mut app = clap_app!(("app name with spaces-and-hyphens") =>
       |         ^^^^^^^

* examples: remove unused variable

The inner Some value is not used in the match arm:

    warning: unused variable: `local_matches`,
    #[warn(unused_variables)] on by default
       --> examples/20_subcommands.rs:128:32
        |
    128 |                 ("local", Some(local_matches)) =>{
        |                                ^^^^^^^^^^^^^
2017-01-29 18:13:49 -08:00
Trevor Spiteri
5b29be9b07 docs: fix link from app_from_crate! to crate_authors! (#822) 2017-01-29 18:13:34 -08:00
Richard Janis Goldschmidt (Beckert)
ed52851c5d Fix confusing, wrong wording in doc (#821) 2017-01-29 18:12:54 -08:00
Homu
d29d7cc0e2 Auto merge of #820 - shepmaster:patch-1, r=kbknapp
Add categories to Cargo.toml

Hi! [crates.io now supports categories][categories], which are a curated list
of topics aimed at helping an end-user coming to crates.io looking for
"a crate to do ______".

We're sending pull requests to selected crates to add categories in order to help
populate the categories and seed their usefulness. We've made a guess at the best
category/categories for this crate; if it doesn't fit, please feel free to take
a look at [all the available categories and their descriptions][categories] and
[the slug values that should be specified in your Cargo.toml][slugs] and pick
different ones. If you have a category in mind that isn't available, you can
[send a PR to this file on crates.io][categories.toml] to propose additional
categories.

Crates can have up to 5 categories, and uploading categories to crates.io
currently requires publishing a new version with a cargo nightly from 2017-01-18
or later (it needs to contain [this PR][cargo-pr]).

We've [published a blog post][blog-post] with further details about categories.
The blog post also talks about the new crates.io support for CI badges, which
you may be interested in adding as well.

Please let me know if you have any questions!

[categories]: https://crates.io/categories
[slugs]: https://crates.io/category_slugs
[categories.toml]: https://github.com/rust-lang/crates.io/blob/master/src/categories.toml
[cargo-pr]: https://github.com/rust-lang/cargo/pull/3301
[blog-post]: http://integer32.com/2017/01/20/categories-and-ci-badges.html
2017-01-21 12:05:57 +09:00
Jake Goulding
8615aee9ac Add categories to Cargo.toml 2017-01-20 11:16:49 -05:00
Homu
70b2ac289e Auto merge of #819 - SuperFluffy:add_note_to_doc, r=kbknapp
Explain how `ArgRequiredElseHelp` and `default_value` interact

When calling the executable without arguments one expects a help message. However, if even one argument has a default value, the validation step of the parser will always see at least one argument, and therefore report success. This effectively disables the settings.
2017-01-19 10:33:15 +09:00
Richard Janis Goldschmidt
f1b11886dc Explain how AppSettings::ArgRequiredElseHelp and Arg::default_value interact
When calling the executable without arguments one expects a help message. However, if even one argument has a default value, the validation step of the parser will always see at least one argument, and therefore report success. This effectively disables the settings.
2017-01-18 17:14:06 +01:00
Homu
ea5ef4f930 Auto merge of #813 - pixelistik:patch-1, r=kbknapp
doc: Fix typo
2017-01-09 10:59:10 +09:00
pixelistik
5de1b6e1c8 doc: Fix typo 2017-01-08 23:45:03 +01:00
Homu
ec9b556192 Auto merge of #811 - Seeker14491:master, r=kbknapp
docs: fix spelling of "guaranteed"
2017-01-08 12:07:27 +09:00
Brian Bowman
4f30a65b9c docs: fix spelling of "guaranteed" 2017-01-07 20:18:59 -06:00
Homu
031df5d639 Auto merge of #809 - kbknapp:issue-636, r=kbknapp
Issue 636
2017-01-06 10:29:09 +09:00
Kevin K
9d88f19181
refactor: 'reverts' a breaking change until further discussion and approval has taken place 2017-01-05 19:26:16 -05:00
Kevin K
15b3f32e5d
chore: increase version 2017-01-04 00:03:10 -05:00
Kevin K
e80fd4d671
tests: adds tests for AppSettings::AllowMissingPositional 2017-01-04 00:02:26 -05:00