Completions for subcommand not working after second or third subcommand
Please complete the following tasks
- I have searched the discussions
- I have searched the open and rejected issues
Rust Version
rustc 1.92.0
Clap Version
4.6.1
Minimal reproducible code
cli.rs:
use clap::Parser;
use clap::Subcommand;
/// Decrypt text file with three algorithms
#[derive(Parser)]
pub struct Args {
/// Which algorithm to use
#[command(subcommand)]
pub algorithm: Algorithms,
}
#[derive(Clone, Debug, Subcommand)]
pub enum Algorithms {
Vigenere {
/// What do you want to do
#[command(subcommand)]
command: VigenereCommands,
},
//DoubleVigenere,
//OneTimePad,
}
#[derive(Clone, Subcommand, Debug)]
pub enum VigenereCommands {
/// Encrypt plain text.
Encrypt,
/// Decrypt cipher text
Decrypt,
/// Crack cipher text
Break {
/// Which method to use to crack or find key (only for vigenere algorithm)
#[command(subcommand)]
method: VigenereBreakMethods,
},
}
#[derive(Clone, Debug, Subcommand)]
pub enum VigenereBreakMethods {
Bruteforce,
Dictionary,
}
Steps to reproduce the bug with the above code
I created cli.rs file with code above and then create completions and run cargo-generate-rpm to be able to test it. ( I can paste code which i use for generation) after creating completions and rpm i install it into system. I click tab and see "vigenere" as an option then I see "decrypt, encrypt, break" (which is weird because in my actual code it stops showing completions after vigenere) I select "break" and i don't see bruteforce or dictionary, but clap still recognize them as an option
Actual Behaviour
it shows completions for 'Algorithms', 'VigenereCommands' but not for 'VigenereBreakMethods' for whatever reason
Expected Behaviour
completions work for every subcommand, not matter how often they occur
Additional Context
I searched the issues, but if it's duplicate link me to it. I can provide whole code if you want or bash output. I don't know what you need :)
Debug Output
No response
Source: clap-rs/clap