conditional cli args
This commit is contained in:
parent
0c5bcf66af
commit
7b52fc000d
2 changed files with 15 additions and 6 deletions
|
@ -5,11 +5,15 @@ edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
|
cfg-if = "1.0.0"
|
||||||
clap = { version = "4.5", features = ["derive"] }
|
clap = { version = "4.5", features = ["derive"] }
|
||||||
fasteval = "0.2.4"
|
fasteval = "0.2.4"
|
||||||
tinyaudio = { version = "0.1", optional = true }
|
tinyaudio = { version = "0.1", optional = true }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
|
# default = []
|
||||||
|
# default = ["save"]
|
||||||
|
# default = ["play"]
|
||||||
default = ["play", "save"]
|
default = ["play", "save"]
|
||||||
play = ["dep:tinyaudio"]
|
play = ["dep:tinyaudio"]
|
||||||
save = []
|
save = []
|
||||||
|
|
17
src/cli.rs
17
src/cli.rs
|
@ -1,11 +1,12 @@
|
||||||
use std::{
|
use std::{fs::read_to_string, ops::Deref, path::Path, str::FromStr};
|
||||||
fs::read_to_string,
|
cfg_if! {
|
||||||
ops::Deref,
|
if #[cfg(save)] {
|
||||||
path::{Path, PathBuf},
|
use std::path::PathBuf;
|
||||||
str::FromStr,
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
use anyhow::{Context, Error};
|
use anyhow::{Context, Error};
|
||||||
|
use cfg_if::cfg_if;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
|
@ -13,8 +14,12 @@ use clap::Parser;
|
||||||
pub(super) struct Args {
|
pub(super) struct Args {
|
||||||
#[arg(short, long, value_parser = Instrument::from_str)]
|
#[arg(short, long, value_parser = Instrument::from_str)]
|
||||||
instrument: Option<Instrument>,
|
instrument: Option<Instrument>,
|
||||||
|
#[cfg(save)]
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
output: Option<PathBuf>,
|
output: Option<PathBuf>,
|
||||||
|
#[cfg(play)]
|
||||||
|
#[arg(short, long)]
|
||||||
|
silent: bool,
|
||||||
score: Score,
|
score: Score,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue