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]
|
||||
anyhow = "1.0"
|
||||
cfg-if = "1.0.0"
|
||||
clap = { version = "4.5", features = ["derive"] }
|
||||
fasteval = "0.2.4"
|
||||
tinyaudio = { version = "0.1", optional = true }
|
||||
|
||||
[features]
|
||||
# default = []
|
||||
# default = ["save"]
|
||||
# default = ["play"]
|
||||
default = ["play", "save"]
|
||||
play = ["dep:tinyaudio"]
|
||||
save = []
|
||||
|
|
17
src/cli.rs
17
src/cli.rs
|
@ -1,11 +1,12 @@
|
|||
use std::{
|
||||
fs::read_to_string,
|
||||
ops::Deref,
|
||||
path::{Path, PathBuf},
|
||||
str::FromStr,
|
||||
};
|
||||
use std::{fs::read_to_string, ops::Deref, path::Path, str::FromStr};
|
||||
cfg_if! {
|
||||
if #[cfg(save)] {
|
||||
use std::path::PathBuf;
|
||||
}
|
||||
}
|
||||
|
||||
use anyhow::{Context, Error};
|
||||
use cfg_if::cfg_if;
|
||||
use clap::Parser;
|
||||
|
||||
#[derive(Parser)]
|
||||
|
@ -13,8 +14,12 @@ use clap::Parser;
|
|||
pub(super) struct Args {
|
||||
#[arg(short, long, value_parser = Instrument::from_str)]
|
||||
instrument: Option<Instrument>,
|
||||
#[cfg(save)]
|
||||
#[arg(short, long)]
|
||||
output: Option<PathBuf>,
|
||||
#[cfg(play)]
|
||||
#[arg(short, long)]
|
||||
silent: bool,
|
||||
score: Score,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue