CLI reference
The wheel installs a single lessish console script with three
subcommands — compile, lint, format — plus version.
No security warning on the CLI. The library defaults to the secure
file_io='jail', but the CLI stays less.js-compatible: an explicit, interactive invocation reads the filesystem withfile_io='allow'and suppresses theLessishSecurityWarningthat'allow'raises on every compile. That warning is reserved for programmatic use, where untrusted Less might reach the compiler — see guide/02-options.md. There is no--file-ioflag; lock down reads in Python instead.
compile
INPUT is a Less file, or - for stdin. Output goes to stdout unless -o
is given. Compile defaults come from [tool.lessish] in pyproject.toml
(or lessish.toml); flags override per key.
$ lessish compile styles.less
.button {
color: #4a90d9;
border: 1px solid #FFFFFF;
margin: 0px;
}
.button:hover {
color: #2a76c6;
}
From stdin:
To a file:
Flags
| Flag | Effect |
|---|---|
-o, --out PATH |
Write CSS to PATH (default: stdout). |
--config PATH |
Compile-config file (default: pyproject.toml). |
--compress |
Minified output. |
--source-map |
Emit a Source Maps v3 annotation. |
--source-map-out PATH |
Write the map JSON to PATH (implies --source-map). |
--source-map-url URL |
URL embedded in the sourceMappingURL annotation. |
--paths DIR |
Extra @import search dir (repeatable; extends config). |
--math {always,parens-division,parens} |
Arithmetic mode (default: parens-division). |
--strict-units |
Raise on compound-unit arithmetic. |
--global-var NAME=VALUE |
Inject @NAME: VALUE before user code (repeatable). |
--modify-var NAME=VALUE |
Inject @NAME: VALUE after user code, overriding it (repeatable). |
--no-process-imports |
Don't splice @imports (less-shape only). |
--rewrite-urls {all,local,off} |
Rewrite url(...) in imported files (default: off). |
--rootpath PREFIX |
Prefix prepended to every url(...). |
--url-args SUFFIX |
Query-string suffix appended to every url(...). |
--banner TEXT |
Verbatim prefix for the emitted CSS. |
The option semantics match the Python API one-for-one — see guide/02-options.md.
Minify
$ lessish compile styles.less --compress
.button{color:#4a90d9;border:1px solid #FFFFFF;margin:0px}.button:hover{color:#2a76c6}
Inject a variable
Source maps
--source-map-out writes both the CSS (with a trailing
sourceMappingURL annotation) and the separate map JSON:
$ lessish compile styles.less --source-map-out styles.css.map -o styles.css
$ tail -c 38 styles.css
/*# sourceMappingURL=styles.css.map */
See guide/03-source-maps.md for the map contents.
lint
Runs the linter, prints diagnostics, and exits 1 if any
warning/error remains. Full walkthrough: linter/01-overview.md.
$ lessish lint styles.less # exit: 1
styles.less:5:21: warning [hex-short] `#FFFFFF` can be shortened to `#fff`
styles.less:5:21: warning [hex-case] `#FFFFFF` should be lowercase
styles.less:6:11: warning [zero-unit] `0px` simplifies to `0`
styles.less:7:12: warning [block-opening-brace-newline-after] block content should start on a new line
styles.less:7:40: warning [closing-brace-newline-before] `}` should be on its own line
styles.less:3:1: info [decls-before-rulesets] declarations should come before nested rulesets
Flags
| Flag | Effect |
|---|---|
--fix |
Apply safe autofixes (Tier 0 + Tier 1) in place. |
--unsafe-fix |
Also apply risky autofixes (Tier 2). |
--full |
Run eval-augmented rules (slower; runs the evaluator). |
--format {text,json,github} |
Output format. text is the default. |
--config PATH |
Load config from PATH instead of the default lookup. |
--enable RULES |
Comma-separated rule IDs to force-enable (repeatable). |
--disable RULES |
Comma-separated rule IDs to force-disable (repeatable). |
--no-inline-config |
Ignore all /* lessish-disable */ directives. |
--cache DIR |
Override cache location (default: auto-discovered). |
--no-cache |
Disable result caching (cache is on by default). |
--project DIR |
Cross-file mode. |
--telemetry-out PATH |
Write per-rule hit counts (JSON). |
Rule catalog, tiers, cache, and --project details:
linter/03-rules.md. Configuration and inline
directives: linter/02-configuration.md.
Autofix
(The first pass rewrites the file in place; the second finds nothing and
exits 0.)
format
A pure formatter — runs only Tier 0 rules, rewrites in place, no diagnostic
output. Same engine as lessish lint --fix, but formatting-only and with
blank-line-before-block on for the canonical layout.
--check reports what would change and exits 1 if anything would,
without writing:
Exit codes
| Exit | Meaning |
|---|---|
0 |
Success. For lint: no findings, or only info-level findings. |
1 |
lint: a warning/error remained after --fix. format --check: a file would change. |
2 |
Bad invocation, or an optional component isn't available. |
3 |
I/O error (missing file, can't write output). |
Back to index.