はじめに

この資料は Rust 製のコマンドラインツール append-if について紹介するものです。

Rustの環境構築やツールのインストール方法については以下を参照してください

Rust開発環境を整える

append-if について

append-if は、ファイルの内容に関する簡単な条件論理に基づいて、ファイルにテキストを追加するためのCLIツールです。特に、誤って同じものを何度も追加することなく、.bashrc などにテキストを追加するのに便利です。

GitHub - sam0x17/append-if: A simple CLI utility for appending text to files based on simple conditional logic about the contents of those files. Particularly useful for appending text to .bashrc and other places without accidentally appending the same thing multiple times.

使用方法

append-if [OPTIONS] --path <PATH> --append <APPEND>

オプション

使用例

% append-if --mode missing --path ~/.bashrc  \\
    --pattern '$HOME/.rvm/bin' --append '
# Add RVM to PATH for scripting. Make sure this is the last PATH variable change.
export PATH="$PATH:$HOME/.rvm/bin"
'