Pythonic JavaScript that doesn't suck - a Python-to-JavaScript transpiler with clean syntax and performance
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Comprehensive command line interface with multiple operational modes for different development workflows. The CLI provides compilation, interactive development, code analysis, testing, and internationalization tools.
The primary CLI entry point that supports multiple operational modes.
# Basic command structure
rapydscript [mode] [options] [files...]
# Auto-detected modes (no mode specified)
rapydscript [options] [files...] # compile mode if files provided
rapydscript # repl mode if no files and TTYDefault mode for compiling RapydScript source files (.pyj) to JavaScript.
rapydscript compile [options] <input1.pyj> [input2.pyj ...]
rapydscript [options] <input1.pyj> [input2.pyj ...] # compile is defaultCompile Options:
# Output control
--output, -o <file> # Output file (default: STDOUT)
--bare, -b # Remove module wrapper
--uglify, -u # Minify the output
--omit_baselib, -m # Exclude base library functions
# Code processing
--keep_docstrings, -d # Preserve docstrings as __doc__ attributes
--discard_asserts, -a # Remove assert statements
--js_version, -j <5|6> # Target JavaScript version (default: 5)
# Module handling
--import_path, -p <paths> # Import search paths (: separated)
--cache_dir, -C <dir> # Cache directory for compiled files
--filename_for_stdin, -P <name> # Filename for STDIN data
# Advanced options
--comments <strategy> # Comment preservation (all|/regex/)
--stats # Display timing statistics
--execute, -x # Compile and execute immediatelyUsage Examples:
# Basic compilation
rapydscript app.pyj --output app.js
# Minified production build
rapydscript src/*.pyj --uglify --omit_baselib --output dist/app.min.js
# Development build with ES6 features
rapydscript main.pyj --js_version 6 --keep_docstrings --output build/main.js
# Execute RapydScript directly
rapydscript --execute script.pyj
# Compile from STDIN
cat source.pyj | rapydscript --output result.jsInteractive Read-Eval-Print-Loop for experimenting with RapydScript code.
rapydscript repl [options]
# REPL options
--no_js # Don't display compiled JavaScriptUsage Examples:
# Start interactive REPL
rapydscript repl
# REPL without showing generated JavaScript
rapydscript repl --no_jsStatic code analysis and error checking for RapydScript files.
rapydscript lint [options] <input1.pyj> [input2.pyj ...]
# Lint options
--globals, -g <names> # Additional global symbol names (comma-separated)
--noqa, -e <checks> # Skip specific lint checks (comma-separated)
--errorformat, -f <format> # Output format: human|json|vim|undef
--noqa_list # List all available lint checks
--stdin_filename <name> # Filename for STDIN data (default: STDIN)Available Lint Checks:
undef - Undefined variablesunused - Unused variablesredefined - Redefined variableseol-semicolon - End-of-line semicolonsUsage Examples:
# Basic linting
rapydscript lint src/app.pyj
# Lint with custom globals
rapydscript lint --globals "jQuery,$,console" src/*.pyj
# JSON output for tooling integration
rapydscript lint --errorformat json src/
# List available checks
rapydscript lint --noqa_list
# Lint from STDIN
cat source.pyj | rapydscript lint --stdin_filename "app.pyj"Run the RapydScript test suite with optional test filtering.
rapydscript test [test1] [test2] [...]
# Examples
rapydscript test # Run all tests
rapydscript test baselib # Run baselib tests only
rapydscript test functions loops # Run specific test categoriesCompile the RapydScript compiler itself (self-hosting).
rapydscript self [options]
# Self-compilation options
--complete, -c # Compile repeatedly until stable
--test, -t # Run test suite after compilation
--profile, -p # Run CPU profiler (output: self.cpuprofile)Usage Examples:
# Basic self-compilation
rapydscript self
# Complete self-compilation with testing
rapydscript self --complete --test
# Profile the compilation process
rapydscript self --profileExtract translatable strings from RapydScript source files for internationalization.
rapydscript gettext [options] <input1.pyj> [input_dir] [...]
# Gettext options
--omit_header, -m # Don't write .po header
--package_name <name> # Package name in header (default: XXX)
--package_version <version> # Package version in header (default: XXX)
--bugs_address <email> # Bug report email in headerTranslatable Functions Detected:
_() - Basic translation functiongettext() - Full gettext functionngettext() - Plural forms functionUsage Examples:
# Extract strings to .pot file
rapydscript gettext src/ > messages.pot
# Custom package information
rapydscript gettext --package_name "MyApp" --package_version "1.0.0" src/*.pyj
# Read from STDIN
cat source.pyj | rapydscript gettext > strings.potCompile .po translation files into .json format for browser usage.
rapydscript msgfmt [options]
# Msgfmt options
--use_fuzzy, -f # Include fuzzy translations (default: ignored)Usage Examples:
# Compile .po to .json
rapydscript msgfmt < messages.po > translations.json
# Include fuzzy translations
rapydscript msgfmt --use_fuzzy < messages.po > translations.jsonOptions available across all modes:
--help, -h # Show help message and exit
--version, -V # Show version and exitThe linter supports configuration via setup.cfg files:
# setup.cfg
[rapydscript]
globals=myglobalvar,otherglobalvar
noqa=undef,eol-semicolonControl linting within source files using special comments:
# Disable checks for specific lines
x = undefined_var # noqa: undef
# Disable checks for entire file (place near top)
# noqa: undef
# Define global symbols for file (place near top)
# globals: assert,myglobalvar# Module import search paths
export RAPYDSCRIPT_IMPORT_PATH="/path/to/modules:/another/path"# Development workflow
rapydscript lint src/
rapydscript src/main.pyj --output build/app.js --keep_docstrings
# Production build
rapydscript src/main.pyj --uglify --omit_baselib --js_version 6 --output dist/app.min.js
# Internationalization workflow
rapydscript gettext src/ > messages.pot
# ... translate messages.pot to messages.po ...
rapydscript msgfmt < messages.po > translations.json
# Testing and validation
rapydscript test
rapydscript lint --errorformat json src/ | jq '.errors | length'Install with Tessl CLI
npx tessl i tessl/npm-rapydscript-ng