diff --git a/Cargo.toml b/Cargo.toml index 0f2ad96c4..89943ec62 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,11 +9,13 @@ license = "MIT/Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +# cli core +clap = {version = "3.0.14", features = ["derive"]} thiserror = "1.0.30" +wasm-bindgen-cli-support = "0.2.79" +# features log = "0.4.14" fern = { version = "0.6.0", features = ["colored"] } -wasm-bindgen-cli-support = "0.2.79" -anyhow = "1.0.53" serde = { version = "1.0.136", features = ["derive"] } serde_json = "1.0.79" toml = "0.5.8" @@ -29,7 +31,6 @@ tokio = { version = "1.16.1", features = ["full"] } atty = "0.2.14" regex = "1.5.4" chrono = "0.4.19" -clap = "3.0.14" axum = { version = "0.4.5", features = ["ws", "headers"] } tower-http = { version = "0.2.2", features = ["fs", "trace"] } diff --git a/src/cli/build/mod.rs b/src/cli/build/mod.rs index 684cec58c..b4d7f5fe4 100644 --- a/src/cli/build/mod.rs +++ b/src/cli/build/mod.rs @@ -1,10 +1,8 @@ -use std::{io::Write, path::PathBuf}; +use super::*; -use crate::{cfg::ConfigOptsBuild, gen_page}; -use structopt::StructOpt; /// Build the Rust WASM app and all of its assets. -#[derive(Clone, Debug, StructOpt)] +#[derive(Clone, Debug, Parser)] #[structopt(name = "build")] pub struct Build { #[structopt(flatten)] @@ -15,7 +13,7 @@ impl Build { pub fn build(self) -> anyhow::Result<()> { let mut crate_config = crate::CrateConfig::new()?; - // change the relase state. + // change the release state. crate_config.with_release(self.build.release); if self.build.example.is_some() { diff --git a/src/cli/cfg.rs b/src/cli/cfg.rs index ece00e07e..fdd627e85 100644 --- a/src/cli/cfg.rs +++ b/src/cli/cfg.rs @@ -1,10 +1,7 @@ -use std::path::PathBuf; -use structopt::StructOpt; - -use serde::Deserialize; +use super::*; /// Config options for the build system. -#[derive(Clone, Debug, Default, Deserialize, StructOpt)] +#[derive(Clone, Debug, Default, Deserialize, Parser)] pub struct ConfigOptsBuild { /// The index HTML file to drive the bundling process [default: index.html] #[structopt(parse(from_os_str))] @@ -24,7 +21,7 @@ pub struct ConfigOptsBuild { pub platform: String, } -#[derive(Clone, Debug, Default, Deserialize, StructOpt)] +#[derive(Clone, Debug, Default, Deserialize, Parser)] pub struct ConfigOptsServe { /// The index HTML file to drive the bundling process [default: index.html] #[structopt(parse(from_os_str))] diff --git a/src/cli/clean/mod.rs b/src/cli/clean/mod.rs index 62593b1ee..334f93572 100644 --- a/src/cli/clean/mod.rs +++ b/src/cli/clean/mod.rs @@ -1,13 +1,7 @@ -use std::{ - fs::remove_dir_all, - path::PathBuf, - process::{Command, Stdio}, -}; - -use structopt::StructOpt; +use super::*; /// Build the Rust WASM app and all of its assets. -#[derive(Clone, Debug, StructOpt)] +#[derive(Clone, Debug, Parser)] #[structopt(name = "clean")] pub struct Clean {} diff --git a/src/cli/config/mod.rs b/src/cli/config/mod.rs index d5291a7d6..e5d7bdbe4 100644 --- a/src/cli/config/mod.rs +++ b/src/cli/config/mod.rs @@ -1,10 +1,7 @@ -use std::{fs::File, io::Write}; - -use serde::Deserialize; -use structopt::StructOpt; +use super::*; /// Build the Rust WASM app and all of its assets. -#[derive(Clone, Debug, Deserialize, StructOpt)] +#[derive(Clone, Debug, Deserialize, Parser)] #[structopt(name = "config")] pub enum Config { /// Init `Dioxus.toml` for project/folder. diff --git a/src/cli/create/mod.rs b/src/cli/create/mod.rs index fa553c55a..b92a193b7 100644 --- a/src/cli/create/mod.rs +++ b/src/cli/create/mod.rs @@ -1,15 +1,4 @@ -use std::{ - fs::File, - io::{Read, Write}, - path::PathBuf, - process::{Command, Stdio}, -}; - -use regex::Regex; -use serde::Deserialize; -use structopt::StructOpt; - -use crate::{error::Result, Error}; +use super::*; /// Build the Rust WASM app and all of its assets. #[derive(Clone, Debug, Default, Deserialize, StructOpt)] diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 4a72e00ac..e3bd18b3b 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,5 +1,3 @@ -use structopt::StructOpt; - pub mod build; pub mod cfg; pub mod clean; @@ -8,17 +6,38 @@ pub mod create; pub mod serve; pub mod translate; +use std::{io::Write, path::PathBuf}; +use crate::{cfg::ConfigOptsBuild, gen_page}; +use clap::{Parser}; +use serde::Deserialize; +use std::{ + fs::remove_dir_all, + process::{Command, Stdio}, +}; +use std::{fs::File}; +use std::{ + io::{Read}, +}; +use regex::Regex; +use crate::{error::Result, Error}; +use crate::{cfg::ConfigOptsServe, server, CrateConfig}; +use html_parser::Dom; +use html_parser::Element; +use html_parser::Node; +use std::fmt::{Display, Formatter}; +use std::process::exit; + /// Build, bundle, & ship your Dioxus app. /// /// -#[derive(StructOpt)] -#[structopt(name = "dioxus")] +#[derive(Parser, Debug)] +#[clap(name = "dioxus")] pub struct Cli { - #[structopt(subcommand)] + #[clap(subcommand)] pub action: Commands, /// Enable verbose logging. - #[structopt(short)] + #[clap(short)] pub v: bool, // // // note: dioxus is still roughly compatible with trunk @@ -27,7 +46,7 @@ pub struct Cli { // pub config: Option, } -#[derive(StructOpt)] +#[derive(Parser)] pub enum Commands { /// Build the Rust WASM app and all of its assets. Build(build::Build), diff --git a/src/cli/serve/mod.rs b/src/cli/serve/mod.rs index 8f26e0f30..d7184f5f9 100644 --- a/src/cli/serve/mod.rs +++ b/src/cli/serve/mod.rs @@ -1,9 +1,7 @@ -use crate::{cfg::ConfigOptsServe, gen_page, server, CrateConfig}; -use std::{io::Write, path::PathBuf, process::{Command, Stdio}}; -use structopt::StructOpt; +use super::*; /// Run the WASM project on dev-server -#[derive(Clone, Debug, StructOpt)] +#[derive(Clone, Debug, Parser)] #[structopt(name = "serve")] pub struct Serve { #[structopt(flatten)] diff --git a/src/cli/translate/mod.rs b/src/cli/translate/mod.rs index a717d632a..4e23533aa 100644 --- a/src/cli/translate/mod.rs +++ b/src/cli/translate/mod.rs @@ -1,16 +1,7 @@ -use anyhow::Result; -use html_parser::Dom; -use html_parser::Element; -use html_parser::Node; -#[allow(unused_imports)] -use std::fmt::{Display, Formatter}; -use std::io::Read; -use std::path::PathBuf; -use std::process::exit; -use structopt::StructOpt; +use super::*; /// Build the Rust WASM app and all of its assets. -#[derive(Clone, Debug, StructOpt)] +#[derive(Clone, Debug, Parser)] #[structopt(name = "translate")] pub struct Translate { /// Activate debug mode diff --git a/tests/main.rs b/tests/main.rs new file mode 100644 index 000000000..f9bb6a890 --- /dev/null +++ b/tests/main.rs @@ -0,0 +1,4 @@ +#[test] +fn ready() { + println!("Compiled successfully!") +} \ No newline at end of file