From 39b45971f89d529a2d7ee8e7c697864b49279031 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Mon, 20 Jun 2022 13:38:02 +0200 Subject: [PATCH] dashboard: Add base for using CLI args --- dashboard/Cargo.toml | 1 + dashboard/src/main.rs | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/dashboard/Cargo.toml b/dashboard/Cargo.toml index 9f7feda..fc2a266 100644 --- a/dashboard/Cargo.toml +++ b/dashboard/Cargo.toml @@ -25,3 +25,4 @@ chrono = "0.4" console_error_panic_hook = "0.1" wasm-rs-dbg = "0.1" common = { path = "../common"} +clap = { version = "3.2", features = ["derive"] } diff --git a/dashboard/src/main.rs b/dashboard/src/main.rs index e0db132..69cb8c2 100644 --- a/dashboard/src/main.rs +++ b/dashboard/src/main.rs @@ -1,6 +1,7 @@ use std::ops::Range; use chrono::{Duration, NaiveDate}; +use clap::Parser; use plotters::prelude::*; use plotters_canvas::CanvasBackend; use wasm_rs_dbg::dbg; @@ -10,6 +11,13 @@ use yew::prelude::*; use common::TestsuiteResult; +#[derive(Parser, Debug)] +#[clap(author, version)] +struct Args { + #[clap(short, long, default_value = "http://127.0.0.1")] + api_url: String, +} + #[derive(Debug, Clone)] enum Error { CacheAPI, @@ -272,6 +280,8 @@ fn get_limits(testsuites: &[TestsuiteResult]) -> Range { fn main() { std::panic::set_hook(Box::new(console_error_panic_hook::hook)); + let args = Args::parse(); + dbg!(args); yew::start_app::(); }