conditional cli args

This commit is contained in:
Ponj 2024-08-24 15:09:50 +02:00
parent 0c5bcf66af
commit 7b52fc000d
Signed by: p6nj
GPG key ID: 6FED68D87C479A59
2 changed files with 15 additions and 6 deletions

View file

@ -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 = []

View file

@ -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,
}