fix: Fix cli command
All checks were successful
Release / Release (push) Successful in 26s

This commit is contained in:
Jan K9f 2025-06-19 19:21:00 +02:00
commit 7f5c72143a
Signed by: jank
GPG key ID: 22BEAC760B3333D6

View file

@ -105,14 +105,48 @@ program
}); });
program.command("init").action(() => { program.command("init").action(() => {
console.log(`${CLI_NAME}() { console.log(`# Real-time output processing version
command ${CLI_NAME} "$@" | while IFS= read -r line; do function pcli() {
if [[ $line == __EXEC__* ]]; then local cli_command="$1"
eval "\${line#__EXEC__}" shift
else
echo "$line" # Use unbuffer to force line buffering, or stdbuf if available
fi if command -v unbuffer >/dev/null 2>&1; then
done # unbuffer from expect package - best option
unbuffer "$cli_command" "$@" | while IFS= read -r line; do
if [[ "$line" =~ ^__EXEC__[[:space:]]*(.*) ]]; then
local cmd="\${match[1]}"
echo "Executing: $cmd"
eval "$cmd"
else
echo "$line"
fi
done
elif command -v stdbuf >/dev/null 2>&1; then
# stdbuf - force line buffering
stdbuf -oL "$cli_command" "$@" | while IFS= read -r line; do
if [[ "$line" =~ ^__EXEC__[[:space:]]*(.*) ]]; then
local cmd="\${match[1]}"
echo "Executing: $cmd"
eval "$cmd"
else
echo "$line"
fi
done
else
# Fallback using script to simulate a terminal
script -q /dev/null "$cli_command" "$@" | while IFS= read -r line; do
# Remove any terminal escape sequences that script might add
line=$(echo "$line" | sed 's/\\x1b\\[[0-9;]*m//g')
if [[ "$line" =~ ^__EXEC__[[:space:]]*(.*) ]]; then
local cmd="\${match[1]}"
echo "Executing: $cmd"
eval "$cmd"
else
echo "$line"
fi
done
fi
}`); }`);
}); });