Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert Result<(), OsString> -> Result<(), String> #981

Closed
wants to merge 98 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
acdbd47
wip: changes to builders in prep for v3
kbknapp Jan 22, 2018
4f3231a
fix(Help): fixes an issue where help is not properly written using Ap…
kbknapp Jan 24, 2018
8173d71
chore: adds some just recipies for showing errors and tracking todos
kbknapp Jan 24, 2018
6705195
wip: setting the stage for serde, custom derive, and v3
kbknapp Jan 24, 2018
efb3b28
tests: updates the tests that were using clap internals
kbknapp Jan 25, 2018
f66e4f3
chore: removes no longer used style lints
kbknapp Jan 25, 2018
1ab1027
style: rustfmt run
kbknapp Jan 25, 2018
e890b64
wip: still setting the stage for v3
kbknapp Jan 25, 2018
7673dfc
perf: refactors the POSIX override handling to lazy handling
kbknapp Jan 25, 2018
712333b
tests: splits tests into single duties
kbknapp Jan 25, 2018
7788ef7
wip: continuing to iron out the bugs from the internal refactor
kbknapp Jan 25, 2018
78090e5
tests: removes some instances of println in the tests
kbknapp Jan 25, 2018
90c0698
tests(Bash Completions): fixes the order of several completion commands
kbknapp Jan 26, 2018
1fa4afa
tests: continues to update tests to take advantage of new internals
kbknapp Jan 26, 2018
4c54c2a
tests: silence some warnings
kbknapp Jan 26, 2018
7372359
Merge pull request #1154 from kbknapp/v3-prep
kbknapp Jan 26, 2018
c441467
depr(App.rs): deprecates old App methods in prep for v3
kbknapp Jan 31, 2018
04b7532
docs(App.rs): updates the docs away from deprecated methods
kbknapp Jan 31, 2018
e1f1b47
Merge pull request #1156 from kbknapp/v3-dev
kbknapp Jan 31, 2018
6fc70d8
depr(Arg.rs): adds deprecations in prep for v3
kbknapp Jan 31, 2018
41436d3
docs(Arg.rs): updates documentation for the deprecations
kbknapp Jan 31, 2018
2b39054
chore(v3_changes.md): adds a document to track changes to announce fo…
kbknapp Jan 31, 2018
41572e4
benches: partially updates the benches to new arg.setting calls
kbknapp Jan 31, 2018
97fd3f1
tests: partially updates tests to new arg.setting calls
kbknapp Jan 31, 2018
cf3eaae
tests: fixes some typos that caused failing doc tests
kbknapp Feb 3, 2018
6a8b301
chore: bumps the Cargo.toml version to 3.0.0-alpha1 to reduce confusion
kbknapp Feb 3, 2018
4fc7905
Merge pull request #1157 from kbknapp/v3-dev
kbknapp Feb 3, 2018
300a059
chore: updates the version tests
kbknapp Feb 3, 2018
b4c2ded
Merge pull request #1163 from kbknapp/v3-dev
kbknapp Feb 3, 2018
e1b10f6
chore(Cargo.toml): updates with new excludes to trim package and new …
kbknapp Feb 5, 2018
f8e6876
chore: adds some idea project files to the ignore list
kbknapp Feb 10, 2018
4204787
imp(Self Overrides): allows args to override themselves properly
kbknapp Feb 10, 2018
db237f3
docs(Self Overrides): adds docs to better explain overrides_with
kbknapp Feb 10, 2018
237c2bd
tests(Self Overrides): adds tests for args that override themselves
kbknapp Feb 10, 2018
e1d1c06
chore: updates version sync in readme
kbknapp Feb 10, 2018
da1ede5
Merge pull request #1171 from kbknapp/v3-dev
kbknapp Feb 10, 2018
7c23bee
setting(AllArgsOverrideSelf): adds a convenience setting to say all a…
kbknapp Feb 10, 2018
dc098e1
tests(AllArgsOverrideSelf): adds tests for AllArgsOverrideSelf
kbknapp Feb 10, 2018
e630a84
Merge pull request #1172 from kbknapp/v3-dev
kbknapp Feb 10, 2018
5220122
Adjusted error message, as specified in Issue #1160
Feb 6, 2018
9730221
Tests pass now
Feb 6, 2018
08dfdc8
style: changes values->possible values in help messages as well as er…
kbknapp Feb 12, 2018
14a2dad
Merge pull request #1177 from kbknapp/v3-dev
kbknapp Feb 12, 2018
79a2104
imp(Bash Completions): instead of completing a generic option name, a…
kbknapp Feb 13, 2018
cdfdbff
tests(Bash Completions): updates the bash completions to the new file…
kbknapp Feb 13, 2018
6971624
imp(Deps): doesnt compile ansi_term on Windows since its not used
kbknapp Feb 13, 2018
e0b891d
style: removes unused imports
kbknapp Feb 13, 2018
bd08e73
Merge pull request #1182 from kbknapp/v3-dev
kbknapp Feb 14, 2018
5ea7eab
Port 1161 fix to v3
willmurphyscode Mar 1, 2018
3401e6a
clean up whitespace
willmurphyscode Mar 1, 2018
23a48ea
vec_map must be optional
willmurphyscode Mar 4, 2018
1567d80
Merge pull request #1198 from willmurphyscode/port-1161-fix-to-v3
kbknapp Mar 4, 2018
74421bb
bump version on term size to 1.0.0-beta1
willmurphyscode Mar 6, 2018
c3cfe8f
Merge pull request #1202 from willmurphyscode/version-bump-term-size
kbknapp Mar 6, 2018
742aec2
Print ARGS after usage in help
willmurphyscode Mar 7, 2018
b9e4c05
Merge pull request #1208 from willmurphyscode/args-first-in-help
willmurphyscode Mar 15, 2018
82ffb82
refactor(Arg): reverts some of the v3 deprecations to ease the upgrad…
kbknapp Mar 19, 2018
b74faf9
Merge pull request #1217 from kbknapp/v3-dev
kbknapp Mar 19, 2018
a4d0803
fix typo
bootandy Mar 13, 2018
919fd32
Moving the line into the apropriate section
spacekookie Feb 25, 2018
92eab59
docs: Fix some typos and markdown issues.
kbknapp Mar 19, 2018
1e3c715
Cargo.toml: use codegen-units = 1 in release and bench profiles.
matthiaskrgr Feb 24, 2018
bd5143d
fish: Fix completion of >1 options
kbknapp Mar 19, 2018
91e275c
Use short help as tooltip in PowerShell completion
kbknapp Mar 19, 2018
59687be
Merge pull request #1218 from kbknapp/v3-dev
kbknapp Mar 19, 2018
219b96b
imp(AllowMissingPositional): improves the ability of AllowMissingPosi…
kbknapp Mar 21, 2018
7b544e0
tests(AllowMissingPositional): adds tests for new 'skipping to last p…
kbknapp Mar 6, 2018
a2c2bb4
Merge pull request #1223 from kbknapp/v3-dev
kbknapp Mar 21, 2018
ed8bcc7
tests: adds tests for querying indices
kbknapp Feb 26, 2018
b59da93
docs(Arg Indices): adds the documentation for the arg index querying …
kbknapp Feb 26, 2018
c3cd1c1
tests(Values): moves values tests into a tests mod
kbknapp Mar 3, 2018
ed96928
feat(Indices): implements an Indices<Item=&usize> iterator
kbknapp Mar 3, 2018
ad51b79
docs(Values): improves the docs example of the Values iterator
kbknapp Mar 3, 2018
89b74d5
fixup! tests: adds tests for querying indices
kbknapp Mar 4, 2018
ee5733f
fixup! docs(Arg Indices): adds the documentation for the arg index qu…
kbknapp Mar 4, 2018
e2e15b7
feat(Arg Indices): adds the ability to query argument value indices
kbknapp Mar 21, 2018
f65e2e4
fix(Indices): fixes Indices to work on v3
kbknapp Mar 4, 2018
875f6b8
Merge pull request #1225 from kbknapp/v3-dev
kbknapp Mar 21, 2018
d405cbf
Add wasm support
kbknapp Mar 21, 2018
a7b3a75
api(Arg): adds Arg::raw as convenience method to indicate multiple, l…
kbknapp Mar 21, 2018
b73c7e8
Merge pull request #1226 from kbknapp/v3-dev
kbknapp Mar 21, 2018
dfbae74
fix(Suggestions): disables suggestions when AllowExternalSubcommand i…
matklad Mar 19, 2018
564f636
Merge pull request #1227 from kbknapp/v3-dev
kbknapp Mar 21, 2018
f236596
depr(App): adds plural settings and unset_settings to deprecations
kbknapp Mar 21, 2018
fba268a
refactor: changes the signature of App::args to be more generic
kbknapp Mar 21, 2018
e5d44ea
api(App): adds App::get_matches_mut for Lib Blitz style naming consit…
kbknapp Mar 21, 2018
60c634b
api(App): adds App::mut_arg to be able to mutate Args after they've b…
kbknapp Mar 21, 2018
2264b25
api(App): adds App::unset_global_setting to be able to unset a globa …
kbknapp Mar 21, 2018
8f1c0cf
tests: fixes failing tests from new API additions
kbknapp Mar 21, 2018
c9159d3
Merge pull request #1228 from kbknapp/v3-dev
kbknapp Mar 21, 2018
82e8a47
api(Arg): adds abilit to hide an arg from the short or long help message
kbknapp Apr 4, 2018
41e2941
fix: fixes hiding args from short or long help in v3 context
kbknapp Apr 4, 2018
36815fe
imp(macros): Support shorthand syntax for ArgGroups
LegNeato Mar 30, 2018
4df65d8
Merge pull request #1241 from kbknapp/v3-dev
kbknapp Apr 4, 2018
8973f22
feat(Help): adds the ability for custom help sections
kbknapp Apr 4, 2018
0822e2e
Merge pull request #1211 from willmurphyscode/805-experiment
kbknapp Apr 4, 2018
45322fb
convert Result<(), OsString> -> Result<(), String>
little-dude Apr 21, 2018
b4901a1
rustfmt
little-dude Apr 21, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ Cargo.lock
# Project files
.vscode/*
.idea/*
clap-rs.iml
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ Minimum version of Rust is now v1.13.0 (Stable)

#### Bug Fixes

* **Low Index Multiples:** fixes a bug where using low index multiples was propgated to subcommands ([33924e88](https://github.com/kbknapp/clap-rs/commit/33924e884461983c4e6b5ea1330fecc769a4ade7), closes [#725](https://github.com/kbknapp/clap-rs/issues/725))
* **Low Index Multiples:** fixes a bug where using low index multiples was propagated to subcommands ([33924e88](https://github.com/kbknapp/clap-rs/commit/33924e884461983c4e6b5ea1330fecc769a4ade7), closes [#725](https://github.com/kbknapp/clap-rs/issues/725))



Expand Down
46 changes: 39 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,35 +1,66 @@
[package]

name = "clap"
version = "2.29.2"
version = "3.0.0-alpha1"
authors = ["Kevin K. <[email protected]>"]
exclude = ["examples/*", "clap-test/*", "tests/*", "benches/*", "*.png", "clap-perf/*", "*.dot"]
exclude = [
".github/*",
"examples/*",
"tests/*",
"benches/*",
"clap-perf/*",
"etc/*",
"*.png",
"*.dot",
"*.yml",
"*.toml",
"*.md",
"clap-test.rs"
]
include = [
"src/**/*",
"Cargo.toml",
"README.md"
]
repository = "https://github.com/kbknapp/clap-rs"
documentation = "https://docs.rs/clap/"
homepage = "https://clap.rs/"
readme = "README.md"
license = "MIT"
keywords = ["argument", "cli", "arg", "parser", "parse"]
keywords = [
"argument",
"cli",
"arg",
"parser",
"parse"
]
categories = ["command-line-interface"]
description = """
A simple to use, efficient, and full featured Command Line Argument Parser
A simple to use, efficient, and full featured Command Line Argument Parser
"""

[badges]
travis-ci = { repository = "kbknapp/clap-rs" }
appveyor = { repository = "kbknapp/clap-rs" }
coveralls = { repostiory = "kbknapp/clap-rs", branch = "master" }
is-it-maintained-issue-resolution = { repository = "kbknapp/clap-rs" }
is-it-maintained-open-issues = { repository = "kbknapp/clap-rs" }
maintenance = {status = "actively-developed"}

[dependencies]
bitflags = "1.0"
unicode-width = "0.1.4"
textwrap = "0.9.0"
ordermap = "0.3.5"
strsim = { version = "0.7.0", optional = true }
ansi_term = { version = "0.10.0", optional = true }
yaml-rust = { version = "0.3.5", optional = true }
clippy = { version = "~0.0.166", optional = true }
atty = { version = "0.2.2", optional = true }
vec_map = { version = "0.8", optional = true }
term_size = { version = "0.3.0", optional = true }
term_size = { version = "1.0.0-beta1", optional = true }

[target.'cfg(not(windows))'.dependencies]
ansi_term = { version = "0.10.0", optional = true }

[dev-dependencies]
regex = "0.2"
Expand All @@ -55,7 +86,7 @@ debug = false
rpath = false
lto = true
debug-assertions = false
# codegen-units ignored with lto=true
codegen-units = 1

