-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
243 additions
and
10 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
use crate::cliapp::make_app; | ||
use anyhow::Result; | ||
|
||
pub fn execute() -> Result<()> { | ||
let app = make_app(); | ||
let matches = app.get_matches(); | ||
|
||
if let Some(_matches) = matches.subcommand_matches("run") { | ||
println!("Hello world"); | ||
Ok(()) | ||
} else { | ||
unreachable!(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//! This module implements the definition of the command line app. | ||
|
||
use clap::builder::ValueParser; | ||
use clap::{Arg, Command, ValueHint}; | ||
|
||
pub const VERSION: &str = env!("CARGO_PKG_VERSION"); | ||
pub const ABOUT: &str = "The Sentry uptime checker service."; | ||
|
||
pub fn make_app() -> Command { | ||
Command::new("relay") | ||
.disable_help_subcommand(true) | ||
.subcommand_required(true) | ||
.propagate_version(true) | ||
.version(VERSION) | ||
.about(ABOUT) | ||
.arg( | ||
Arg::new("config") | ||
.long("config") | ||
.short('c') | ||
.global(true) | ||
.value_hint(ValueHint::DirPath) | ||
.value_parser(ValueParser::path_buf()) | ||
.help("The path to the config file."), | ||
) | ||
.subcommand( | ||
Command::new("run") | ||
.about("Run the service") | ||
.after_help("This runs the uptime-checker in the foreground until it's shut down."), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
fn main() { | ||
println!("Hello, world!"); | ||
} | ||
mod cli; | ||
mod cliapp; | ||
|
||
use std::process; | ||
|
||
#[cfg(test)] | ||
mod tests { | ||
#[test] | ||
fn test_addition() { | ||
assert_eq!(1 + 1, 2); | ||
} | ||
pub fn main() { | ||
let exit_code = match cli::execute() { | ||
Ok(()) => 0, | ||
Err(_err) => { | ||
// TODO(epurkhiser): capture error? Here's what relay did | ||
// relay_log::ensure_error(&err); | ||
1 | ||
} | ||
}; | ||
process::exit(exit_code); | ||
} |