Move the cli into it’s own library

This commit is contained in:
Syrus
2020-07-22 21:32:45 -07:00
parent ad58fea8ae
commit 8cab73e34f
29 changed files with 253 additions and 71 deletions

53
lib/cli/src/common.rs Normal file
View File

@@ -0,0 +1,53 @@
//! Common module with common used structures across different
//! commands.
use crate::VERSION;
use std::env;
use std::path::PathBuf;
use structopt::StructOpt;
#[derive(Debug, StructOpt, Clone)]
/// The WebAssembly features that can be passed through the
/// Command Line args.
pub struct WasmFeatures {
/// Enable support for the SIMD proposal.
#[structopt(long = "enable-simd")]
pub simd: bool,
/// Enable support for the threads proposal.
#[structopt(long = "enable-threads")]
pub threads: bool,
/// Enable support for the reference types proposal.
#[structopt(long = "enable-reference-types")]
pub reference_types: bool,
/// Enable support for the multi value proposal.
#[structopt(long = "enable-multi-value")]
pub multi_value: bool,
/// Enable support for the bulk memory proposal.
#[structopt(long = "enable-bulk-memory")]
pub bulk_memory: bool,
/// Enable support for all pre-standard proposals.
#[structopt(long = "enable-all")]
pub all: bool,
}
/// Get the cache dir
pub fn get_cache_dir() -> PathBuf {
match env::var("WASMER_CACHE_DIR") {
Ok(dir) => {
let mut path = PathBuf::from(dir);
path.push(VERSION);
path
}
Err(_) => {
// We use a temporal directory for saving cache files
let mut temp_dir = env::temp_dir();
temp_dir.push("wasmer");
temp_dir.push(VERSION);
temp_dir
}
}
}