cli.rs 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. use argh::FromArgs;
  2. #[derive(FromArgs, PartialEq, Debug)]
  3. /// Top-level command.
  4. pub struct LaunchOptions {
  5. #[argh(subcommand)]
  6. pub command: LaunchCommand,
  7. }
  8. /// The various kinds of commands that `wasm-pack` can execute.
  9. #[derive(FromArgs, PartialEq, Debug)]
  10. #[argh(subcommand)]
  11. pub enum LaunchCommand {
  12. Develop(DevelopOptions),
  13. Build(BuildOptions),
  14. Test(TestOptions),
  15. Publish(PublishOptions),
  16. }
  17. /// Publish your yew application to Github Pages, Netlify, or S3
  18. #[derive(FromArgs, PartialEq, Debug)]
  19. #[argh(subcommand, name = "publish")]
  20. pub struct PublishOptions {}
  21. /// 🔬 test your yew application!
  22. #[derive(FromArgs, PartialEq, Debug)]
  23. #[argh(subcommand, name = "test")]
  24. pub struct TestOptions {
  25. /// an example in the crate
  26. #[argh(option)]
  27. pub example: Option<String>,
  28. }
  29. /// 🏗️ Build your yew application
  30. #[derive(FromArgs, PartialEq, Debug, Clone)]
  31. #[argh(subcommand, name = "build")]
  32. pub struct BuildOptions {
  33. /// an optional direction which is "up" by default
  34. #[argh(option, short = 'o', default = "String::from(\"public\")")]
  35. pub outdir: String,
  36. /// an example in the crate
  37. #[argh(option)]
  38. pub example: Option<String>,
  39. }
  40. /// 🛠 Start a development server
  41. #[derive(FromArgs, PartialEq, Debug)]
  42. #[argh(subcommand, name = "develop")]
  43. pub struct DevelopOptions {
  44. /// an example in the crate
  45. #[argh(option)]
  46. pub example: Option<String>,
  47. }