Newer
Older
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Debug, Parser)]
#[command(author, version, about, long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
/// Check that firmware is well built
CheckFile(CheckFileArgs),
/// Flash firmware
Flash(FlashArgs),
/// Read the status of the program currently running, and
/// check if there is a firmware installed if we are in
/// bootloader mode.
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Status(StatusArgs),
}
#[derive(Args, Debug)]
pub struct CheckFileArgs {
/// ELF file containing the firmware
pub firmware: PathBuf,
}
#[derive(Args, Debug)]
pub struct CheckFlashArgs {
/// ELF file containing the firmware
pub firmware: PathBuf,
/// I²C bus to use
#[clap(short, long, default_value = "8")]
pub i2c_bus: u8,
}
#[derive(Args, Debug)]
pub struct FlashArgs {
/// Do not verify after flashing
#[clap(long)]
pub no_verify: bool,
/// Do not program (verify only)
#[clap(short, long, conflicts_with = "no_verify")]
pub no_program: bool,
/// I²C bus to use
#[clap(short, long, default_value = "8")]
pub i2c_bus: u8,
/// ELF file containing the firmware
pub firmware: PathBuf,
}
#[derive(Args, Debug)]
pub struct StatusArgs {
/// I²C bus to use
#[clap(short, long, default_value = "8")]
pub i2c_bus: u8,
/// Print only the running program, version, and extra arguments, separated by spaces
#[clap(short, long)]
pub short: bool,