[profile.dev]
opt-level = 0
Expand All @@ -79,6 +110,7 @@ debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1

[profile.doc]
opt-level = 0
Expand Down
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,21 @@ Here's whats new in 2.29.2:

* **Many ZSH Completions Improvements** (Thanks to @segevfiner)
* Positional arguments will default to file completion when not using specific values!
* Implement postional argument possible values completion
* Removes redundant code from output
* Don't pass `-S` to `_arguments` if Zsh is too old
* Fix completions with mixed positionals and subcommands
* String escape possible values for options
* Implement postional argument possible values completion
* Removes redundant code from output
* Don't pass `-S` to `_arguments` if Zsh is too old
* Fix completions with mixed positionals and subcommands
* String escape possible values for options


Here's whats new in 2.29.1:

* Debloats clap by deduplicating logic and refactors for a ~57% decrease in code size! This is with zero functinoality lost, and a slight perf increase!
* Change the bash completion script code generation to support hyphens.
* Change the bash completion script code generation to support hyphens.
* Fix completion of long option values in ZSH completions
* Fixes broken links in docs
* Updates contributors list
* Fixes the ripgrep benchmark by adding a value to a flag that expects it
* Fixes the ripgrep benchmark by adding a value to a flag that expects it

Here's whats new in 2.29.0:

