cfg.rs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. use super::*;
  2. /// Config options for the build system.
  3. #[derive(Clone, Debug, Default, Deserialize, Parser)]
  4. pub struct ConfigOptsBuild {
  5. /// The index HTML file to drive the bundling process [default: index.html]
  6. #[clap(parse(from_os_str))]
  7. pub target: Option<PathBuf>,
  8. /// Build in release mode [default: false]
  9. #[clap(long)]
  10. #[serde(default)]
  11. pub release: bool,
  12. // Use verbose output [default: false]
  13. #[clap(long)]
  14. #[serde(default)]
  15. pub verbose: bool,
  16. /// Build a example [default: ""]
  17. #[clap(long)]
  18. pub example: Option<String>,
  19. /// Build with custom profile
  20. #[clap(long)]
  21. pub profile: Option<String>,
  22. /// Build platform: support Web & Desktop [default: "default_platform"]
  23. #[clap(long)]
  24. pub platform: Option<String>,
  25. /// Space separated list of features to activate
  26. #[clap(long)]
  27. pub features: Option<Vec<String>>,
  28. }
  29. #[derive(Clone, Debug, Default, Deserialize, Parser)]
  30. pub struct ConfigOptsServe {
  31. /// The index HTML file to drive the bundling process [default: index.html]
  32. #[clap(parse(from_os_str))]
  33. pub target: Option<PathBuf>,
  34. /// Port of dev server
  35. #[clap(long)]
  36. #[clap(default_value_t = 8080)]
  37. pub port: u16,
  38. /// Open the app in the default browser [default: false]
  39. #[clap(long)]
  40. #[serde(default)]
  41. pub open: bool,
  42. /// Build a example [default: ""]
  43. #[clap(long)]
  44. pub example: Option<String>,
  45. /// Build in release mode [default: false]
  46. #[clap(long)]
  47. #[serde(default)]
  48. pub release: bool,
  49. // Use verbose output [default: false]
  50. #[clap(long)]
  51. #[serde(default)]
  52. pub verbose: bool,
  53. /// Build with custom profile
  54. #[clap(long)]
  55. pub profile: Option<String>,
  56. /// Build platform: support Web & Desktop [default: "default_platform"]
  57. #[clap(long)]
  58. pub platform: Option<String>,
  59. /// Build with hot reloading rsx [default: false]
  60. #[clap(long)]
  61. #[serde(default)]
  62. pub hot_reload: bool,
  63. /// Space separated list of features to activate
  64. #[clap(long)]
  65. pub features: Option<Vec<String>>,
  66. }
  67. /// Ensure the given value for `--public-url` is formatted correctly.
  68. pub fn parse_public_url(val: &str) -> String {
  69. let prefix = if !val.starts_with('/') { "/" } else { "" };
  70. let suffix = if !val.ends_with('/') { "/" } else { "" };
  71. format!("{}{}{}", prefix, val, suffix)
  72. }