mod lib;
use argh::FromArgs;
use cargo_metadata::camino::Utf8PathBuf;
use lib::{build, default_build_dir, Profile, Target};
#[derive(FromArgs)]
#[argh(subcommand, name = "build-web-viewer")]
pub struct Args {
#[argh(switch)]
release: bool,
#[argh(switch)]
debug: bool,
#[argh(switch, short = 'g')]
debug_symbols: bool,
#[argh(option, short = 't', long = "target", default = "Target::Browser")]
target: Target,
#[argh(option, short = 'o', long = "out")]
build_dir: Option<Utf8PathBuf>,
#[argh(option, short = 'F', long = "features", default = "default_features()")]
features: String,
#[argh(switch, long = "no-default-features")]
no_default_features: bool,
}
fn default_features() -> String {
"analytics".to_owned()
}
pub fn main(args: Args) -> anyhow::Result<()> {
let profile = if args.release && !args.debug {
Profile::Release
} else if !args.release && args.debug {
Profile::Debug
} else {
return Err(anyhow::anyhow!(
"Exactly one of --release or --debug must be set"
));
};
let build_dir = args.build_dir.unwrap_or_else(default_build_dir);
build(
profile,
args.debug_symbols,
args.target,
&build_dir,
args.no_default_features,
&args.features,
)
}