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

V3 master #510

Closed
wants to merge 18 commits into from
Closed

V3 master #510

wants to merge 18 commits into from

Conversation

kbknapp
Copy link
Member

@kbknapp kbknapp commented May 22, 2016

Still a Work in Progress but getting closer and closer. It's now PR'able minus things like deprecation notices and updated readme/changelogs.

Before this is merged, current master will be branched off to become v2-master.


Here's a list of things I still need to do

  • Create subcommands! macro for using enums with subcommands
    • Update Args::subcommand
    • Update Args::subcommand_name
    • Update Args::subcommand_matches
  • Create args! macro for using enums with args
  • Fix Windows build
  • Add examples/ with new subcommand args macros
    • arg!
    • subcommands!
    • Add _ -> - conversion
  • Decide on if a compiler extension or macro for matches needs to be added prior to this release or not
  • Update Readme (deprecations, how to update, etc.)
  • Update Changelog

kbknapp added 16 commits May 22, 2016 16:55
Example:

```
 #[macro_use]
 extern crate clap;
 use clap::{App, SubCommand};
 // Note lowercase variants, the subcommand will be exactly as typed here
 subcommands!{
     enum MyProg {
         show,
         delete,
         make
     }
 }

 // Alternatively, if you wish to have variants which display
 // differently, or contain hyphens ("-") one can use this variation of
 // the macro
 subcommands!{
     enum MyProgAlt {
         Show => "show",
         Delete => "delete",
         DoStuff => "do-stuff"
     }
 }

 fn main() {
     let m = App::new("myprog")
         .subcommand(SubCommand::with_name(MyProg::show))
         .subcommand(SubCommand::with_name(MyProg::delete))
         .subcommand(SubCommand::with_name(MyProg::make))
         .get_matches_from(vec!["myprog", "show"]);

     match m.subcommand() {
         Some((MyProg::show, _)) => println!("'myprog show' was used"),
         Some((MyProg::delete, _)) => println!("'myprog delete' was used"),
         Some((MyProg::make, _)) => println!("'myprog make' was used"),
         None => println!("No subcommand was used"),
     }
 }
```

This has the benefit of giving non-exhaustive compile time errors when you add subcommands but
forget to check or handle them later.
The v3 macros can now be used with multiple enums:

```rust
args! {
	enum SubCmd1Args {
		One,
		Two,
		Three
	}

	enum SubCmd2Args {
		Four,
		Five,
		Six
	}
}
```
The v3 macros can now be used with multiple enums:

```rust
args! {
	enum SubCmd1Args {
		One,
		Two,
		Three
	}

	enum SubCmd2Args {
		Four,
		Five,
		Six
	}
}
```
The args! macro now has the same alternate form as the subcommands! macro.

```rust
args! {
	enum ProgArgs {
		Arg1 => "FILE",
		Arg2 => "Other"
	}
}
```
@yo-bot
Copy link

yo-bot commented May 22, 2016

r? @sru

(yo-bot has picked a reviewer for you, use r? to override)

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.04%) to 88.696% when pulling be11ab5 on v3-master into a86d6aa on master.

@homu
Copy link
Contributor

homu commented May 31, 2016

☔ The latest upstream changes (presumably #517) made this pull request unmergeable. Please resolve the merge conflicts.

@kbknapp
Copy link
Member Author

kbknapp commented Nov 11, 2016

A lot has changed, I'll reopen this when the time gets closer

@kbknapp kbknapp closed this Nov 11, 2016
@kbknapp kbknapp deleted the v3-master branch June 20, 2017 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants