1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
use crate::parser::Localization;

#[cfg(target_family = "wasm")]
use serde::{Deserialize, Serialize};

#[cfg_attr(
    target_family = "wasm",
    wasm_bindgen::prelude::wasm_bindgen,
    derive(Serialize, Deserialize),
    serde(rename_all(serialize = "kebab-case", deserialize = "kebab-case"))
)]
#[derive(Debug, Copy, Clone, PartialEq, clap::ValueEnum, strum::EnumString, strum::EnumIter)]
#[strum(serialize_all = "kebab-case")]
pub enum Experiment {
    TailCalls,
    RestArgs,
}

/// Run the R REPL
#[cfg_attr(
    target_family = "wasm",
    wasm_bindgen::prelude::wasm_bindgen(getter_with_clone),
    derive(Serialize, Deserialize),
    serde(rename_all(serialize = "kebab-case", deserialize = "kebab-case"))
)]
#[cfg_attr(not(target_family = "wasm"), derive(clap::Parser))]
#[derive(Debug, Clone, Default)]
pub struct Cli {
    /// Localization to use for runtime
    #[cfg_attr(not(target_family = "wasm"), arg(short, long, default_value = "en"))]
    pub locale: Localization,

    /// Show the extended warranty information at startup
    #[cfg_attr(not(target_family = "wasm"), arg(long))]
    pub warranty: bool,

    /// Enable experimental language features
    #[cfg_attr(
        not(target_family = "wasm"),
        arg(short = 'x', long, value_delimiter = ',')
    )]
    pub experiments: Vec<Experiment>,
}