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

refactor: compgen path if no argc script is found for the command #267

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 7 additions & 11 deletions src/bin/argc/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,17 @@ fn run_compgen(mut args: Vec<String>) -> Option<()> {
args[3] = script_file.to_string_lossy().to_string();
} else if let Ok(script_file) = which(&args[4]) {
args[3] = script_file.to_string_lossy().to_string();
} else {
return None;
}
}
let no_color = if let Ok(v) = std::env::var("NO_COLOR") {
v == "true" || v == "1"
} else {
false
};
let output = if args.len() >= 6
&& &args[4] == "argc"
&& (args[3].is_empty() || args[5].starts_with("--argc"))
{
let no_color = std::env::var("NO_COLOR")
.map(|v| v == "true" || v == "1")
.unwrap_or_default();
let output = if &args[4] == "argc" && (args[3].is_empty() || args[5].starts_with("--argc")) {
let cmd_args = &args[4..];
argc::compgen(shell, "", COMPLETION_SCRIPT, cmd_args, no_color).ok()?
} else if args[3].is_empty() {
let cmd_args = &args[4..];
argc::compgen(shell, "", "# @arg path*", cmd_args, no_color).ok()?
} else {
let (source, cmd_args) = parse_script_args(&args[3..]).ok()?;
argc::compgen(shell, &args[3], &source, &cmd_args[1..], no_color).ok()?
Expand Down