Skip to content

CLI Documentation

The GScript Command Line Interface (CLI) provides tools for compiling, validating, simulating, and optimizing GScript programs.

Installation

Install via cargo:

bash
cargo install gscript

Or download pre-built binaries from the releases page.

Basic Usage

bash
gscript [COMMAND] [OPTIONS]

Available Commands

compile

Compile GScript to G-code:

bash
gscript compile input.gs --backend grbl -o output.gcode

Options:

  • --backend <BACKEND>: Target backend (grbl, marlin, fanuc, linuxcnc, tinyg)
  • -o, --output <FILE>: Output file path
  • -O <LEVEL>: Optimization level (0-3)
  • --profile <PROFILE>: Machine profile to use

validate

Validate GScript syntax and semantics:

bash
gscript validate input.gs

Checks for:

  • Syntax errors
  • Type errors
  • Tool definition issues
  • Workspace boundary violations
  • Feed rate validation

simulate

Simulate toolpaths and visualize operations:

bash
gscript simulate input.gs

Shows:

  • Toolpath preview
  • Collision detection results
  • Material removal simulation
  • Cycle time estimate

estimate

Calculate machining costs:

bash
gscript estimate input.gs --profile my-machine

Provides:

  • Estimated cycle time
  • Material usage
  • Tool wear estimation
  • Total cost breakdown

optimize

Optimize G-code output:

bash
gscript optimize input.gcode -O3 -o optimized.gcode

Applies optimizations:

  • Redundancy elimination
  • Feed rate optimization
  • Travel path optimization
  • Arc fitting

Global Options

Available for all commands:

  • --verbose, -v: Enable verbose output
  • --quiet, -q: Suppress non-error output
  • --version: Show version information
  • --help, -h: Show help information

Examples

Compile with optimization:

bash
gscript compile program.gs --backend grbl -O2 -o output.gcode

Validate before compiling:

bash
gscript validate program.gs && gscript compile program.gs --backend marlin

Estimate costs before running:

bash
gscript estimate program.gs --profile haas-vf2

Next Steps

Released under the Apache License 2.0