Reid/src/args.rs

52 lines
1.3 KiB
Rust
Raw Normal View History

2020-06-25 01:00:53 +02:00
use std::path::PathBuf;
use argh::FromArgs;
#[derive(FromArgs, PartialEq, Debug)]
#[argh(description = "reid compiler and Virtual Machine")]
pub struct MainOpt {
2020-07-02 22:13:10 +02:00
#[cfg(feature = "compiler")]
#[argh(positional, description = "run compiled .reidc from <path>")]
pub run_path: Option<PathBuf>,
2020-07-02 22:13:10 +02:00
#[cfg(not(feature = "compiler"))]
#[argh(positional, description = "run compiled .reidc from <path>")]
pub run_path: PathBuf,
2020-06-25 01:00:53 +02:00
#[argh(subcommand)]
2020-07-02 22:13:10 +02:00
#[cfg(feature = "compiler")]
pub subcommand: Option<Subcommand>,
2020-06-25 01:00:53 +02:00
}
2020-07-02 22:13:10 +02:00
#[cfg(feature = "compiler")]
2020-06-25 01:00:53 +02:00
#[derive(FromArgs, PartialEq, Debug)]
#[argh(subcommand)]
pub enum Subcommand {
Compile(Compile),
Run(Run),
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(
subcommand,
name = "compile",
description = "compile <source> to .reidc to <output> path"
)]
pub struct Compile {
#[argh(positional, description = "source .reid path")]
pub source: String,
#[argh(positional, description = "output .reidc path")]
pub output: Option<String>,
2020-06-25 01:00:53 +02:00
}
#[derive(FromArgs, PartialEq, Debug)]
#[argh(
subcommand,
name = "run",
description = "compile and run given .reid file"
)]
pub struct Run {
2020-06-25 01:00:53 +02:00
#[argh(positional, description = "source .reid path")]
pub source: PathBuf,
}