Expand Down Expand Up @@ -321,7 +321,7 @@ subcommands:

Since this feature requires additional dependencies that not everyone may want, it is *not* compiled in by default and we need to enable a feature flag in Cargo.toml:

Simply change your `clap = "2.29"` to `clap = {version = "2.29", features = ["yaml"]}`.
Simply change your `clap = "3.0.0-alpha1"` to `clap = {version = "3.0.0-alpha1", features = ["yaml"]}`.

Finally we create our `main.rs` file just like we would have with the previous two examples:

Expand Down Expand Up @@ -418,7 +418,7 @@ To test out `clap`'s default auto-generated help/version follow these steps:
*
```toml
[dependencies]
clap = "2"
clap = "3.0.0-alpha1"
```

* Add the following to your `src/main.rs`
Expand All @@ -441,7 +441,7 @@ For full usage, add `clap` as a dependency in your `Cargo.toml` () to use from c

```toml
[dependencies]
clap = "~2.29"
clap = "~3.0.0-alpha1"
```

(**note**: If you are concerned with supporting a minimum version of Rust that is *older* than the current stable Rust minus 2 stable releases, it's recommended to use the `~major.minor.patch` style versions in your `Cargo.toml` which will only update the patch version automatically. For more information see the [Compatibility Policy](#compatibility-policy))
Expand All @@ -464,15 +464,15 @@ To disable these, add this to your `Cargo.toml`:

```toml
[dependencies.clap]
version = "2.29"
version = "3.0.0-alpha1"
default-features = false
```

You can also selectively enable only the features you'd like to include, by adding:

```toml
[dependencies.clap]
version = "2.29"
version = "3.0.0-alpha1"
default-features = false

# Cherry-pick the features you'd like to use
Expand All @@ -483,6 +483,7 @@ features = [ "suggestions", "color" ]

* **"yaml"**: Enables building CLIs from YAML documents. (builds dependency `yaml-rust`)
* **"unstable"**: Enables unstable `clap` features that may change from release to release
* **"wrap_help"**: Turns on the help text wrapping feature, based on the terminal size. (builds dependency `term-size`)

### Dependencies Tree

Expand Down Expand Up @@ -520,7 +521,7 @@ In order to keep from being surprised of breaking changes, it is **highly** reco

```toml
[dependencies]
clap = "~2.29"
clap = "~3.0.0-alpha1"
```

This will cause *only* the patch version to be updated upon a `cargo update` call, and therefore cannot break due to new features, or bumped minimum versions of Rust.
Expand All @@ -537,11 +538,11 @@ Right now Cargo's version resolution is pretty naive, it's just a brute-force se

# In one Cargo.toml
[dependencies]
clap = "~2.29.0"
clap = "~3.0.0-alpha1"

# In another Cargo.toml
[dependencies]
clap = "2.29"
clap = "3.0.0-alpha1"
```

This is inherently an unresolvable crate graph in Cargo right now. Cargo requires there's only one major version of a crate, and being in the same workspace these two crates must share a version. This is impossible in this location, though, as these version constraints cannot be met.
Expand Down
19 changes: 19 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
- [ ] update-todo.sh
- [ ] src/lib.rs
-[ ] 578:@TODO @release @docs
-[ ] 580:@TODO @release @docs
-[ ] 583:@TODO @release @docs
-[ ] 592:@TODO @release @docs
-[ ] 598:@TODO @release @docs
-[ ] 608:@TODO @release @docs
-[ ] 610:@TODO @release @docs
-[ ] 614:@TODO @release @docs
-[ ] 616:@TODO @release @docs
-[ ] 619:@TODO @release @docs
-[ ] 623:@TODO @release @docs
- [ ] src/app/parser.rs
-[ ] 678:@TODO @perf: cloning all these Apps ins't great, but since it's just displaying the help
- [ ] src/app/mod.rs
-[ ] 1760:@TODO @v3-alpha @perf: should only propagate globals to subcmd we find, or for help
- [ ] src/args/arg.rs
-[ ] 3545:@TODO @p2 @docs @release: write docs
8 changes: 2 additions & 6 deletions benches/01_default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,7 @@ use clap::App;
use test::Bencher;

#[bench]
fn build_app(b: &mut Bencher) {
b.iter(|| App::new("claptests"));
}
fn build_app(b: &mut Bencher) { b.iter(|| App::new("claptests")); }

#[bench]
fn parse_clean(b: &mut Bencher) {
b.iter(|| App::new("claptests").get_matches_from(vec![""]));
}
fn parse_clean(b: &mut Bencher) { b.iter(|| App::new("claptests").get_matches_from(vec![""])); }
37 changes: 9 additions & 28 deletions benches/02_simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,18 @@ macro_rules! create_app {
}

#[bench]
fn build_app(b: &mut Bencher) {

b.iter(|| create_app!());
}
fn build_app(b: &mut Bencher) { b.iter(|| create_app!()); }

#[bench]
fn add_flag(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| build_app().arg(Arg::from_usage("-s, --some 'something'")));
}

