1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
use std::path::PathBuf;
use structopt::{clap::AppSettings::ColoredHelp, StructOpt};

#[derive(StructOpt)]
#[structopt(global_setting(ColoredHelp))]
pub enum CargoSpawnedArguments {
    /// Run checks on hardware agnostic avionics
    Preflight(Arguments),
}

#[derive(StructOpt)]
pub struct Arguments {
    #[structopt(subcommand)]
    pub command: PreflightCommand,
}

#[derive(StructOpt)]
pub enum PreflightCommand {
    /// Check the layout and setup of the project for compatibility with the preflight runner
    Check {
        #[structopt(flatten)]
        cargo: CargoArguments,
    },
    /// Run a set of automated tests on the project
    Test {
        #[structopt(flatten)]
        cargo: CargoArguments,
        #[structopt(flatten)]
        panic: PanicHandleArguments,
        #[structopt(flatten)]
        sim: SimulationArguments,
        #[structopt(flatten)]
        display: DisplayArguments,
    },
    // /// Run a simulation on the project
    // Simulate {
    //     #[structopt(flatten)]
    //     cargo: CargoArguments,
    // },
}

#[derive(StructOpt)]
pub struct SimulationArguments {}

#[derive(StructOpt)]
pub struct DisplayArguments {
    /// Disable the gui for headless running
    #[structopt(long)]
    pub no_gui: bool,
}

#[derive(StructOpt, Default)]
pub struct PanicHandleArguments {
    /// Open the panic report upon panic
    #[structopt(long, short)]
    pub open: bool,
}

#[derive(StructOpt)]
pub struct CargoArguments {
    #[structopt(long, parse(from_os_str), env = "CARGO")]
    pub cargo_path: PathBuf,
    // TODO: more
    /// Path to Cargo.toml
    #[structopt(long, name = "FILE", parse(from_os_str))]
    pub manifest_path: Option<PathBuf>,
    /// Run without accessing the network
    #[structopt(long)]
    pub offline: bool,
    /// Build artifacts in release mode, with optimizations
    #[structopt(long)]
    pub release: bool,
    /// Directory for all generated artifacts
    #[structopt(long, name = "DIRECTORY", parse(from_os_str))]
    pub target_dir: Option<PathBuf>,
}