printable-shell-command

Crates.ioprintable-shell-command
lib.rsprintable-shell-command
version0.2.4
created_at2025-10-03 04:48:04.948698+00
updated_at2025-10-09 02:39:27.769732+00
descriptionA helper library to print shell commands.
homepagehttps://github.com/lgarron/printable-shell-command-rs
repositoryhttps://github.com/lgarron/printable-shell-command-rs
max_upload_size
id1866130
size35,343
Lucas Garron (lgarron)

documentation

https://github.com/lgarron/printable-shell-command-rs

README

printable_shell_command

Rust port of: https://github.com/lgarron/printable-shell-command

A helper library to print shell commands.

The goal is to make it easy to print commands that are being run by a program, in a way that makes it easy and safe for a user to copy-and-paste.

Examples

Using Command directly

use std::process::Command;

use printable_shell_command::ShellPrintable;

fn main() {
    let _ = Command::new("echo").args(["#hi"]).print_invocation();
}

Prints:

echo \
  '#hi'

Using PrintableShellCommand to group args

use printable_shell_command::{PrintableShellCommand, ShellPrintable};

fn main() {
    let _ = PrintableShellCommand::new("ffmpeg")
        .args(["-i", "./test/My video.mp4"])
        .args(["-filter:v", "setpts=2.0*PTS"])
        .args(["-filter:a", "atempo=0.5"])
        .arg("./test/My video (slow-mo).mov")
        .print_invocation()
        .unwrap();
}

Prints:

ffmpeg \
  -i './test/My video.mp4' \
  -filter:v 'setpts=2.0*PTS' \
  -filter:a atempo=0.5 \
  './test/My video (slow-mo).mov'
Commit count: 0

cargo fmt