|
@@ -13,6 +13,10 @@ pub enum Config {
|
|
#[clap(long)]
|
|
#[clap(long)]
|
|
#[serde(default)]
|
|
#[serde(default)]
|
|
force: bool,
|
|
force: bool,
|
|
|
|
+
|
|
|
|
+ /// Project default platform
|
|
|
|
+ #[clap(long, default_value = "web")]
|
|
|
|
+ platform: String,
|
|
},
|
|
},
|
|
}
|
|
}
|
|
|
|
|
|
@@ -20,7 +24,11 @@ impl Config {
|
|
pub fn config(self) -> Result<()> {
|
|
pub fn config(self) -> Result<()> {
|
|
let crate_root = crate::cargo::crate_root()?;
|
|
let crate_root = crate::cargo::crate_root()?;
|
|
match self {
|
|
match self {
|
|
- Config::Init { name, force } => {
|
|
|
|
|
|
+ Config::Init {
|
|
|
|
+ name,
|
|
|
|
+ force,
|
|
|
|
+ platform,
|
|
|
|
+ } => {
|
|
let conf_path = crate_root.join("Dioxus.toml");
|
|
let conf_path = crate_root.join("Dioxus.toml");
|
|
if conf_path.is_file() && !force {
|
|
if conf_path.is_file() && !force {
|
|
log::warn!(
|
|
log::warn!(
|
|
@@ -30,7 +38,8 @@ impl Config {
|
|
}
|
|
}
|
|
let mut file = File::create(conf_path)?;
|
|
let mut file = File::create(conf_path)?;
|
|
let content = String::from(include_str!("../../assets/dioxus.toml"))
|
|
let content = String::from(include_str!("../../assets/dioxus.toml"))
|
|
- .replace("{{project-name}}", &name);
|
|
|
|
|
|
+ .replace("{{project-name}}", &name)
|
|
|
|
+ .replace("{{default-platform}}", &platform);
|
|
file.write_all(content.as_bytes())?;
|
|
file.write_all(content.as_bytes())?;
|
|
log::info!("🚩 Init config file completed.");
|
|
log::info!("🚩 Init config file completed.");
|
|
}
|
|
}
|