UNPKG

mowascript

Version:

MowaScript language implementation

110 lines (78 loc) โ€ข 2.27 kB
[[๐ŸŒ€ Interslavic](../../05_cli.md) ยท [๐ŸŒฒ East Slavic](../east/05_cli.md)] # ๐Ÿ’ป MowaJS Command-Line Interface (CLI) MowaJS comes with a built-in CLI that lets you quickly run, compile, watch, and initialize projects using `.mowa` files. --- ## ๐Ÿ“ฆ Installation (globally or via `npx`) ```bash # global installation npm install -g mowascript mowa init npm install npm run watch # or run directly via npx npx mowascript <command> ``` --- ## ๐Ÿ”ง CLI Commands ### `mowa init <project_name>` Initializes a new project with starter structure and templates: ``` my-project/ โ”œโ”€โ”€ docs/ โ”‚ โ””โ”€โ”€ doc.md โ”œโ”€โ”€ src/ โ”‚ โ””โ”€โ”€ index.mowa โ”œโ”€โ”€ dist/ โ”œโ”€โ”€ package.json โ”œโ”€โ”€ README.md ``` ๐Ÿงฉ Creates `package.json`, copies template files, adds dependencies. --- ### `mowa build` Compiles all `.mowa` files from `src/` into `.js` files in `dist/`. - Reads all `.mowa` files in `src/` - Transpiles them to JavaScript - Saves output in `dist/` with the same structure --- ### `mowa run <file.mowa>` Runs a `.mowa` file directly: - Transpiles to JavaScript - Prints the output code to console - Executes it via `eval` --- ### `mowa watch` Watch mode: - Watches all `.mowa` files inside `src/` - Automatically recompiles on change - Deletes corresponding `.js` when `.mowa` is removed Super useful during development โ€” no need to re-run `build` manually. --- ## ๐Ÿ“„ Under the Hood The CLI is implemented in `mowa.js`. Core functions include: - `initProject()` โ€” creates structure and package.json - `buildProject()` โ€” compiles `.mowa` โ†’ `.js` - `runFile()` โ€” runs a file via `eval` - `watchProject()` โ€” live watch and transpile --- ## ๐Ÿง  Tips - Use `mowa watch` during development - Write code in `src/`, results appear in `dist/` - Add `npm run build` to your scripts for convenience --- ## โ›“ Sample `package.json` after `init` ```json { "name": "my-project", "version": "1.0.0", "type": "module", "scripts": { "build": "mowa build", "start": "node dist/index.js" }, "dependencies": { "mowascript": "^1.0.0" } } ``` --- This CLI is the heart of MowaJS. It makes running, compiling, and bootstrapping projects smooth โ€” and your experience delightfully Slavic โค๏ธ