CLI & Tooling / dlang CLI Reference

dlang CLI Reference

Reference for the dlang command-line tool: running scripts, type-checking, building native binaries, and using the REPL.

Core Commands

CommandDescription
dlang run <file.dl> [-- args]Compile and execute a Dlang source file, passing optional arguments to system.args().
dlang check <file.dl>Parse, resolve imports, and validate static type annotations without running the program.
dlang build <file.dl> -o <out>Compile a standalone native executable. Refuses to overwrite an existing output file.
dlang replStart an interactive Dlang session.
dlang --versionPrint the installed Dlang version.

Passing Program Arguments

Use -- to forward command-line flags directly to your .dl program:

terminal
dlang run app.dl -- --port 8080 --host 127.0.0.1

Read those arguments in Dlang with system.args():

args.dl
import system

for arg in system.args()
    show arg
end

Environment Variables