CLI Usage
The LocIO CLI (locio) lets you quickly count files and lines of code in directories with powerful filters and rich statistics.
This page provides an overview of the most common commands and flags.
Basic usage
- Installation, first run, and common workflows are covered in Get Started.
- This page focuses on the full list of flags and options and how they behave.
Detailed Options Reference
Below is a complete list of all LocIO CLI arguments and what they do.
Positional Arguments
paths...- Type: one or more paths (default:
.) - Description:
- If you provide no arguments, LocIO scans the current directory.
- If you provide one argument, LocIO scans either that directory or that single file.
- If you provide multiple arguments, LocIO scans each path (directories and/or files) and then produces a combined report.
- Examples:
locio(current directory)locio ./src(directory)locio /path/to/project(directory)locio ./src/index.ts(single file)locio /path/to/file.js(single file)locio packages/core packages/web(multiple directories)
- Type: one or more paths (default:
Mode Flags
-f,--files-only- Description: Count only files, ignoring line counts.
- Use when: You just need file counts per directory/extension.
- Example:
locio --files-only
-l,--lines-only- Description: Count only lines, ignoring file counts.
- Use when: You only care about total lines of code.
- Example:
locio --lines-only
--workspaces- Description: Auto-detect and scan workspace packages from a monorepo root (npm/Yarn
workspaces,pnpm-workspace.yaml, orlerna.json). - Behavior:
- Uses the first positional path as the monorepo root.
- Discovers each workspace directory that contains a
package.json. - Scans each workspace separately, then produces a combined report.
- Examples:
locio . --workspaces --statslocio /path/to/monorepo --workspaces --stats --export json,html
- Description: Auto-detect and scan workspace packages from a monorepo root (npm/Yarn
If both are omitted, LocIO reports both files and lines.
Include / Exclude by Pattern, Extension, Directory, Name
-e,--exclude <PATTERN>- Type: repeatable (regex)
- Description: Exclude files whose full path matches the given regular expression.
- Examples:
locio --exclude ".*\\.log$"locio --exclude ".*\\.test\\.(js|ts)$"
--exclude-ext <EXTENSIONS>- Type: comma-separated list
- Description: Exclude files with the given extensions. Dots are optional (
tsand.tsare both accepted). - Examples:
locio --exclude-ext log,tmplocio --exclude-ext .png,.jpg
--include-ext <EXTENSIONS>- Type: comma-separated list
- Description: Include only files with the given extensions.
- Examples:
locio --include-ext tslocio --include-ext ts,tsx,js
--exclude-dir <PATTERN>- Type: repeatable (regex)
- Description: Exclude directories whose path matches the regular expression (e.g.
node_modules,dist). - Examples:
locio --exclude-dir node_moduleslocio --exclude-dir dist --exclude-dir build
--include-dir <PATTERN>- Type: repeatable (regex)
- Description: Only scan directories whose path matches the regular expression. All other directories are skipped.
- Examples:
locio --include-dir srclocio --include-dir packages/core
--exclude-name <PATTERN>- Type: repeatable (regex)
- Description: Exclude files by file name regular expression (not full path). Useful for things like
README,LICENSE, etc. - Examples:
locio --exclude-name README.mdlocio --exclude-name "*.spec.ts"
--include-name <PATTERN>- Type: repeatable (regex)
- Description: Only include files whose name matches the regular expression.
- Examples:
locio --include-name "*.ts"locio --include-name "index.*"
Size and Depth Control
--max-size <SIZE>- Type: single value
- Description: Skip files larger than the given size.
- Examples:
locio --max-size 5MBlocio --max-size 100K
--min-size <SIZE>- Type: single value
- Description: Skip files smaller than the given size.
- Examples:
locio --min-size 1Klocio --min-size 10KB
--max-depth <DEPTH>- Type: integer
- Description: Limit how deep LocIO will traverse from the root directory.
1means only the root directory itself. - Examples:
locio --max-depth 1locio --max-depth 3
Hidden, Empty, Binary, and Symlinks
--no-hidden- Description: Exclude hidden files and directories (e.g.
.git,.env). - Example:
locio --no-hidden
- Description: Exclude hidden files and directories (e.g.
--no-empty- Description: Exclude empty files from counts.
- Example:
locio --no-empty
--follow-links- Description: Follow symbolic links when traversing directories.
- Example:
locio --follow-links
--no-binary- Description: Skip files detected as binary (e.g. images, compiled artifacts).
- Example:
locio --no-binary
--no-gitignore- Description: Do not apply nested
.gitignorerules. LocIO still excludes.gitmetadata. - Example:
locio --no-gitignore --explain
- Description: Do not apply nested
Output and statistics
--stats- Description: Show detailed statistics (extensions, directories, etc.) instead of just simple totals.
- Examples:
locio --statslocio --include-ext ts,tsx --stats
Language-level statistics (default when stats are shown)
- LocIO groups counts by language as well as by file extension.
- For each detected language you get:
- Files
- Total lines
- Code lines
- Comment lines
- Blank lines
- Total size
- All export formats now include a language breakdown:
- Human/terminal output – “Statistics by Language” section
- JSON –
by_languagearray - CSV/TSV – “Language Breakdown” section
- Markdown – “Statistics by Language” table
- HTML – language bar chart and table
--no-progress- Description: Disable progress indicator. Progress is enabled by default.
- Example:
locio --no-progress
--export <FORMAT>- Type:
human|json|csv|tsv|markdown|html(optional, defaults tohumanif omitted) - Description: Write the report to a file named
LocIO-report.{ext}in the given format instead of only printing to stdout. - Details:
--exportor--export human→LocIO-report.txt--export json→LocIO-report.json(includes blank_lines in summary and by_extension stats)--export csv→LocIO-report.csv(includes Blank Lines column)--export tsv→LocIO-report.tsv(includes Blank Lines column)--export markdownor--export md→LocIO-report.md(includes Blank Lines in summary and tables)--export html→LocIO-report.html(includes Blank Lines card/columns, language charts, directory graph, and an interactive treemap)- Multiple formats:
--export json,html,markdown→ creates all three files
- Note: All export formats include blank lines in the breakdown. The formula is: Total Lines = Code Lines + Comment Lines + Blank Lines
- Examples:
locio --stats --exportlocio --stats --export jsonlocio --stats --export json,html,markdown
- Type:
--export-path <DIR>- Type: directory path
- Description: Specify output directory for exported reports. Files will use default naming (LocIO-report.{ext}). Directories will be created automatically if they don't exist.
- Examples:
locio --stats --export json --export-path ./reportslocio --stats --export json,html --export-path ./output
--stdout <FORMAT>- Type: exactly one of
human|json|csv|tsv|markdown|html - Description: Print the selected report directly to stdout. Operational messages move to stderr, keeping structured output pipe-safe.
- Details: May be combined with
--exportto print one format and write report files in the same run. - Examples:
locio --stdout json | jq '.files'locio --stdout csv > report.csvlocio --stdout json --export html
- Type: exactly one of
--explain- Description: Include exclusion reason totals and up to 100 candidate-path examples.
- Reasons include:
.gitignore, extension/name/path filters, size/depth limits, hidden/empty/binary files, unsafe paths, and unreadable files. - Examples:
locio --explainlocio --stdout json --explain | jq '.exclusions'
Matching Behavior and Noise Control
-i,--ignore-case- Description: Make pattern matching for include/exclude options case-insensitive.
- Example:
locio --exclude ".*\\.LOG$" --ignore-case
-q,--quiet- Description: Reduce or suppress non-essential output (useful in scripts/CI).
- Example:
locio --quiet --stats --export json
Comment Analysis
--no-comments- Description: Disable comment counting. Comment analysis is enabled by default and provides breakdown of code lines, comment lines (full-line and inline), and blank lines.
- Example:
locio --no-comments
--comments(deprecated)- Description: This flag is now the default behavior. Use
--no-commentsto disable comment analysis. - Note: Comment analysis is automatically enabled by default, showing:
- Code Lines: Lines containing actual code
- Comment Lines: Lines containing comments (full-line and inline)
- Blank Lines: Empty lines (always included in totals)
Important: Blank lines are always included in the total line count and shown in all output formats. The formula is: Total Lines = Code Lines + Comment Lines + Blank Lines
- Description: This flag is now the default behavior. Use
--code-vs-comments- Description: Show code vs comments ratio. Automatically enables
--comments. - Example:
locio --code-vs-comments
- Description: Show code vs comments ratio. Automatically enables
--rm-comments [EXTENSIONS]- Type: optional comma-separated extensions
- Description: Remove comments from files (modifies files in place). Optionally specify file extensions to limit processing (e.g.,
js,ts,py). If no extensions specified, all supported files are processed. - Important:
- This modifies files permanently - use with caution!
- Certain file types are automatically ignored:
.md,.json,.yaml,.csv,.html,.log,.lock, etc. - When
--rm-commentsis used, normal reporting is skipped and only comment removal messages are shown.
- Examples:
locio --rm-comments(removes comments from all supported files)locio --rm-comments ts,js(removes comments only from TypeScript and JavaScript files)locio src --rm-comments py(removes comments from Python files in src directory)
--dry-run- Description: Preview which files
--rm-commentswould modify without writing anything. - Requirement: Must be used with
--rm-comments. - Examples:
locio --rm-comments --dry-runlocio --rm-comments ts,tsx --dry-run
- Description: Preview which files
Top Files and Directories
--top-files <N>- Type: integer
- Description: Show top N largest files by size in the statistics output.
- Example:
locio --stats --top-files 10
--top-dirs <N>- Type: integer
- Description: Show top N directories with most files in the statistics output.
- Example:
locio --stats --top-dirs 5
Watch Mode
-w,--watch- Description: Watch directory for changes and automatically rescan when files are modified, added, or deleted. Press
Ctrl+Cto stop. - Example:
locio --watch
- Description: Watch directory for changes and automatically rescan when files are modified, added, or deleted. Press
--watch-debounce <ms>- Type: integer (milliseconds)
- Description: Set the debounce delay for watch mode. This controls how long LocIO waits after detecting a file change before rescanning. Default is 500ms. Minimum is 100ms, maximum is 5000ms.
- Use when: You want to adjust the responsiveness of watch mode. Lower values make it more responsive but may cause more frequent scans. Higher values reduce scan frequency but increase delay.
- Examples:
locio --watch --watch-debounce 1000(1 second debounce)locio --watch --watch-debounce 200(200ms debounce for faster response)
Version
-v,--version- Description: Show version information and exit.
- Example:
locio --version
Project Configuration
--init- Description: Create a starter
.lociorc.jsonin the target directory. - Safety: Refuses to overwrite an existing config.
- Example:
locio . --init
- Description: Create a starter
--force- Description: Allow
--initto overwrite an existing.lociorc.json. - Requirement: Must be used with
--init. - Example:
locio . --init --force
- Description: Allow
Generated config:
{
"exclude_dirs": ["node_modules", "dist", "build", "coverage"],
"no_binary": true,
"comments": true,
"stats": true
}The config also accepts dry_run, stdout, explain, and no_gitignore.
Exit Codes
LocIO uses stable codes for scripts and CI:
0— completed successfully1— fatal error; no usable result2— partial result; one or more targets/files failed
Example:
locio package-a missing-package --stdout json
case $? in
0) echo "complete" ;;
1) echo "fatal" ;;
2) echo "partial result" ;;
esacLinks
- Get Started – Install LocIO and run your first counts
- GitHub Repository – Source code, issues, and contributions
"LocIO: Count your code, not your worries."
