Skip to content

CLI Usage

Chris W edited this page Dec 9, 2024 · 1 revision

CLI Usage

Goshot provides a powerful command-line interface for creating beautiful code screenshots. This guide covers how to use the CLI effectively.

Basic Usage

# Create a screenshot of a code file
goshot main.go

# Create a screenshot and save it to a file
goshot main.go -o screenshot.png

# Create a screenshot and copy it to clipboard
goshot main.go -c

# Read from clipboard and create a screenshot
goshot --from-clipboard

Common Examples

Code Screenshots

  1. Basic code screenshot with default settings:

    goshot main.go
  2. Custom theme and window style:

    goshot main.go -t dracula -C windows
  3. Custom background color and corner radius:

    goshot main.go -b "#282a36" --corner-radius 8
  4. Highlight specific lines:

    goshot main.go --highlight-lines "5-8" --highlight-lines "10" --highlight-lines "15-20"
  5. Show only specific line ranges:

    goshot main.go --line-range "10-50"

Terminal Screenshots

  1. Basic terminal output screenshot:

    ls -la | goshot exec
  2. Custom terminal dimensions:

    ls -la | goshot exec -w 80 -H 24
  3. Auto-sized terminal with custom padding:

    ls -la | goshot exec -A --pad-left 2 --pad-right 2 --pad-top 1 --pad-bottom 1
  4. Show command prompt:

    ls -la | goshot exec -p --auto-title

Gradient Backgrounds

  1. Linear gradient:

    goshot main.go \
      --gradient-type linear \
      --gradient-stops "#232323;0,#383838;100" \
      --gradient-angle 45
  2. Radial gradient:

    goshot main.go \
      --gradient-type radial \
      --gradient-stops "#232323;0,#383838;100" \
      --gradient-center-x 0.5 \
      --gradient-center-y 0.5
  3. Custom gradient with intensity:

    goshot main.go \
      --gradient-type spiral \
      --gradient-stops "#232323;0,#383838;50,#444444;100" \
      --gradient-intensity 8

Window Styling

  1. macOS style with custom theme:

    goshot main.go -C mac -T dark --window-title "My Code"
  2. Windows style with custom corner radius:

    goshot main.go -C windows --window-corner-radius 8
  3. No window controls with light mode:

    goshot main.go -L --no-window-controls

Layout and Padding

  1. Custom padding:

    goshot main.go --pad-horiz 40 --pad-vert 30 --line-pad 2
  2. Code block padding:

    goshot main.go \
      --code-pad-left 20 \
      --code-pad-right 20 \
      --code-pad-top 10 \
      --code-pad-bottom 10
  3. Width constraints:

    goshot main.go --min-width 800 --max-width 1200

Shadow Effects

  1. Simple shadow:

    goshot main.go --shadow-blur 10 --shadow-offset-y 4
  2. Custom shadow:

    goshot main.go \
      --shadow-blur 15 \
      --shadow-color "#00000066" \
      --shadow-spread 5 \
      --shadow-offset-x 0 \
      --shadow-offset-y 8

Redaction

  1. Basic pattern redaction:

    goshot config.yaml \
      --redact \
      --redact-pattern "password=.*" \
      --redact-pattern "api_key=.*"
  2. Blur redaction:

    goshot config.yaml \
      --redact \
      --redact-style blur \
      --redact-blur 5
  3. Manual area redaction:

    goshot screenshot.png \
      --redact \
      --redact-area "10,20,100,50" \
      --redact-area "200,300,150,30"

Additional Commands

# List available fonts
goshot fonts

# List syntax highlighting themes
goshot themes

# List supported languages
goshot languages

# Show version information
goshot version

Common Flags Reference

Input/Output

  • -o, --output: Output file path (default "code.png")
  • -c, --to-clipboard: Copy to clipboard
  • --from-clipboard: Read from clipboard
  • -s, --to-stdout: Write to stdout
  • --auto-title: Auto-set window title from filename/command

Appearance

  • -C, --chrome: Window chrome style (mac, windows, gnome) (default "mac")
  • -T, --chrome-theme: Chrome theme name
  • -L, --light-mode: Use light mode
  • -t, --theme: Syntax highlight theme (default "ayu-dark")
  • -f, --font: Font name (default "JetBrainsMonoNerdFont")
  • --line-height: Line height multiplier (default 1.0)
  • -b, --background: Background color (default "#ABB8C3")
  • --corner-radius: Image corner radius (default 10)
  • --window-corner-radius: Window corner radius (default 10)
  • --line-range: Line ranges to show (can specify multiple)
  • --highlight-lines: Lines to highlight (can specify multiple)

Layout

  • --line-pad: Line padding (default 2)
  • --pad-horiz: Horizontal padding (default 20)
  • --pad-vert: Vertical padding (default 20)
  • --code-pad-top: Code top padding (default 10)
  • --code-pad-bottom: Code bottom padding (default 10)
  • --code-pad-left: Code left padding (default 10)
  • --code-pad-right: Code right padding (default 10)
  • --line-number-pad: Line number padding (default 10)
  • --min-width: Minimum width (default 0)
  • --max-width: Maximum width (default 0)
  • --tab-width: Tab width (default 4)

Terminal

  • -w, --width: Terminal width in cells (default 120)
  • -H, --height: Terminal height in cells (default 40)
  • -A, --auto-size: Auto-size terminal to content
  • --pad-left: Left padding in cells (default 1)
  • --pad-right: Right padding in cells (default 1)
  • --pad-top: Top padding in cells (default 1)
  • --pad-bottom: Bottom padding in cells (default 1)
  • --cell-spacing: Cell spacing (default 0)
  • -p, --show-prompt: Show command prompt
  • -P, --prompt-template: Custom prompt template

Gradient

  • --gradient-type: Type (linear, radial, angular, diamond, spiral, square, star)
  • --gradient-stops: Color stops (default "#232323;0,#383838;100")
  • --gradient-angle: Angle in degrees (default 45)
  • --gradient-center-x: Center X position (default 0.5)
  • --gradient-center-y: Center Y position (default 0.5)
  • --gradient-intensity: Intensity (default 5)

Shadow

  • --shadow-blur: Shadow blur radius (default 0)
  • --shadow-color: Shadow color (default "#00000033")
  • --shadow-spread: Shadow spread (default 0)
  • --shadow-offset-x: Shadow X offset (default 0)
  • --shadow-offset-y: Shadow Y offset (default 0)

Redaction

  • --redact: Enable redaction
  • --redact-style: Style (block or blur) (default "block")
  • --redact-blur: Blur radius (default 5)
  • --redact-pattern: Regex patterns to redact (can specify multiple)
  • --redact-area: Areas to redact as "x,y,width,height" (can specify multiple)