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
//! Clap-derived CLI types for the legacy `windjammer` binary.
use clap::{Parser, Subcommand, ValueEnum};
use std::path::PathBuf;
#[derive(Debug, Clone, Copy, PartialEq, Eq, ValueEnum)]
pub enum CompilationTarget {
/// Native Rust binary
Rust,
/// Go source code (experimental)
Go,
/// WebAssembly
Wasm,
/// Node.js native modules (future)
Node,
/// Python FFI via PyO3 (future)
Python,
/// C FFI (future)
C,
}
#[derive(Parser)]
#[command(name = "windjammer")]
#[command(about = "Windjammer - A simple language that transpiles to Rust", long_about = None)]
pub struct Cli {
#[command(subcommand)]
pub command: Commands,
}
#[derive(Subcommand)]
pub enum Commands {
/// Build a Windjammer project
Build {
/// Input directory or file
#[arg(short, long, value_name = "PATH")]
path: PathBuf,
/// Output directory for generated Rust code
#[arg(short, long, value_name = "OUTPUT")]
output: PathBuf,
/// Compilation target (wasm, node, python, c)
#[arg(short, long, value_enum, default_value = "wasm")]
target: CompilationTarget,
/// Run cargo build after transpilation and show errors
#[arg(long)]
check: bool,
/// Show raw Rust errors instead of translated Windjammer errors
#[arg(long)]
raw_errors: bool,
/// Library mode: exclude test main() functions from output
#[arg(long)]
library: bool,
/// Auto-generate mod.rs with pub mod declarations and re-exports
#[arg(long)]
module_file: bool,
/// Disable Rust leakage linter warnings (style, .unwrap(), .iter(), etc.)
#[arg(long)]
no_lint: bool,
},
/// Check a Windjammer project for errors (transpile + cargo check)
Check {
/// Input directory or file
#[arg(short, long, value_name = "PATH")]
path: PathBuf,
/// Output directory for generated Rust code
#[arg(short, long, value_name = "OUTPUT")]
output: PathBuf,
/// Compilation target
#[arg(short, long, value_enum, default_value = "wasm")]
target: CompilationTarget,
/// Show raw Rust errors instead of translated Windjammer errors
#[arg(long)]
raw_errors: bool,
},
/// Lint a Windjammer project (code quality, style, performance, security)
Lint {
/// Input directory or file
#[arg(short, long, value_name = "PATH")]
path: PathBuf,
/// Maximum function length
#[arg(long, default_value = "50")]
max_function_length: usize,
/// Maximum file length
#[arg(long, default_value = "500")]
max_file_length: usize,
/// Maximum complexity score
#[arg(long, default_value = "10")]
max_complexity: usize,
/// Disable unused code checks
#[arg(long)]
no_unused: bool,
/// Disable style checks
#[arg(long)]
no_style: bool,
/// Show only errors
#[arg(long)]
errors_only: bool,
/// JSON output format
#[arg(long)]
json: bool,
/// Enable auto-fix for supported rules
#[arg(long)]
fix: bool,
},
/// Eject to pure Rust - convert your Windjammer project to a standalone Rust project
Eject {
/// Input directory or file
#[arg(short, long, value_name = "PATH")]
path: PathBuf,
/// Output directory for ejected Rust project
#[arg(short, long, value_name = "OUTPUT")]
output: PathBuf,
/// Compilation target
#[arg(short, long, value_enum, default_value = "wasm")]
target: CompilationTarget,
/// Run rustfmt on generated code
#[arg(long, default_value = "true")]
format: bool,
/// Add helpful comments explaining Windjammer features
#[arg(long, default_value = "true")]
comments: bool,
/// Skip Cargo.toml generation (use existing)
#[arg(long)]
no_cargo_toml: bool,
},
/// Run a Windjammer file (build + cargo run, or --interpret for instant execution)
Run {
/// Input file to run
#[arg(value_name = "FILE")]
file: PathBuf,
/// Compilation target
#[arg(short, long, value_enum, default_value = "rust")]
target: CompilationTarget,
/// Interpret directly (Windjammerscript mode) — no compilation, instant execution.
/// Same .wj source can later be compiled with `wj build` for production.
#[arg(long)]
interpret: bool,
/// Arguments to pass to the program
#[arg(last = true)]
args: Vec<String>,
},
/// Start the Windjammerscript REPL (interactive interpreter)
Repl {},
/// Run tests (discovers and runs all test functions)
Test {
/// Directory or file containing tests (defaults to current directory)
#[arg(value_name = "PATH")]
path: Option<PathBuf>,
/// Run only tests matching this pattern
#[arg(short, long)]
filter: Option<String>,
/// Show output from passing tests
#[arg(long)]
nocapture: bool,
/// Run tests in parallel (default: true)
#[arg(long, default_value = "true")]
parallel: bool,
/// Output results as JSON for tooling
#[arg(long)]
json: bool,
},
}