Expand description
Command-line interface for the mq markdown processing tool.
This crate provides the CLI implementation for mq, a jq-like tool for processing markdown files. It handles command-line argument parsing, input/output processing, and integration with the mq language engine.
§Features
- Process markdown, MDX, HTML, and plain text inputs
- Support for file and stdin input
- Multiple output formats
- Optional debugger integration (with
debuggerfeature) - Optional Tarn VM operand-stack tracing (with
debug-tracefeature) - Optional Tarn VM instruction-count profiling (with
vm-profilefeature) - Interactive REPL mode
§Usage
The CLI is typically used through the mq binary, but can be embedded in other applications.
External subcommands (mq-NAME) are dispatched by Cli::run_external_subcommand on the raw
arguments before parsing; skip that call if the embedding application does not need them.
use mq_run::Cli;
use clap::Parser;
fn main() -> std::process::ExitCode {
let args: Vec<std::ffi::OsString> = std::env::args_os().collect();
if let Some(code) = Cli::run_external_subcommand(&args) {
return code;
}
let cli = Cli::parse_from(args);
cli.run().expect("CLI execution failed");
std::process::ExitCode::SUCCESS
}§Command-line Examples
Process markdown from a file:
mq '.h' input.mdFilter headings from stdin:
echo "# Title\nContent" | mq '.h | select(level == 1)'Use the REPL:
mq replRe-exports§
pub use cli::Cli;
Modules§
- cli
- Command-line interface.