#[bench]
fn add_flag_ref(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| {
let arg = Arg::from_usage("-s, --some 'something'");
Expand All @@ -48,18 +41,14 @@ fn add_flag_ref(b: &mut Bencher) {

#[bench]
fn add_opt(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| build_app().arg(Arg::from_usage("-s, --some <FILE> 'something'")));
}

#[bench]
fn add_opt_ref(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| {
let arg = Arg::from_usage("-s, --some <FILE> 'something'");
Expand All @@ -69,18 +58,14 @@ fn add_opt_ref(b: &mut Bencher) {

#[bench]
fn add_pos(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| build_app().arg(Arg::with_name("some")));
}

#[bench]
fn add_pos_ref(b: &mut Bencher) {
fn build_app() -> App<'static, 'static> {
App::new("claptests")
}
fn build_app() -> App<'static, 'static> { App::new("claptests") }

b.iter(|| {
let arg = Arg::with_name("some");
Expand All @@ -89,14 +74,10 @@ fn add_pos_ref(b: &mut Bencher) {
}

#[bench]
fn parse_clean(b: &mut Bencher) {
b.iter(|| create_app!().get_matches_from(vec![""]));
}
fn parse_clean(b: &mut Bencher) { b.iter(|| create_app!().get_matches_from(vec![""])); }

#[bench]
fn parse_flag(b: &mut Bencher) {
b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"]));
}
fn parse_flag(b: &mut Bencher) { b.iter(|| create_app!().get_matches_from(vec!["myprog", "-f"])); }

#[bench]
fn parse_option(b: &mut Bencher) {
Expand Down
Loading