Skip to content

Commit 4d56ecf

Browse files
committed
Add version flag to CLI and improve installer
- Added version support to the CLI using the clap derive macro. - Updated the install script to verify the installation using the new version flag, with a fallback to help if the flag is unavailable.
1 parent 3dce0d6 commit 4d56ecf

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

scripts/install.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,12 @@ fi
156156
install -m 0755 "${TMP_DIR}/trigrep" "${INSTALL_DIR}/trigrep"
157157

158158
echo "==> Installed to ${INSTALL_DIR}/trigrep"
159-
"${INSTALL_DIR}/trigrep" --version
159+
if "${INSTALL_DIR}/trigrep" --version >/dev/null 2>&1; then
160+
"${INSTALL_DIR}/trigrep" --version
161+
else
162+
echo "==> Warning: installed binary does not support --version; use 'trigrep --help'" >&2
163+
"${INSTALL_DIR}/trigrep" --help >/dev/null
164+
fi
160165

161166
case ":$PATH:" in
162167
*":${INSTALL_DIR}:"*) ;;

trigrep-cli/src/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ use std::path::PathBuf;
88
use clap::{Parser, Subcommand};
99

1010
#[derive(Parser)]
11-
#[command(name = "trigrep", about = "Indexed regex search for large codebases")]
11+
#[command(
12+
name = "trigrep",
13+
about = "Indexed regex search for large codebases",
14+
version
15+
)]
1216
struct Cli {
1317
#[command(subcommand)]
1418
command: Commands,

0 commit comments

Comments
 (0)