fob_cli/cli/enums.rs
1use clap::ValueEnum;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5/// Output format for bundled code
6#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
7pub enum Format {
8 /// ECMAScript modules (import/export syntax)
9 ///
10 /// Modern format with static imports, enabling tree shaking and code splitting.
11 /// Supported in modern browsers and Node.js 14+.
12 #[value(name = "esm")]
13 Esm,
14
15 /// CommonJS modules (require/module.exports)
16 ///
17 /// Traditional Node.js format. Use this for maximum compatibility with
18 /// older Node.js versions and tools that don't support ESM.
19 #[value(name = "cjs")]
20 Cjs,
21
22 /// Immediately Invoked Function Expression
23 ///
24 /// Wraps code in a function that executes immediately. Suitable for
25 /// browser script tags and environments without module support.
26 #[value(name = "iife")]
27 Iife,
28}
29
30/// Source map generation mode
31#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
32pub enum SourceMapMode {
33 /// Inline source maps embedded in the bundle
34 ///
35 /// The source map is encoded as a base64 data URL and appended to the bundle.
36 /// Results in a single file but increases bundle size.
37 #[value(name = "inline")]
38 Inline,
39
40 /// External source map files (.map)
41 ///
42 /// Generates separate .map files alongside bundles. Keeps bundles smaller
43 /// and allows selective loading of source maps.
44 #[value(name = "external")]
45 External,
46
47 /// Generate source maps but don't reference them
48 ///
49 /// Creates .map files but doesn't add sourceMappingURL comments to bundles.
50 /// Useful for production builds where you want maps for debugging but
51 /// don't want to expose source structure to end users.
52 #[value(name = "hidden")]
53 Hidden,
54}
55
56/// Target platform environment
57#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
58pub enum Platform {
59 /// Browser environment
60 ///
61 /// Assumes APIs like window, document, fetch are available.
62 /// Node.js-specific APIs (fs, path, etc.) are not available.
63 #[value(name = "browser")]
64 Browser,
65
66 /// Node.js environment
67 ///
68 /// Assumes Node.js built-in modules are available (fs, path, http, etc.).
69 /// Browser-specific APIs are not available.
70 #[value(name = "node")]
71 Node,
72}
73
74/// ECMAScript target version
75///
76/// Determines which JavaScript language features are available in the output.
77/// Later versions enable more modern syntax and APIs but require newer runtimes.
78#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum, Serialize, Deserialize, JsonSchema)]
79#[serde(rename_all = "lowercase")]
80pub enum EsTarget {
81 /// ECMAScript 2015 (ES6)
82 ///
83 /// Maximum compatibility. Supports IE11, Node.js 4+, and all modern browsers.
84 /// Features: classes, arrow functions, promises, let/const.
85 #[value(name = "es2015")]
86 #[serde(rename = "es2015")]
87 Es2015,
88
89 /// ECMAScript 2016
90 ///
91 /// Adds: Array.prototype.includes, exponentiation operator (**)
92 #[value(name = "es2016")]
93 #[serde(rename = "es2016")]
94 Es2016,
95
96 /// ECMAScript 2017
97 ///
98 /// Adds: async/await, Object.entries/values, string padding
99 #[value(name = "es2017")]
100 #[serde(rename = "es2017")]
101 Es2017,
102
103 /// ECMAScript 2018
104 ///
105 /// Adds: async iteration, rest/spread properties, Promise.finally
106 #[value(name = "es2018")]
107 #[serde(rename = "es2018")]
108 Es2018,
109
110 /// ECMAScript 2019
111 ///
112 /// Adds: Array.prototype.flat/flatMap, Object.fromEntries, optional catch
113 #[value(name = "es2019")]
114 #[serde(rename = "es2019")]
115 Es2019,
116
117 /// ECMAScript 2020
118 ///
119 /// Adds: optional chaining (?.), nullish coalescing (??), BigInt, dynamic import
120 /// Good balance between modern features and compatibility. Node.js 14+, modern browsers.
121 #[value(name = "es2020")]
122 #[serde(rename = "es2020")]
123 Es2020,
124
125 /// ECMAScript 2021
126 ///
127 /// Adds: String.prototype.replaceAll, Promise.any, logical assignment operators
128 #[value(name = "es2021")]
129 #[serde(rename = "es2021")]
130 Es2021,
131
132 /// ECMAScript 2022
133 ///
134 /// Adds: class fields, top-level await, Array.prototype.at, Object.hasOwn
135 #[value(name = "es2022")]
136 #[serde(rename = "es2022")]
137 Es2022,
138
139 /// Latest ECMAScript features
140 ///
141 /// Uses the newest JavaScript syntax and APIs. Requires the latest Node.js
142 /// and browsers. Output may break in older environments.
143 #[value(name = "esnext")]
144 #[serde(rename = "esnext")]
145 Esnext,
146}
147
148/// Output format for generated documentation.
149#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
150pub enum DocsFormat {
151 #[value(name = "md")]
152 Markdown,
153 #[value(name = "json")]
154 Json,
155 #[value(name = "both")]
156 Both,
157}
158
159/// LLM enhancement mode for documentation
160#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
161pub enum DocsEnhanceMode {
162 /// Only enhance symbols with no documentation
163 ///
164 /// Fastest mode - only processes completely undocumented symbols.
165 /// Recommended for quick documentation passes.
166 #[value(name = "missing")]
167 Missing,
168
169 /// Enhance incomplete documentation
170 ///
171 /// Processes symbols that are missing parameters, return types,
172 /// or examples. Good balance between speed and thoroughness.
173 #[value(name = "incomplete")]
174 Incomplete,
175
176 /// Enhance all symbols
177 ///
178 /// Most thorough - enhances all symbols, even those with complete
179 /// JSDoc, merging LLM output with existing documentation.
180 #[value(name = "all")]
181 All,
182}
183
184/// Merge strategy for writing documentation back to source files.
185#[derive(Copy, Clone, PartialEq, Eq, Debug, ValueEnum)]
186pub enum DocsMergeStrategy {
187 /// Merge LLM output with existing JSDoc
188 ///
189 /// Preserves custom tags like @deprecated, @internal, etc.
190 /// Adds or updates description, params, returns, and examples.
191 #[value(name = "merge")]
192 Merge,
193
194 /// Replace existing JSDoc entirely
195 ///
196 /// Completely replaces existing documentation with LLM output.
197 /// Use with caution as it will remove custom tags.
198 #[value(name = "replace")]
199 Replace,
200
201 /// Skip symbols with existing JSDoc
202 ///
203 /// Only adds documentation to symbols that have no JSDoc at all.
204 /// Useful for preserving all hand-written documentation.
205 #[value(name = "skip")]
206 Skip,
207}