|
Download tasks/data/reverse/aaveshdev__dragon.e4245fe/environment/docs/cli.md from Lego-X/ProgramGen: direct link, hf CLI and curl.
- Browser
- Download file 4.15 kB
-
https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/aaveshdev__dragon.e4245fe/environment/docs/cli.md
- Command line
-
hf download hf://datasets/Lego-X/ProgramGen/tasks/data/reverse/aaveshdev__dragon.e4245fe/environment/docs/cli.md
-
curl -L -o cli.md https://huggingface.co/datasets/Lego-X/ProgramGen/resolve/main/tasks/data/reverse/aaveshdev__dragon.e4245fe/environment/docs/cli.md
4.15 kB
dragon CLI reference
The dragon executable is the entry point for running, compiling and editing
Dragon programs. Its behaviour is chosen by the first argument (a script path,
a subcommand, or a flag).
dragon <command | file.dgn> [options] [args...]
Commands
| Invocation | Effect |
|---|---|
dragon <file.dgn> [args...] |
Run a Dragon script. Extra arguments are passed to the script as argv. |
dragon --repl |
Start the interactive REPL. |
dragon run |
Run the project described by ./package.json. |
dragon -c <file.dgn> -o <out> |
Compile/bundle a script into an executable or library. |
dragon --ide |
Launch the TurboDragon terminal IDE. |
dragon -v, dragon --version |
Print version information and exit. |
Running a script
dragon hello.dgn
dragon hello.dgn Alice 42 --verbose
- Input: a UTF-8
.dgnsource file. - Output: whatever the program prints with
show/showlnon stdout (errors and diagnostics are reported on stderr, with the offending line highlighted). - Everything after the file name is delivered to the program as the
argvlist, so scripts can read their own command-line arguments.
Interactive REPL
dragon --repl
A persistent session: variables, functions and classes defined on one line stay
available on the next. Type exit to quit.
Running a project: dragon run
dragon run
Looks for a package.json in the current directory and runs the file named by
its "main" field (the "entry" field is accepted as an alias).
{
"name": "my-dragon-app",
"main": "src/main.dgn"
}
Input format: a JSON object with a name and a main/entry path relative to
the directory containing package.json.
Compiling a script: -c / -o
# Bundle a script (and everything it imports) into one distributable executable
dragon -c input.dgn -o output
# GUI/background mode: do not attach a console window on Windows
dragon -c input.dgn -o output --window
# Build a shared library instead of an executable
dragon -c input.dgn -o output.dll --lib # .so / .dylib on Linux / macOS
# (Experimental) transpile to C and build a native binary with gcc/clang/MSVC
dragon -c input.dgn -o output --native
# (Experimental) native shared library
dragon -c input.dgn -o output --native --lib
# Keep the intermediate generated C source when using --native
dragon -c input.dgn -o output --native --keep-c
| Option | Meaning |
|---|---|
-c <file.dgn> |
Compile mode; the value is the input script. |
-o <path> |
Output file name (omit the extension for an executable; add .dll / .so / .dylib with --lib). |
--lib |
Produce a shared library that can be embedded in another application. |
--native |
Experimental: build the program with your system C compiler instead of bundling it. Requires gcc, clang, or cl on PATH. |
--keep-c |
With --native, leave the generated C source on disk for inspection. |
--window |
Windows only: start without a console window (GUI/background application). |
Notes:
- Bundled executables are self-contained: the script plus everything it imports is packaged inside the single output file, which can be distributed to machines that do not have Dragon installed.
--nativeproduces an ordinary platform binary built by your C compiler, which starts faster than a bundled script because no translation happens when the program is launched.
TurboDragon IDE
dragon --ide
A lightweight, keyboard-driven terminal editor/runner: edit a script and run it without leaving the terminal.
Output formats summary
| Mode | Artifact produced |
|---|---|
| run | none (program output on stdout) |
--repl |
none (session state is in-memory) |
-c ... -o out |
out (native executable / bundled binary) |
-c ... -o out --lib |
out.dll / libout.so / out.dylib |
-c ... -o out --native |
platform executable built by the system C compiler |
-c ... -o out --native --keep-c |
executable + retained generated C source |