-
Notifications
You must be signed in to change notification settings - Fork 0
Stabilise AppSettings::Multicall
Tracking Issue
#215
Comments
Comment by pksunkara Can you please fill up the known issues that are unresolved from the pr? |
Comment by fishface60
Working on it. |
Comment by epage Note: I had assumed #2817 was merged when preparing to write this. I've intentionally not posted it on #2817 after finding out because I don't think we should gate resolution of that PR on further design discussions For #2864, #2865, and #2866, I wonder if we should make some simplifying assumptions. Currently, #2817 bakes in one multi-call policy and these are about the impact of that or for supporting a variety of other multi-call policies. Instead on taking on the burden to support all multi-call policies, what if we generalize multi-call policy in clap and put the burden on the developer? Proposal:
Benefits
Downside
I'm assuming a trade off like this is worth it because the percentage of multicall users is probably fairly low and so the cost of taking on that extra boiler plate is low, in aggregate across users, compared to the cost for everyone else. |
Comment by epage I added a checklist item
I didn't create an issue because I think it might strictly be possible but its going to be non-obvious. More work might be needed around this. |
Comment by fishface60
So… no matching against base program name, no checking whether the applet exists before I think the way that differs from AppSettings::NoBinaryName is that
So you mean something like this? #[derive(Parser)]
struct ConnectCommand(SocketAddr);
#[derive(Parser)]
enum DeceaseCommand {
GenerateKeys,
Connect(ConnectCommand),
Handshake,
Listen,
}
#[derive(Parser)]
enum Applet {
#[clap(name = concat!(env!("PROGRAM_PREFIX"), "decease"))]
Decease(DeceaseCommand),
#[clap(name = concat!(env!("PROGRAM_PREFIX"), "decease-generate-keys"))]
DeceaseGenerateKeys,
#[clap(name = concat!(env!("PROGRAM_PREFIX"), "decease-connect"))]
DeceaseConnect(ConnectCommand),
#[clap(name = concat!(env!("PROGRAM_PREFIX"), "decease-handshake"))]
DeceaseHandshake,
#[clap(name = concat!(env!("PROGRAM_PREFIX"), "decease-listen"))]
DeceaseListen,
} $ export PROGRAM_PREFIX=dcs-
$ cargo build
$ for name in decease decease-generate-keys decease-connect decease-handshake decease-listen; do ln target/debug/decease ~/bin/"$PROGRAM_PREFIX$name"; done I think this would work okay for derive-style, since the subcommand names get mapped to an enum variant internally, though I think it could be a lot of work for builder-style to keep adding the prefix. I think native support for prefixes would be nice to add later to reduce the duplication in the definition, but isn't needed. |
Issue by fishface60
Tuesday Oct 12, 2021 at 19:51 GMT
Originally opened as clap-rs/clap#2861
Original request: clap-rs/clap#1120
Original PR: clap-rs/clap#2817
Feature flag:
unstable-multicall
Known issues:
The text was updated successfully, but these errors were encountered: