Move argument parsing in separate module
This commit is contained in:
parent
60af1c3d0b
commit
6653339da7
2 changed files with 19 additions and 15 deletions
17
src/cli.rs
Normal file
17
src/cli.rs
Normal file
|
@ -0,0 +1,17 @@
|
|||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about)]
|
||||
pub struct Cli {
|
||||
/// SpaceAPI endpoint
|
||||
#[arg(short, long)]
|
||||
pub url: String,
|
||||
|
||||
/// Period of querying, in seconds
|
||||
#[arg(short, long, default_value_t = 300)]
|
||||
pub delay: u64,
|
||||
}
|
||||
|
||||
pub fn parse() -> Cli {
|
||||
Cli::parse()
|
||||
}
|
17
src/main.rs
17
src/main.rs
|
@ -1,18 +1,5 @@
|
|||
use clap::Parser;
|
||||
|
||||
mod client;
|
||||
|
||||
#[derive(Parser)]
|
||||
#[command(version, about)]
|
||||
struct Cli {
|
||||
/// SpaceAPI endpoint
|
||||
#[arg(short, long)]
|
||||
url: String,
|
||||
|
||||
/// Period of querying, in seconds
|
||||
#[arg(short, long, default_value_t = 300)]
|
||||
delay: u64,
|
||||
}
|
||||
mod cli;
|
||||
|
||||
use std::sync::{Arc, Mutex};
|
||||
type Body = Arc<Mutex<String>>;
|
||||
|
@ -21,7 +8,7 @@ use rocket::{get, launch, routes, State};
|
|||
|
||||
#[launch]
|
||||
fn rocket() -> _ {
|
||||
let cli = Cli::parse();
|
||||
let cli = cli::parse();
|
||||
|
||||
let body: Body = Arc::new(Mutex::new(String::new()));
|
||||
let body_state = body.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue