Skip to content
Snippets Groups Projects
Commit b9da0b28 authored by Federico Lolli's avatar Federico Lolli
Browse files

Moved cli in its own module and added color

parent eb069557
No related branches found
No related tags found
No related merge requests found
use std::path::PathBuf;
use clap::{
builder::{
styling::{AnsiColor, Color, Style},
Styles,
},
Parser,
};
#[derive(Debug, Parser)]
#[command(styles=get_styles())]
pub struct Cli {
/// The serial port to use
#[clap(short, long, value_name = "PORT")]
pub port: Option<String>,
/// The input csv file to read from
pub csv_input: PathBuf,
/// baud rate
#[clap(short, long, default_value = "115200")]
pub baud_rate: u32,
}
pub fn get_styles() -> Styles {
Styles::styled()
.usage(
Style::new()
.bold()
.underline()
.fg_color(Some(Color::Ansi(AnsiColor::Yellow))),
)
.header(
Style::new()
.bold()
.underline()
.fg_color(Some(Color::Ansi(AnsiColor::Yellow))),
)
.literal(Style::new().fg_color(Some(Color::Ansi(AnsiColor::Green))))
.invalid(
Style::new()
.bold()
.fg_color(Some(Color::Ansi(AnsiColor::Red))),
)
.error(
Style::new()
.bold()
.fg_color(Some(Color::Ansi(AnsiColor::Red))),
)
.valid(
Style::new()
.bold()
.underline()
.fg_color(Some(Color::Ansi(AnsiColor::Green))),
)
.placeholder(Style::new().fg_color(Some(Color::Ansi(AnsiColor::White))))
}
mod cli;
mod packet;
mod utils;
use std::{
fs::File,
io::{self, Read},
path::PathBuf,
time::{Duration, Instant},
};
......@@ -17,26 +17,13 @@ use skyward_mavlink::{
};
use crate::{
cli::Cli,
packet::PacketSequence,
utils::{get_first_stm32_serial_port, print_stats},
};
const ACK: u8 = 0x06;
#[derive(Debug, Parser)]
struct Cli {
/// The serial port to use
#[clap(short, long, value_name = "PORT")]
port: Option<String>,
/// The input csv file to read from
csv_input: PathBuf,
/// baud rate
#[clap(short, long, default_value = "115200")]
baud_rate: u32,
}
fn main() {
simple_logger::SimpleLogger::new()
.with_level(log::LevelFilter::Info)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment