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

External subcommand #1883

Merged
merged 4 commits into from
May 1, 2020
Merged

External subcommand #1883

merged 4 commits into from
May 1, 2020

Conversation

CreepySkeleton
Copy link
Contributor

Closes #1672

This is almost done, but blocked on the undetected bug in 3.0: if both AllowExternalSubcommands and SubcommandRequiredElseHelp are set, externals subcommand doesn't count and exit triggers. Will get to it tomorrow.

}
});
})
.collect();
Copy link
Member

@pksunkara pksunkara Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think you need the collect here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need collect here so this mapping is executed right now, not lazily. I need it because it sets ext_subcmd and the code below relies on it.

other => {
#( #child_subcommands )*;
None
#( #child_subcommands )else*
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the else here.

Copy link
Contributor Author

@CreepySkeleton CreepySkeleton Apr 30, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This else serves as a separator for if statements.

Before:

if let Some(...) = ... {
   //...
}
if let Some(...) = ... {
   //...
}
// ...

After:

if let Some(...) = ... {
   //...
} else if let Some(...) = ... {
   //...
}
// ...

The new variant looks better in cargo expand, this is the whole motivation

@CreepySkeleton CreepySkeleton changed the title WIP: External subcommand External subcommand May 1, 2020
@pksunkara
Copy link
Member

Looks good except the 2 comments.

@pksunkara
Copy link
Member

You are not running tests locally. They will fail with this commit.

@CreepySkeleton
Copy link
Contributor Author

@pksunkara Why do you think so? Clarify?

@pksunkara
Copy link
Member

You uncommented the asserts in the test as I asked, but you forgot to uncomment the enum variants which are used in the asserts.

@CreepySkeleton
Copy link
Contributor Author

Yeah, fixed. I tend to avoid running tests on my machine because CI works 2x faster.

@pksunkara
Copy link
Member

Rust Analyzer with VSCode allows running single test easily

@CreepySkeleton
Copy link
Contributor Author

...except my current laptop is slow as hell. cargo test --all takes 20+ minutes and renders the machine unusable - unless it's -j1 but then it it takes up to 40 minutes. Basically, I use CI because it saves time. Lots of time.

Let's try to integrate the current workflow - I push, look at the logs, fix, push, request review when it's green.

@CreepySkeleton
Copy link
Contributor Author

I do run single tests, but sometimes it's not enough.

@kbknapp
Copy link
Member

kbknapp commented May 1, 2020

@CreepySkeleton @pksunkara see the discussion in the Admins area of the org if you'd like to offload some compile/test times without having to use the public CI/PR trackers.

@CreepySkeleton
Copy link
Contributor Author

I'm going to reorganize the .stderr files and add the requested tests along the way. Would you like a separate file for each test case or one file for similar cases (like conflicting_attrs.rs, misplaced_attrs.rs and the like)?

@pksunkara
Copy link
Member

Can we please not do the reorganization as part of this PR?

@pksunkara
Copy link
Member

bors r+

@bors
Copy link
Contributor

bors bot commented May 1, 2020

Build succeeded:

@bors bors bot merged commit 99e8629 into master May 1, 2020
@bors bors bot deleted the external_subcommand branch May 1, 2020 18:19
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.

Implement #[clap(external_subcommand)]
3 participants