CLI Reference

The MathViz CLI provides commands for compiling, running, and managing your MathViz projects. This reference covers all available commands and their options.

Installation

Install MathViz using pipx (recommended), pip, or uv:

Shell
# Using pipx (recommended for CLI tools)
pipx install mathviz

# Using pip
pip install mathviz

# Using uv for development
git clone https://github.com/CyberSnakeH/MathViz.git
cd MathViz
uv sync --dev

Global Options

These options are available for all commands:

Option Description
--help, -h Show help message and exit
--version, -V Show version number and exit
--verbose, -v Enable verbose output
--quiet, -q Suppress non-error output
--color Control color output: auto, always, never

mathviz compile

Compile MathViz source files to Python.

Shell
mathviz compile <input> [options]

Arguments

Argument Description
input Path to MathViz source file (.mviz)

Options

Option Description Default
-o, --output Output file path <input>.py
--emit Output format: py, ast, tokens py
--optimize Optimization level: 0, 1, 2, 3 1
--no-runtime Don't include runtime library false
--stdout Print output to stdout instead of file false

Examples

Shell
# Compile to default output (hello.py)
mathviz compile hello.mviz

# Compile to specific output file
mathviz compile hello.mviz -o output/hello.py

# Compile with maximum optimization
mathviz compile hello.mviz --optimize 3

# Output AST for debugging
mathviz compile hello.mviz --emit ast --stdout

# Output tokens for debugging
mathviz compile hello.mviz --emit tokens --stdout

mathviz run

Compile and run a MathViz file with Manim. This command is specifically for files containing scene blocks.

Shell
mathviz run <input> [scene] [options]

Arguments

Argument Description
input Path to MathViz source file
scene Scene name to render (optional, renders all if omitted)

Options

Option Description Default
-q, --quality Video quality: l (480p), m (720p), h (1080p), p (1440p), k (4K) h
-p, --preview Preview video after rendering false
--format Output format: mp4, gif, webm, png mp4
-o, --output Output directory ./media
--fps Frame rate 60
--transparent Render with transparent background false
--save-last-frame Save last frame as image false
--dry-run Compile only, don't render false

Examples

Shell
# Run with preview
mathviz run animation.mviz --preview

# Run specific scene at 720p
mathviz run animation.mviz IntroScene -q m --preview

# Render to GIF
mathviz run animation.mviz --format gif -q l

# High quality render without preview
mathviz run animation.mviz -q k -o ./renders

# Render with transparent background
mathviz run animation.mviz --transparent --format webm

# Save last frame as image
mathviz run animation.mviz --save-last-frame

mathviz exec

Execute a MathViz file directly without generating intermediate files. Use this for scripts without Manim scenes.

Shell
mathviz exec <input> [args...]

Arguments

Argument Description
input Path to MathViz source file
args... Arguments to pass to the program

Examples

Shell
# Execute a script
mathviz exec script.mviz

# Pass arguments to the script
mathviz exec script.mviz --input data.json --verbose

# Execute with verbose output
mathviz exec -v script.mviz

mathviz check

Check MathViz source files for errors without compiling.

Shell
mathviz check <input> [options]

Options

Option Description Default
--strict Enable strict type checking false
--warnings Show warnings true
--json Output diagnostics as JSON false

Examples

Shell
# Check for errors
mathviz check main.mviz

# Strict mode with all warnings
mathviz check main.mviz --strict

# Output as JSON (for editor integration)
mathviz check main.mviz --json

