Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored bin commands into separate files #1357

Merged
merged 12 commits into from
Apr 7, 2020
1,132 changes: 9 additions & 1,123 deletions src/bin/wasmer.rs

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
mod cache;
mod run;
mod selfupdate;
mod validate;

pub use {cache::*, run::*, selfupdate::*, validate::*};
31 changes: 31 additions & 0 deletions src/commands/cache.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::common::get_cache_dir;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
pub enum Cache {
/// Clear the cache
#[structopt(name = "clean")]
Clean,

/// Display the location of the cache
#[structopt(name = "dir")]
Dir,
}

impl Cache {
pub fn execute(&self) {
match &self {
Cache::Clean => {
use std::fs;
let cache_dir = get_cache_dir();
if cache_dir.exists() {
fs::remove_dir_all(cache_dir.clone()).expect("Can't remove cache dir");
}
fs::create_dir_all(cache_dir.clone()).expect("Can't create cache dir");
}
Cache::Dir => {
println!("{}", get_cache_dir().to_string_lossy());
}
}
}
}
Loading