scan markdown files and execute `console` blocks

Overview

exec-commands − scan markdown files and execute console blocks

exec-commands is a utility to update command-line-tool examples embedded in markdown files. It scans .md-suffixed files in a directory, extracts all code blocks with a console attribute, executes each $-prefixed line in a shell, and embeds the result right below the line.

Note: Please use exec-commands inside a sandbox. exec-command itself doesn't have any mechanism to protect the host environment from malicious commands embedded in markdown files.

Options

$ exec-commands --help
exec-commands 0.0.1
Hajime Suzuki ([email protected])
scan markdown files and execute `console` blocks

USAGE:
    exec-commands [OPTIONS] [INPUTS]...

ARGS:
    <INPUTS>...    Input markdown files (overrides config and glob)

OPTIONS:
    -c, --config <CONFIG>    Path to config file (it always loads .exec-commands.yaml if exists)
    -d, --diff               Take diff between original and updated contents
    -e, --extension <EXT>    Extension of files to scan (when no file specified by config or
                             argument) [default: md]
    -h, --help               Print help information
        --path <PATH>        Additional paths to find commands (colon-delimited)
        --pwd <PWD>          Directory where commands are executed
    -r, --reverse            Remove existing output lines
    -V, --version            Print version information

Configuration file format

It takes configuration in the yaml format. Below is an example and description of the fields.

# `inputs` is an array of input files.
inputs:
  - README.md
  - doc/**/*.md     # wildcard allowed; `**` matches directories with zero or more depths.

# `pwd` specifies the directory to run commands
pwd: "test"

# `path` is additional directories to search commands; extends the PATH environment variable.
path: "target/debug:$HOME/.cargo/bin"

# `alt` is a list of command substitutions. when it finds `raw`, it executes `alt` instead.
alt:
  - raw: "some-command --option-that-takes-long-time"
    alt: "another-command --with-the-fastest-option"
  - raw: "one-more-command --that-takes-user-input"
    alt: "alternative-command --that-runs-without-user-input"

# it executes a sequence of commands before and after every block and file.
hooks:
  pre_block:
    - "git clean -f -d"
    - "git checkout HEAD ."
  post_block:
    - ":"
  pre_file:
    - ":"
  post_file:
    - "git clean -f -d"
    - "git checkout HEAD ."

Copyright and License

2022, Hajime Suzuki. Licensed under MIT.

You might also like...
A tool for collecting rollup blocks from the Aztec Connect rollup, and exporting them to csv

Aztec Connect Data Gobbler The Aztec Connect Data gobbler is a tool made for extracting data from the Aztec Connect system using only L1 as its source

Programming language that compiles into Scratch blocks (SB3).

Claw Hello, and welcome to my cool project! I've spent... at least a month on this, and it's still not finished! Feel free to check it out though. :D

rehype plugin to use tree-sitter to highlight code in pre code blocks

rehype-tree-sitter rehype plugin to use tree-sitter to highlight code in precode blocks Contents What is this? When should I use this? Install Use

Building blocks for handling potentially unsafe statics.

Grounded Building blocks for handling potentially unsafe statics. This crate aims to provide useful and sound components that serve as building blocks

Execute Javascript code in the Dioxus, and get the return value ( for Dioxus )

Golde Dioxus Execute Javascript code in the Dioxus, and get the return value. This demo can help use Javascript to calc the + operator formula. use di

Workflows make it easy to browse, search, execute and share commands (or a series of commands)--without needing to leave your terminal.
Workflows make it easy to browse, search, execute and share commands (or a series of commands)--without needing to leave your terminal.

Workflows The repo for all public Workflows that appear within Warp and within commands.dev. To learn how to create local or repository workflows, see

Workflows make it easy to browse, search, execute and share commands (or a series of commands)--without needing to leave your terminal.
Workflows make it easy to browse, search, execute and share commands (or a series of commands)--without needing to leave your terminal.

Workflows The repo for all public Workflows that appear within Warp and within commands.dev. To learn how to create local or repository workflows, see

A rust library that allows you to host the CLR and execute dotnet binaries.
A rust library that allows you to host the CLR and execute dotnet binaries.

ClrOxide ClrOxide is a rust library that allows you to host the CLR and dynamically execute dotnet binaries. I wanted to call it Kepler for no particu

A very simple third-party cargo subcommand to execute a custom command

cargo-x A very simple third-party cargo subcommand to execute a custom command Usage install cargo-x cargo install cargo-x or upgrade cargo install -

Owner
Hajime Suzuki
Hajime Suzuki
Socket Monitor: A prettier and simpler alternative to netstat or ss for socket monitoring with the ability to scan for malicious IP addresses.

?? Somo A prettier alternative to netstat or ss for socket monitoring. ⬇️ Installation: 1. Install cargo: From crates.io. 2. Install the somo crate: c

Theodor Peifer 13 Jun 6, 2023
Scan your Rust crate for semver violations.

cargo-semver-checks Scan your Rust crate for semver violations. Queries rustdoc-generated crate documentation using the trustfall "query everything" e

Predrag Gruevski 293 Jan 6, 2023
Fast tool to scan for valid 7-long imgur ids for the ArchiveTeam imgur efforts (not affiliated or endorsed)

imgur_id7 Fast tool to scan for valid 7-long imgur ids for the ArchiveTeam imgur efforts (not affiliated or endorsed) Optionally uses supplied http pr

Robin Rolf 6 Jun 3, 2023
Scan the symbols of all ELF binaries in all Arch Linux packages for usage of malloc_usable_size

Scan the symbols of all ELF binaries in all Arch Linux packages for usage of malloc_usable_size (-D_FORTIFY_SOURCE=3 compatibility)

null 3 Sep 9, 2023
Efficient scan conversion of a line segment with clipping to a rectangular window.

✂️ clipline ?? clipline is a Rust crate for efficient scan conversion of a line segment with clipping to a rectangular window. It is an implementation

Nurzhan Sakén 5 Oct 26, 2023
mdBook is a utility to create modern online books from Markdown files.

Create book from markdown files. Like Gitbook but implemented in Rust

The Rust Programming Language 11.6k Jan 4, 2023
Introducing Inlyne, a GPU powered yet browsless tool to help you quickly view markdown files in the blink of an eye.

Inlyne - a GPU powered, browserless, markdown + html viewer inlyne README.md --theme dark/light About Markdown files are a wonderful tool to get forma

null 308 Jan 1, 2023
This is a tool to evaluate or export code from Markdown files.

Evaluate Markdown This is a tool to evaluate or export code from Markdown files. Why? Because I like writing Markdown files with code snippets (it's g

Balazs Nadasdi 5 Apr 25, 2023
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

Quentin Texier (g0h4n) 104 Oct 7, 2023
Rust crate for Ok-wrapping and try blocks

tryvial A small crate for Ok-wrapping and try blocks. This is compatible with Result, Option, and any type implementing the unstable std::ops::Try tra

null 11 Jan 25, 2023