# Check multiple files
mathviz check src/*.mviz

mathviz analyze

Perform static analysis on MathViz source files.

Shell
mathviz analyze <input> [options]

Options

Option Description Default
--complexity Report cyclomatic complexity false
--dependencies Show module dependencies false
--unused Find unused code false
--all Run all analyses false
--json Output as JSON false

Examples

Shell
# Full analysis
mathviz analyze main.mviz --all

# Check complexity only
mathviz analyze main.mviz --complexity

# Find unused code
mathviz analyze src/ --unused

# Export dependency graph
mathviz analyze src/ --dependencies --json > deps.json

mathviz fmt

Format MathViz source files according to the standard style guide.

Shell
mathviz fmt <input> [options]

Options

Option Description Default
--check Check if files are formatted (don't modify) false
--diff Show diff of changes false
--indent Indentation size (spaces) 4
--line-width Maximum line width 100

Examples

Shell
# Format a file in place
mathviz fmt main.mviz

# Format all files in directory
mathviz fmt src/

# Check formatting (CI/CD)
mathviz fmt --check src/

# Show what would change
mathviz fmt --diff main.mviz

# Custom formatting options
mathviz fmt main.mviz --indent 2 --line-width 80

mathviz lint

Run the linter to find code quality issues and potential bugs.

Shell
mathviz lint <input> [options]

Options

Option Description Default
--fix Automatically fix issues when possible false
--select Enable specific rules (comma-separated) all
--ignore Disable specific rules (comma-separated) none
--config Path to config file mathviz.toml

Lint Rules

Common lint rule categories:

Category Prefix Description
Error E Syntax and semantic errors
Warning W Potential issues and bad practices
Style S Code style violations
Complexity C Code complexity issues
Performance P Performance suggestions

Examples

Shell
# Lint a file
mathviz lint main.mviz

# Lint and auto-fix
mathviz lint main.mviz --fix

# Only check specific rules
mathviz lint main.mviz --select E,W

# Ignore style rules
mathviz lint main.mviz --ignore S

# Lint entire project
mathviz lint src/

mathviz watch

Watch files for changes and automatically recompile or re-render.

Shell
mathviz watch <input> [options]

Options

Option Description Default
--command Command to run: compile, run, check compile
--debounce Debounce time in milliseconds 300
--clear Clear terminal before each run true
--notify Show desktop notifications false

Examples

Shell
# Watch and compile on changes
mathviz watch src/

# Watch and run animation on changes
mathviz watch animation.mviz --command run

# Watch with notifications
mathviz watch src/ --notify

# Watch with custom debounce
mathviz watch src/ --debounce 500

mathviz new

Create a new MathViz project with a complete directory structure.

Shell
mathviz new <name> [options]

Options

Option Description
--template <type> Project template: basic (default), manim, math, lib
--no-git Don't initialize a git repository

Generated Structure

Shell
$ mathviz new my-project
Created MathViz project: my-project/
  - src/main.mviz (template: basic)
  - mathviz.toml
  - .gitignore

my-project/
├── src/
│   └── main.mviz       # Entry point
├── tests/
├── mathviz.toml         # Project configuration
└── .gitignore

Examples

Shell
# Create a basic project
mathviz new my-project

# Create an animation project
mathviz new my-animation --template manim

# Create a math project
mathviz new my-math --template math

# Create a library
mathviz new my-lib --template lib

# Create without git
mathviz new my-project --no-git

mathviz build

Build the current project. Reads configuration from mathviz.toml and compiles all .mviz files in src/.

Shell
mathviz build

Example

Shell
$ cd my-project
$ mathviz build
Build successful: 3 file(s) compiled

mathviz info

Display information about the MathViz installation and environment.

Shell
mathviz info [options]

Options

Option Description
--json Output as JSON
--check-deps Check if all dependencies are installed

Example Output

Shell
$ mathviz info
MathViz 1.0.0

Environment:
  Python: 3.11.5
  Manim: 0.18.0
  Platform: linux (x86_64)

Paths:
  Config: ~/.config/mathviz/config.toml
  Cache: ~/.cache/mathviz

Dependencies:
  numpy: 1.24.0
  scipy: 1.11.0
  numba: 0.58.0 (JIT enabled)

Auto-Update

MathViz automatically checks PyPI for new versions once per day. The check runs in the background and never blocks your commands. When an update is available, a message is displayed after the command output:

Shell
$ mathviz build
Build successful: 3 file(s) compiled

Update available: 0.1.7 → 0.2.0
Run: pipx upgrade mathviz

The version check result is cached in ~/.cache/mathviz/update_check.json for 24 hours. To force a fresh check, delete the cache file.

Configuration File

Configure default options in mathviz.toml in your project root:

TOML mathviz.toml
[project]
name = "my-animation"
version = "1.0.0"
entry = "src/main.mviz"

[compile]
optimize = 2
output_dir = "build"

[run]
quality = "h"
preview = true
output_dir = "media"

[fmt]
indent = 4
line_width = 100

[lint]
select = ["E", "W", "C"]
ignore = ["S001"]

Exit Codes

Code Meaning
0 Success
1 General error
2 Syntax error in source file
3 Type error
4 Runtime error
5 File not found
10 Lint errors found (with --check)
11 Format check failed (with --check)

Next Steps