Command-line interface for the html_view HTML viewer.
Install both the viewer app and the CLI tool:
# From the workspace root
cargo install --path html_view_app
cargo install --path html_view_cliBoth will be installed to ~/.cargo/bin/ (ensure this is in your PATH).
html_view_cli [SUBCOMMAND] [OPTIONS]html_view_cli html "<h1>Hello, World!</h1>"
html_view_cli html "<h1>Title</h1><p>Content</p>" --width 800 --height 600html_view_cli file index.html
html_view_cli file ./build/index.html --title "My App"html_view_cli dir ./dist
html_view_cli dir ./build --entry main.htmlThe --entry option specifies which HTML file to load (defaults to index.html).
html_view_cli url https://example.com
html_view_cli url https://docs.rs/html_view --width 1200All subcommands support these options:
--width <pixels>- Set window width (default: 1024)--height <pixels>- Set window height (default: 768)--title <string>- Set window title--devtools- Enable developer tools for debugging--timeout <seconds>- Auto-close window after N seconds
Quick HTML preview:
html_view_cli html "<h1>Quick Test</h1>"View documentation:
cargo doc --no-deps
html_view_cli file target/doc/my_crate/index.htmlPreview a static site:
# Build your static site
npm run build
# View it
html_view_cli dir ./distDebug a web page:
html_view_cli file debug.html --devtoolsTemporary notification:
html_view_cli html "<h1>Build Complete!</h1>" \
--timeout 5 \
--width 400 \
--height 200Custom window:
html_view_cli html "<h1>Custom</h1>" \
--width 800 \
--height 600 \
--title "My Custom Window"Pipe HTML from another command:
cat template.html | html_view_cli html "$(cat -)"View with styling:
html_view_cli html '
<!DOCTYPE html>
<html>
<head>
<style>
body { font-family: Arial; padding: 40px; }
h1 { color: #4A90E2; }
</style>
</head>
<body>
<h1>Styled Content</h1>
<p>This is a styled HTML page.</p>
</body>
</html>
'-
Environment Files: Save commonly used HTML snippets and load them:
html_view_cli html "$(cat my-template.html)" -
Integration with Build Tools: Add to your build scripts:
# In package.json or Makefile cargo build && html_view_cli html "<h1>Build Success!</h1>" --timeout 3
-
Data Visualization: Generate HTML reports and view them:
./my-analyzer --format html > report.html html_view_cli file report.html -
Testing: Quickly test HTML without opening a browser:
html_view_cli html "<button onclick='alert(\"test\")'>Click</button>" --devtools
The html_view_app binary must be installed and available. The CLI will look for it in:
~/.cargo/bin/html_view_app(preferred location)HTML_VIEW_APP_PATHenvironment variable- Same directory as
html_view_cli - Development target directories
If you get a "binary not found" error, ensure html_view_app is installed:
cargo install --path html_view_app- Linux: Requires WebKitGTK (
libwebkit2gtk-4.1-dev) - macOS: Uses system WKWebView (no additional dependencies)
- Windows: Uses WebView2 (included in Windows 11)
MIT OR Apache-2.0