Skip to content

Commit

Permalink
fixed formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippPolterauer committed Jan 19, 2024
1 parent 1ee20c1 commit b9706fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,21 +39,21 @@ pub fn ensure_samply_profile(cargo_toml: &Path) -> error::Result<()> {
.and_then(|p| p.get("samply"));

if profile_samply.is_none() {
let mut f = OpenOptions::new().append(true).open(&cargo_toml).unwrap();
f.write(SAMPLY_PROFILE.as_bytes()).path_ctx(&cargo_toml)?;
let mut f = OpenOptions::new().append(true).open(cargo_toml).unwrap();
f.write(SAMPLY_PROFILE.as_bytes()).path_ctx(cargo_toml)?;
info!("'samply' profile was added to 'Cargo.toml'");
}
Ok(())
}

pub fn guess_bin(cargo_toml: &Path) -> error::Result<String> {
let manifest = cargo_toml::Manifest::from_path(&cargo_toml)?;
let manifest = cargo_toml::Manifest::from_path(cargo_toml)?;
let default_run = manifest.package.and_then(|p| p.default_run);
if let Some(bin) = default_run {
return Ok(bin);
Ok(bin)
} else if manifest.bin.len() == 1 {
return Ok(manifest.bin.first().unwrap().name.clone().unwrap());
} else if manifest.bin.len() == 0 {
} else if manifest.bin.is_empty() {
return Err(error::Error::NoBinaryFound);
} else {
return Err(error::Error::BinaryToRunNotDetermined);
Expand Down
3 changes: 2 additions & 1 deletion tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ fn trycmd() {
.register_bin("cargo", trycmd::schema::Bin::Path(which("cargo").unwrap()));

for pth in cargo_bins.iter().filter(|pth| {
!pth.extension().is_some_and(|pth| pth == "exe") && pth.file_name().is_some_and(|p| p !="cargo-samply")
!pth.extension().is_some_and(|pth| pth == "exe")
&& pth.file_name().is_some_and(|p| p != "cargo-samply")
}) {
println!("{}", pth.file_name().unwrap().to_string_lossy());
t = t.register_bin(
Expand Down

0 comments on commit b9706fc

Please sign in to comment.