Skip to main content

euv_cli/args/
impl.rs

1use super::*;
2
3/// Conversion helpers between CLI arguments and `euv-core` types.
4impl RenderArg {
5    /// Converts a `RenderArg` into the core `RenderMode` enum.
6    ///
7    /// # Returns
8    ///
9    /// - `RenderMode` - Core rendering pipeline mode.
10    #[must_use]
11    pub const fn to_render_mode(self) -> RenderMode {
12        match self {
13            Self::Auto => RenderMode::Auto,
14            Self::Software => RenderMode::Software,
15            Self::Hardware => RenderMode::Hardware,
16            Self::Hybrid => RenderMode::Hybrid,
17        }
18    }
19
20    /// Returns the CLI flag string forwarded to `euv` applications.
21    ///
22    /// # Returns
23    ///
24    /// - `&'static str` - Render flag token.
25    #[must_use]
26    pub const fn as_flag(self) -> &'static str {
27        match self {
28            Self::Auto => RENDER_FLAG_AUTO,
29            Self::Software => RENDER_FLAG_SOFTWARE,
30            Self::Hardware => RENDER_FLAG_HARDWARE,
31            Self::Hybrid => RENDER_FLAG_HYBRID,
32        }
33    }
34}
35
36/// Wire string helpers for `HarmonyFormFactorArg`.
37impl HarmonyFormFactorArg {
38    /// Returns the canonical lowercase form factor label used by HarmonyOS builders.
39    ///
40    /// # Returns
41    ///
42    /// - `&'static str` - Lowercase form factor label.
43    #[must_use]
44    pub const fn as_str(self) -> &'static str {
45        match self {
46            Self::Phone => HARMONY_FORM_PHONE,
47            Self::Tablet => HARMONY_FORM_TABLET,
48            Self::Pc => HARMONY_FORM_PC,
49            Self::Foldable => HARMONY_FORM_FOLDABLE,
50            Self::Tv => HARMONY_FORM_TV,
51            Self::Car => HARMONY_FORM_CAR,
52            Self::Wearable => HARMONY_FORM_WEARABLE,
53        }
54    }
55}
56
57/// Classification helpers for `TargetArg`.
58impl TargetArg {
59    /// Returns `true` when this variant represents a multi-target group rather than a single concrete target.
60    ///
61    /// # Returns
62    ///
63    /// - `bool` - Whether this selector expands to a group of concrete targets.
64    #[must_use]
65    pub const fn is_group(self) -> bool {
66        matches!(
67            self,
68            Self::Desktop
69                | Self::Mobile
70                | Self::Apple
71                | Self::Terminal
72                | Self::HarmonyAll
73                | Self::Wearables
74                | Self::Miniapps
75                | Self::Quickapps
76                | Self::All
77        )
78    }
79}
80
81/// Canonical string helpers for `ProjectTemplateArg`.
82impl ProjectTemplateArg {
83    /// Returns the canonical lowercase CLI label for this scaffolding template.
84    ///
85    /// # Returns
86    ///
87    /// - `&'static str` - Lowercase template label.
88    #[must_use]
89    pub const fn as_str(self) -> &'static str {
90        match self {
91            Self::App => TEMPLATE_NAME_APP,
92            Self::Web => TEMPLATE_NAME_WEB,
93            Self::DynamicWidget => TEMPLATE_NAME_DYNAMIC_WIDGET,
94            Self::Docs => TEMPLATE_NAME_DOCS,
95        }
96    }
97}
98
99/// Canonical string helpers for `ShellKindArg`.
100impl ShellKindArg {
101    /// Returns the canonical lowercase CLI label for this shell dialect.
102    ///
103    /// # Returns
104    ///
105    /// - `&'static str` - Lowercase shell dialect label.
106    #[must_use]
107    pub const fn as_str(self) -> &'static str {
108        match self {
109            Self::Bash => SHELL_NAME_BASH,
110            Self::Zsh => SHELL_NAME_ZSH,
111            Self::Fish => SHELL_NAME_FISH,
112            Self::Powershell => SHELL_NAME_POWERSHELL,
113        }
114    }
115}