0
# Command Line Interface
1
2
Comprehensive command line interface with multiple operational modes for different development workflows. The CLI provides compilation, interactive development, code analysis, testing, and internationalization tools.
3
4
## Capabilities
5
6
### Main Command
7
8
The primary CLI entry point that supports multiple operational modes.
9
10
```bash { .api }
11
# Basic command structure
12
rapydscript [mode] [options] [files...]
13
14
# Auto-detected modes (no mode specified)
15
rapydscript [options] [files...] # compile mode if files provided
16
rapydscript # repl mode if no files and TTY
17
```
18
19
### Compile Mode
20
21
Default mode for compiling RapydScript source files (.pyj) to JavaScript.
22
23
```bash { .api }
24
rapydscript compile [options] <input1.pyj> [input2.pyj ...]
25
rapydscript [options] <input1.pyj> [input2.pyj ...] # compile is default
26
```
27
28
**Compile Options:**
29
30
```bash { .api }
31
# Output control
32
--output, -o <file> # Output file (default: STDOUT)
33
--bare, -b # Remove module wrapper
34
--uglify, -u # Minify the output
35
--omit_baselib, -m # Exclude base library functions
36
37
# Code processing
38
--keep_docstrings, -d # Preserve docstrings as __doc__ attributes
39
--discard_asserts, -a # Remove assert statements
40
--js_version, -j <5|6> # Target JavaScript version (default: 5)
41
42
# Module handling
43
--import_path, -p <paths> # Import search paths (: separated)
44
--cache_dir, -C <dir> # Cache directory for compiled files
45
--filename_for_stdin, -P <name> # Filename for STDIN data
46
47
# Advanced options
48
--comments <strategy> # Comment preservation (all|/regex/)
49
--stats # Display timing statistics
50
--execute, -x # Compile and execute immediately
51
```
52
53
**Usage Examples:**
54
55
```bash
56
# Basic compilation
57
rapydscript app.pyj --output app.js
58
59
# Minified production build
60
rapydscript src/*.pyj --uglify --omit_baselib --output dist/app.min.js
61
62
# Development build with ES6 features
63
rapydscript main.pyj --js_version 6 --keep_docstrings --output build/main.js
64
65
# Execute RapydScript directly
66
rapydscript --execute script.pyj
67
68
# Compile from STDIN
69
cat source.pyj | rapydscript --output result.js
70
```
71
72
### REPL Mode
73
74
Interactive Read-Eval-Print-Loop for experimenting with RapydScript code.
75
76
```bash { .api }
77
rapydscript repl [options]
78
79
# REPL options
80
--no_js # Don't display compiled JavaScript
81
```
82
83
**Usage Examples:**
84
85
```bash
86
# Start interactive REPL
87
rapydscript repl
88
89
# REPL without showing generated JavaScript
90
rapydscript repl --no_js
91
```
92
93
### Lint Mode
94
95
Static code analysis and error checking for RapydScript files.
96
97
```bash { .api }
98
rapydscript lint [options] <input1.pyj> [input2.pyj ...]
99
100
# Lint options
101
--globals, -g <names> # Additional global symbol names (comma-separated)
102
--noqa, -e <checks> # Skip specific lint checks (comma-separated)
103
--errorformat, -f <format> # Output format: human|json|vim|undef
104
--noqa_list # List all available lint checks
105
--stdin_filename <name> # Filename for STDIN data (default: STDIN)
106
```
107
108
**Available Lint Checks:**
109
- `undef` - Undefined variables
110
- `unused` - Unused variables
111
- `redefined` - Redefined variables
112
- `eol-semicolon` - End-of-line semicolons
113
114
**Usage Examples:**
115
116
```bash
117
# Basic linting
118
rapydscript lint src/app.pyj
119
120
# Lint with custom globals
121
rapydscript lint --globals "jQuery,$,console" src/*.pyj
122
123
# JSON output for tooling integration
124
rapydscript lint --errorformat json src/
125
126
# List available checks
127
rapydscript lint --noqa_list
128
129
# Lint from STDIN
130
cat source.pyj | rapydscript lint --stdin_filename "app.pyj"
131
```
132
133
### Test Mode
134
135
Run the RapydScript test suite with optional test filtering.
136
137
```bash { .api }
138
rapydscript test [test1] [test2] [...]
139
140
# Examples
141
rapydscript test # Run all tests
142
rapydscript test baselib # Run baselib tests only
143
rapydscript test functions loops # Run specific test categories
144
```
145
146
### Self Mode
147
148
Compile the RapydScript compiler itself (self-hosting).
149
150
```bash { .api }
151
rapydscript self [options]
152
153
# Self-compilation options
154
--complete, -c # Compile repeatedly until stable
155
--test, -t # Run test suite after compilation
156
--profile, -p # Run CPU profiler (output: self.cpuprofile)
157
```
158
159
**Usage Examples:**
160
161
```bash
162
# Basic self-compilation
163
rapydscript self
164
165
# Complete self-compilation with testing
166
rapydscript self --complete --test
167
168
# Profile the compilation process
169
rapydscript self --profile
170
```
171
172
### Gettext Mode
173
174
Extract translatable strings from RapydScript source files for internationalization.
175
176
```bash { .api }
177
rapydscript gettext [options] <input1.pyj> [input_dir] [...]
178
179
# Gettext options
180
--omit_header, -m # Don't write .po header
181
--package_name <name> # Package name in header (default: XXX)
182
--package_version <version> # Package version in header (default: XXX)
183
--bugs_address <email> # Bug report email in header
184
```
185
186
**Translatable Functions Detected:**
187
- `_()` - Basic translation function
188
- `gettext()` - Full gettext function
189
- `ngettext()` - Plural forms function
190
191
**Usage Examples:**
192
193
```bash
194
# Extract strings to .pot file
195
rapydscript gettext src/ > messages.pot
196
197
# Custom package information
198
rapydscript gettext --package_name "MyApp" --package_version "1.0.0" src/*.pyj
199
200
# Read from STDIN
201
cat source.pyj | rapydscript gettext > strings.pot
202
```
203
204
### Msgfmt Mode
205
206
Compile .po translation files into .json format for browser usage.
207
208
```bash { .api }
209
rapydscript msgfmt [options]
210
211
# Msgfmt options
212
--use_fuzzy, -f # Include fuzzy translations (default: ignored)
213
```
214
215
**Usage Examples:**
216
217
```bash
218
# Compile .po to .json
219
rapydscript msgfmt < messages.po > translations.json
220
221
# Include fuzzy translations
222
rapydscript msgfmt --use_fuzzy < messages.po > translations.json
223
```
224
225
### Global Options
226
227
Options available across all modes:
228
229
```bash { .api }
230
--help, -h # Show help message and exit
231
--version, -V # Show version and exit
232
```
233
234
### Configuration Files
235
236
The linter supports configuration via `setup.cfg` files:
237
238
```ini
239
# setup.cfg
240
[rapydscript]
241
globals=myglobalvar,otherglobalvar
242
noqa=undef,eol-semicolon
243
```
244
245
### Inline Lint Control
246
247
Control linting within source files using special comments:
248
249
```python
250
# Disable checks for specific lines
251
x = undefined_var # noqa: undef
252
253
# Disable checks for entire file (place near top)
254
# noqa: undef
255
256
# Define global symbols for file (place near top)
257
# globals: assert,myglobalvar
258
```
259
260
### Environment Variables
261
262
```bash { .api }
263
# Module import search paths
264
export RAPYDSCRIPT_IMPORT_PATH="/path/to/modules:/another/path"
265
```
266
267
### Complete Workflow Examples
268
269
```bash
270
# Development workflow
271
rapydscript lint src/
272
rapydscript src/main.pyj --output build/app.js --keep_docstrings
273
274
# Production build
275
rapydscript src/main.pyj --uglify --omit_baselib --js_version 6 --output dist/app.min.js
276
277
# Internationalization workflow
278
rapydscript gettext src/ > messages.pot
279
# ... translate messages.pot to messages.po ...
280
rapydscript msgfmt < messages.po > translations.json
281
282
# Testing and validation
283
rapydscript test
284
rapydscript lint --errorformat json src/ | jq '.errors | length'
285
```