summaryrefslogtreecommitdiffstats
path: root/xtask/src/flags.rs
blob: c3afe2df65831d84466a4dad6926793a58b720f9 (plain)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
//! CLI flags for `cargo xtask`
use std::ffi::OsString;
use std::path::PathBuf;

xflags::xflags! {
    src "./src/flags.rs"

    /// Custom build commands for zellij
    cmd xtask {
        /// Deprecation warning. Compatibility to transition from `cargo make`.
        cmd deprecated {
            repeated args: OsString
        }

        /// Tasks for the CI
        cmd ci {
            /// end-to-end tests
            cmd e2e {
                /// Build E2E binary of zellij
                optional --build
                /// Run the E2E tests
                optional --test
                /// Additional arguments for `--test`
                repeated args: OsString
            }

            /// Perform cross-compiled release builds
            cmd cross {
                /// Target-triple to compile the application for
                required triple: OsString
            }
        }

        /// Build the manpage
        cmd manpage {}

        /// Publish zellij and all the sub-crates
        cmd publish {
            /// Perform a dry-run (don't push/publish anything)
            optional --dry-run
        }

        /// Package zellij for distribution (result found in ./target/dist)
        cmd dist {}

        /// Run `cargo clippy` on all crates
        cmd clippy {}

        /// Sequentially call: format, build, test, clippy
        cmd make {
            /// Build in release mode without debug symbols
            optional -r, --release
            /// Clean project before building
            optional -c, --clean
        }

        /// Generate a runnable `zellij` executable with plugins bundled
        cmd install {
            required destination: PathBuf
        }

        /// Run debug version of zellij
        cmd run {
            /// Take plugins from here, skip building plugins. Passed to zellij verbatim
            optional --data-dir path: PathBuf
            /// Arguments to pass after `cargo run --`
            repeated args: OsString
        }

        /// Run `cargo fmt` on all crates
        cmd format {
            /// Run `cargo fmt` in check mode
            optional --check
        }

        /// Run application tests
        cmd test {
            /// Arguments to pass after `cargo test --`
            repeated args: OsString
        }

        /// Build the application and all plugins
        cmd build {
            /// Build in release mode without debug symbols
            optional -r, --release
            /// Build only the plugins
            optional -p, --plugins-only
            /// Build everything except the plugins
            optional --no-plugins
        }
    }
}
// generated start
// The following code is generated by `xflags` macro.
// Run `env UPDATE_XFLAGS=1 cargo build` to regenerate.
#[derive(Debug)]
pub struct Xtask {
    pub subcommand: XtaskCmd,
}

#[derive(Debug)]
pub enum XtaskCmd {
    Deprecated(Deprecated),
    Ci(Ci),
    Manpage(Manpage),
    Publish(Publish),
    Dist(Dist),
    Clippy(Clippy),
    Make(Make),
    Install(Install),
    Run(Run),
    Format(Format),
    Test(Test),
    Build(Build),
}

#[derive(Debug)]
pub struct Deprecated {
    pub args: Vec<OsString>,
}

#[derive(Debug)]
pub struct Ci {
    pub subcommand: CiCmd,
}

#[derive(Debug)]
pub enum CiCmd {
    E2e(E2e),
    Cross(Cross),
}

#[derive(Debug)]
pub struct E2e {
    pub args: Vec<OsString>,

    pub build: bool,
    pub test: bool,
}

#[derive(Debug)]
pub struct Cross {
    pub triple: OsString,
}

#[derive(Debug)]
pub struct Manpage;

#[derive(Debug)]
pub struct Publish {
    pub dry_run: bool,
}

#[derive(Debug)]
pub struct Dist;

#[derive(Debug)]
pub struct Clippy;

#[derive(Debug)]
pub struct Make {
    pub release: bool,
    pub clean: bool,
}

#[derive(Debug)]
pub struct Install {
    pub destination: PathBuf,
}

#[derive(Debug)]
pub struct Run {
    pub args: Vec<OsString>,

    pub data_dir: Option<PathBuf>,
}

#[derive(Debug)]
pub struct Format {
    pub check: bool,
}

#[derive(Debug)]
pub struct Test {
    pub args: Vec<OsString>,
}

#[derive(Debug)]
pub struct Build {
    pub release: bool,
    pub plugins_only: bool,
    pub no_plugins: bool,
}

impl Xtask {
    #[allow(dead_code)]
    pub fn from_env_or_exit() -> Self {
        Self::from_env_or_exit_()
    }

    #[allow(dead_code)]
    pub fn from_env() -> xflags::Result<Self> {
        Self::from_env_()
    }

    #[allow(dead_code)]
    pub fn from_vec(args: Vec<std::ffi::OsString>) -> xflags::Result<Self> {
        Self::from_vec_(args)
    }
}
// generated end