Skip to content

Commit

Permalink
Parse path
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnan-chandra committed Jul 30, 2024
1 parent 25394f4 commit 4cba408
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions crates/uv/src/commands/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,22 @@ pub(crate) fn help(query: &[String], printer: Printer, no_pager: bool) -> Result
Some(pager) => {
// When using a pager, we use the command name as the file name and can support colors
match pager.to_str() {
Some("less") => {
let prompt = format!("help: uv {}", query.join(" "));
spawn_pager(&pager, &["-R", "-P", &prompt], &help_ansi)?;
Some(pager_str) => {
let pager_name = std::path::Path::new(pager_str)
.file_name()
.and_then(|name| name.to_str())
.unwrap_or("");

if pager_name.is_empty() {
writeln!(printer.stdout(), "{help_ansi}")?;
} else if pager_name == "less" {
let prompt = format!("help: uv {}", query.join(" "));
spawn_pager(&pager, &["-R", "-P", &prompt], &help_ansi)?;
} else {
spawn_pager(&pager, &[], &help)?;
}
}
Some(x) if !x.is_empty() => spawn_pager(&pager, &[], &help)?,
_ => {
None => {
writeln!(printer.stdout(), "{help_ansi}")?;
}
}
Expand Down

0 comments on commit 4cba408

Please sign in to comment.