mirror of
https://github.com/fanzeyi/cargo-play
synced 2024-11-12 22:17:06 +00:00
rename opt to options
This commit is contained in:
parent
040a52ae4f
commit
e1748f91db
6 changed files with 16 additions and 16 deletions
|
@ -4,7 +4,7 @@ use serde::Serialize;
|
|||
use toml::value::{Table, Value};
|
||||
|
||||
use crate::errors::CargoPlayError;
|
||||
use crate::opt::RustEdition;
|
||||
use crate::options::RustEdition;
|
||||
|
||||
#[derive(Clone, Debug, Serialize)]
|
||||
struct CargoPackage {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
mod cargo;
|
||||
mod errors;
|
||||
pub mod opt;
|
||||
pub mod options;
|
||||
pub mod steps;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
mod cargo;
|
||||
mod errors;
|
||||
mod infer;
|
||||
mod opt;
|
||||
mod options;
|
||||
mod steps;
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
@ -10,12 +10,12 @@ use std::process::{Command, Stdio};
|
|||
use std::vec::Vec;
|
||||
|
||||
use crate::errors::CargoPlayError;
|
||||
use crate::opt::Opt;
|
||||
use crate::options::Options;
|
||||
use crate::steps::*;
|
||||
|
||||
fn main() -> Result<(), CargoPlayError> {
|
||||
let args = std::env::args().collect::<Vec<_>>();
|
||||
let opt = Opt::parse(args);
|
||||
let opt = Options::parse(args);
|
||||
if opt.is_err() {
|
||||
return Ok(());
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ impl Default for RustEdition {
|
|||
name = "cargo-play",
|
||||
about = "Run your Rust program without Cargo.toml"
|
||||
)]
|
||||
pub struct Opt {
|
||||
pub struct Options {
|
||||
#[structopt(short = "d", long = "debug", hidden = true)]
|
||||
pub debug: bool,
|
||||
|
||||
|
@ -110,11 +110,11 @@ pub struct Opt {
|
|||
pub args: Vec<String>,
|
||||
}
|
||||
|
||||
impl Opt {
|
||||
impl Options {
|
||||
#[allow(unused)]
|
||||
/// Convenient constructor for testing
|
||||
pub fn with_files<I: AsRef<Path>>(src: Vec<I>) -> Self {
|
||||
Opt {
|
||||
Self {
|
||||
src: src
|
||||
.into_iter()
|
||||
.filter_map(|x| std::fs::canonicalize(x).ok())
|
||||
|
@ -164,7 +164,7 @@ impl Opt {
|
|||
.find(|x| x.starts_with('+'))
|
||||
.map(|s| String::from_iter(s.chars().skip(1)));
|
||||
|
||||
Ok(Opt::from_iter(args.filter(|x| !x.starts_with('+'))).with_toolchain(toolchain))
|
||||
Ok(Self::from_iter(args.filter(|x| !x.starts_with('+'))).with_toolchain(toolchain))
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ use pathdiff::diff_paths;
|
|||
|
||||
use crate::cargo::CargoManifest;
|
||||
use crate::errors::CargoPlayError;
|
||||
use crate::opt::{Opt, RustEdition};
|
||||
use crate::options::{Options, RustEdition};
|
||||
|
||||
pub fn parse_inputs(inputs: &[PathBuf]) -> Result<Vec<String>, CargoPlayError> {
|
||||
inputs
|
||||
|
@ -118,7 +118,7 @@ pub fn copy_sources(temp: &PathBuf, sources: &[PathBuf]) -> Result<(), CargoPlay
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_cargo_build(options: &Opt, project: &PathBuf) -> Result<ExitStatus, CargoPlayError> {
|
||||
pub fn run_cargo_build(options: &Options, project: &PathBuf) -> Result<ExitStatus, CargoPlayError> {
|
||||
let mut cargo = Command::new("cargo");
|
||||
|
||||
if let Some(toolchain) = options.toolchain.as_ref() {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use cargo_play::opt::Opt;
|
||||
use cargo_play::options::Options;
|
||||
use rand::distributions::Alphanumeric;
|
||||
use rand::{thread_rng, Rng};
|
||||
use std::env;
|
||||
|
@ -108,7 +108,7 @@ fn basic() -> Result<()> {
|
|||
#[test]
|
||||
fn clean() -> Result<()> {
|
||||
let rt = TestRuntime::new()?;
|
||||
let opt = Opt::with_files(vec!["fixtures/hello.rs"]);
|
||||
let opt = Options::with_files(vec!["fixtures/hello.rs"]);
|
||||
let path = rt.temp_dir(opt.temp_dirname());
|
||||
let canary = path.clone().join("canary");
|
||||
|
||||
|
@ -151,7 +151,7 @@ fn edition() -> Result<()> {
|
|||
fn debug_mode() -> Result<()> {
|
||||
let rt = TestRuntime::new()?;
|
||||
|
||||
let opt = Opt::with_files(vec!["fixtures/hello.rs"]);
|
||||
let opt = Options::with_files(vec!["fixtures/hello.rs"]);
|
||||
let path = rt.temp_dir(opt.temp_dirname());
|
||||
|
||||
let _ = rt.run(&["fixtures/hello.rs"])?;
|
||||
|
@ -165,7 +165,7 @@ fn debug_mode() -> Result<()> {
|
|||
fn release_mode() -> Result<()> {
|
||||
let rt = TestRuntime::new()?;
|
||||
|
||||
let opt = Opt::with_files(vec!["fixtures/hello.rs"]);
|
||||
let opt = Options::with_files(vec!["fixtures/hello.rs"]);
|
||||
let path = rt.temp_dir(opt.temp_dirname());
|
||||
|
||||
let _ = rt.run(&["--release", "fixtures/hello.rs"])?;
|
||||
|
@ -195,7 +195,7 @@ fn verbose_mode() -> Result<()> {
|
|||
fn cargo_option() -> Result<()> {
|
||||
let rt = TestRuntime::new()?;
|
||||
|
||||
let opt = Opt::with_files(vec!["fixtures/hello.rs"]);
|
||||
let opt = Options::with_files(vec!["fixtures/hello.rs"]);
|
||||
let path = rt.temp_dir(opt.temp_dirname());
|
||||
|
||||
let _ = rt.run(&["--cargo-option=--release", "fixtures/hello.rs"])?;
|
||||
|
|
Loading…
Reference in a new issue