cmd(init/build): cargo fmt

master
csmoe 7 years ago
parent 7cbfc2e893
commit edbd6f4118
  1. 18
      src/command/build.rs
  2. 16
      src/command/init.rs
  3. 4
      src/command/mod.rs
  4. 5
      src/command/utils.rs

@ -1,8 +1,6 @@
//! Initializing a crate for packing `.wasm`s.
use bindgen; use bindgen;
use build; use build;
use command::utils::{set_crate_path, create_pkg_dir}; use command::utils::{create_pkg_dir, set_crate_path};
use emoji; use emoji;
use error::Error; use error::Error;
use indicatif::HumanDuration; use indicatif::HumanDuration;
@ -35,7 +33,7 @@ pub enum BuildMode {
} }
/// Everything required to configure and run the `wasm-pack build` command. /// Everything required to configure and run the `wasm-pack build` command.
#[derive(Debug,StructOpt)] #[derive(Debug, StructOpt)]
pub struct BuildOptions { pub struct BuildOptions {
/// The path to the Rust crate. /// The path to the Rust crate.
pub path: Option<String>, pub path: Option<String>,
@ -60,7 +58,6 @@ pub struct BuildOptions {
#[structopt(long = "debug")] #[structopt(long = "debug")]
/// Build without --release. /// Build without --release.
debug: bool, debug: bool,
// build config from manifest // build config from manifest
// build_config: Option<BuildConfig>, // build_config: Option<BuildConfig>,
} }
@ -72,10 +69,10 @@ impl From<BuildOptions> for Build {
// let build_config = manifest::xxx(&crate_path).xxx(); // let build_config = manifest::xxx(&crate_path).xxx();
Build { Build {
crate_path, crate_path,
scope:build_opts.scope, scope: build_opts.scope,
disable_dts:build_opts.disable_dts, disable_dts: build_opts.disable_dts,
target:build_opts.target, target: build_opts.target,
debug:build_opts.debug, debug: build_opts.debug,
// build_config, // build_config,
crate_name, crate_name,
} }
@ -85,7 +82,7 @@ impl From<BuildOptions> for Build {
type BuildStep = fn(&mut Build, &Step, &Logger) -> Result<(), Error>; type BuildStep = fn(&mut Build, &Step, &Logger) -> Result<(), Error>;
impl Build { impl Build {
/// Execute this `Init` command. /// Execute this `Build` command.
pub fn run(&mut self, log: &Logger, mode: BuildMode) -> Result<(), Error> { pub fn run(&mut self, log: &Logger, mode: BuildMode) -> Result<(), Error> {
let process_steps = Build::get_process_steps(mode); let process_steps = Build::get_process_steps(mode);
@ -148,7 +145,6 @@ impl Build {
} }
} }
fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> { fn step_check_crate_config(&mut self, step: &Step, log: &Logger) -> Result<(), Error> {
info!(&log, "Checking crate configuration..."); info!(&log, "Checking crate configuration...");
manifest::check_crate_config(&self.crate_path, step)?; manifest::check_crate_config(&self.crate_path, step)?;

@ -1,6 +1,6 @@
//! Initializing a crate for packing `.wasm`s. //! Initializing a crate for packing `.wasm`s.
use command::utils::{set_crate_path,create_pkg_dir}; use command::utils::{create_pkg_dir, set_crate_path};
use emoji; use emoji;
use error::Error; use error::Error;
use indicatif::HumanDuration; use indicatif::HumanDuration;
@ -41,8 +41,6 @@ pub struct Init {
scope: Option<String>, scope: Option<String>,
disable_dts: bool, disable_dts: bool,
target: String, target: String,
// build without --release.
debug: bool,
} }
/// `Init` options /// `Init` options
@ -63,22 +61,16 @@ pub struct InitOptions {
#[structopt(long = "target", short = "t", default_value = "browser")] #[structopt(long = "target", short = "t", default_value = "browser")]
/// Sets the target environment. [possible values: browser, nodejs] /// Sets the target environment. [possible values: browser, nodejs]
pub target: String, pub target: String,
#[structopt(long = "debug")]
/// Build without --release.
pub debug: bool,
} }
impl From<InitOptions> for Init { impl From<InitOptions> for Init {
fn from(init_opts: InitOptions) -> Self { fn from(init_opts: InitOptions) -> Self {
let crate_path = set_crate_path(init_opts.path); let crate_path = set_crate_path(init_opts.path);
let crate_name = manifest::get_crate_name(&crate_path).unwrap(); Init {
Init {
crate_path, crate_path,
scope: init_opts.scope, scope: init_opts.scope,
disable_dts:init_opts.disable_dts, disable_dts: init_opts.disable_dts,
target:init_opts.target, target: init_opts.target,
debug:init_opts.debug,
} }
} }
} }

@ -7,11 +7,11 @@ mod pack;
mod publish; mod publish;
pub mod utils; pub mod utils;
use self::build::{Build, BuildMode};
use self::init::Init;
use self::login::login; use self::login::login;
use self::pack::pack; use self::pack::pack;
use self::publish::publish; use self::publish::publish;
use self::build::{Build,BuildMode};
use self::init::Init;
use error::Error; use error::Error;
use slog::Logger; use slog::Logger;
use std::path::PathBuf; use std::path::PathBuf;

@ -1,6 +1,11 @@
//! Utility functions for commands. //! Utility functions for commands.
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use emoji;
use error::Error;
use progressbar::Step;
use std::fs;
use PBAR;
/// If an explicit path is given, then use it, otherwise assume the current /// If an explicit path is given, then use it, otherwise assume the current
/// directory is the crate path. /// directory is the crate path.

Loading…
Cancel
Save