Skip to content

Commit

Permalink
Have arti hss onion-name error if it doesn't print the onion name
Browse files Browse the repository at this point in the history
There are two error cases where the onion name isn't printed, but
previously returned `Ok(())`.

It now returns an error to exit with a non-zero status code.
  • Loading branch information
legoktm committed Aug 1, 2024
1 parent 55512ff commit 405ada0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
8 changes: 5 additions & 3 deletions crates/arti/src/subcommands/hss.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
//! The `hss` subcommand.
use anyhow::anyhow;
use arti_client::TorClientConfig;
use clap::ArgMatches;

Expand All @@ -23,8 +24,7 @@ pub(crate) fn run(
.find(|(n, _)| **n == nickname)
.map(|(_, cfg)| cfg.svc_cfg.clone())
else {
println!("Service {nickname} is not configured");
return Ok(());
return Err(anyhow!("Service {nickname} is not configured"));
};

// TODO: PreferredRuntime was arbitrarily chosen and is entirely unused
Expand All @@ -43,7 +43,9 @@ pub(crate) fn run(
if let Some(onion) = onion_svc.onion_name() {
println!("{onion}");
} else {
println!("Service {nickname} does not exist, or does not have an K_hsid yet");
return Err(anyhow!(
"Service {nickname} does not exist, or does not have an K_hsid yet"
));
}
}

Expand Down
3 changes: 2 additions & 1 deletion crates/arti/tests/testcases/hss/hss.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ $ arti -c hss.toml hss --nickname acutus-cepa onion-name
mnyizjj7m3hpcr7i5afph3zt7maa65johyu2ruis6z7cmnjmaj3h6tad.onion

$ arti -c hss.toml hss --nickname flamingo onion-name
Service flamingo is not configured
? 127
[..]/arti: error: Service flamingo is not configured

```

0 comments on commit 405ada0

Please sign in to comment.