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

Powershell completions not working with empty help string. #5341

Open
LucasLehmann opened this issue Feb 6, 2024 · 1 comment
Open

Powershell completions not working with empty help string. #5341

LucasLehmann opened this issue Feb 6, 2024 · 1 comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate

Comments

@LucasLehmann
Copy link

I came across a problem with the uutils coreutils package where the powershell completions didnt work, uutils/coreutils#5933, and was directed here. I discovered this is because in the generated ps1 file the line [CompletionResuIt]::new('seq', 'seq', [CompletionResultType]::ParameterValue, '') exists, this line seems to cause the completions to fail and fall back on completing files, i also noticed this is not an issue and everything works as intended when adding something here, be it ' ' or anything else.
I dont know how this and i have never used clap so i dont know what to do to try to replicate it. But i can duplicate the issue in for example rustups completion by replacing it an empty string in one of the completion elements.

@tertsdiepraam
Copy link
Contributor

Here's a minimal example as cargo script:

#!/usr/bin/env -S cargo +nightly -Zscript
```
[dependencies]
clap = "4.4.18"
clap_complete = "4.4.10"
```

use clap::Command;
use clap_complete::{generate, Shell::PowerShell};

fn main() {
    let mut cmd = Command::new("test").subcommand(Command::new("foo").about(""));
    generate(PowerShell, &mut cmd, "test", &mut std::io::stdout());
}

Upon further inspection, I do think we have to fix this in uutils as well, but I think clap_complete should be aware that an empty about breaks completion and fall back to something else.

@epage epage added C-bug Category: Updating dependencies A-completion Area: completion generator E-medium Call for participation: Experience needed to fix: Medium / intermediate E-help-wanted Call for participation: Help is requested to fix this issue. labels Feb 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-completion Area: completion generator C-bug Category: Updating dependencies E-help-wanted Call for participation: Help is requested to fix this issue. E-medium Call for participation: Experience needed to fix: Medium / intermediate
Projects
None yet
Development

No branches or pull requests

3 participants