pub(crate) mod autoformat;
pub(crate) mod build;
pub(crate) mod build_assets;
pub(crate) mod bundle;
pub(crate) mod check;
pub(crate) mod component;
pub(crate) mod config;
pub(crate) mod create;
pub(crate) mod doctor;
pub(crate) mod hotpatch;
pub(crate) mod init;
pub(crate) mod link;
pub(crate) mod platform_override;
pub(crate) mod print;
pub(crate) mod run;
pub(crate) mod serve;
pub(crate) mod shell_completions;
pub(crate) mod target;
pub(crate) mod translate;
pub(crate) mod update;
pub(crate) mod verbosity;
pub(crate) use build::*;
pub(crate) use serve::*;
pub(crate) use target::*;
pub(crate) use verbosity::*;
use crate::platform_override::CommandWithPlatformOverrides;
use crate::Anonymized;
use crate::{error::Result, Error, StructuredOutput};
use clap::builder::styling::{AnsiColor, Effects, Style, Styles};
use clap::{Parser, Subcommand};
use html_parser::Dom;
use serde::Deserialize;
use serde_json::{json, Value};
use std::sync::LazyLock;
use std::{
fmt::Display,
fs::File,
io::{Read, Write},
path::PathBuf,
process::Command,
};
#[derive(Parser)]
#[clap(name = "dioxus", version = VERSION.as_str())]
#[clap(styles = CARGO_STYLING)]
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) action: Commands,
#[command(flatten)]
pub(crate) verbosity: Verbosity,
}
#[derive(Subcommand)]
pub(crate) enum Commands {
#[clap(name = "new")]
New(create::Create),
#[clap(name = "serve")]
Serve(serve::ServeArgs),
#[clap(name = "bundle")]
Bundle(bundle::Bundle),
#[clap(name = "build")]
Build(CommandWithPlatformOverrides<build::BuildArgs>),
#[clap(name = "run")]
Run(run::RunArgs),
#[clap(name = "init")]
Init(init::Init),
#[clap(name = "doctor")]
Doctor(doctor::Doctor),
#[clap(name = "completions")]
ShellCompletions(shell_completions::ShellCompletions),
#[clap(name = "print")]
#[clap(subcommand)]
Print(print::Print),
#[clap(name = "translate")]
Translate(translate::Translate),
#[clap(name = "fmt")]
Autoformat(autoformat::Autoformat),
#[clap(name = "check")]
Check(check::Check),
#[clap(subcommand)]
#[clap(name = "config")]
Config(config::Config),
#[clap(name = "self-update")]
SelfUpdate(update::SelfUpdate),
#[clap(name = "tools")]
#[clap(subcommand)]
Tools(BuildTools),
#[clap(name = "components")]
#[clap(subcommand)]
Components(component::ComponentCommand),
}
#[allow(clippy::large_enum_variant)]
#[derive(Subcommand)]
pub enum BuildTools {
#[clap(name = "assets")]
BuildAssets(build_assets::BuildAssets),
#[clap(name = "hotpatch")]
HotpatchTip(hotpatch::HotpatchTip),
}
pub(crate) static VERSION: LazyLock<String> = LazyLock::new(|| {
format!(
"{} ({})",
crate::dx_build_info::PKG_VERSION,
crate::dx_build_info::GIT_COMMIT_HASH_SHORT.unwrap_or("was built without git repository")
)
});
pub(crate) const CARGO_STYLING: Styles = Styles::styled()
.header(styles::HEADER)
.usage(styles::USAGE)
.literal(styles::LITERAL)
.placeholder(styles::PLACEHOLDER)
.error(styles::ERROR)
.valid(styles::VALID)
.invalid(styles::INVALID);
pub mod styles {
use super::*;
pub(crate) const HEADER: Style = AnsiColor::Green.on_default().effects(Effects::BOLD);
pub(crate) const USAGE: Style = AnsiColor::Green.on_default().effects(Effects::BOLD);
pub(crate) const LITERAL: Style = AnsiColor::Cyan.on_default().effects(Effects::BOLD);
pub(crate) const PLACEHOLDER: Style = AnsiColor::Cyan.on_default();
pub(crate) const ERROR: Style = AnsiColor::Red.on_default().effects(Effects::BOLD);
pub(crate) const VALID: Style = AnsiColor::Cyan.on_default().effects(Effects::BOLD);
pub(crate) const INVALID: Style = AnsiColor::Yellow.on_default().effects(Effects::BOLD);
pub(crate) const GLOW_STYLE: Style = AnsiColor::Yellow.on_default();
pub(crate) const NOTE_STYLE: Style = AnsiColor::Green.on_default();
pub(crate) const LINK_STYLE: Style = AnsiColor::Blue.on_default();
pub(crate) const ERROR_STYLE: Style = AnsiColor::Red.on_default();
pub(crate) const HINT_STYLE: Style = clap::builder::styling::Ansi256Color(244).on_default();
}