From ccf3d391dd969aeb4d181887c568d6b5ef4864bd Mon Sep 17 00:00:00 2001 From: jank Date: Fri, 20 Jun 2025 07:34:05 +0200 Subject: [PATCH] fix: Try different cli script --- index.ts | 50 ++++++++------------------------------------------ 1 file changed, 8 insertions(+), 42 deletions(-) diff --git a/index.ts b/index.ts index 76a8414..a8204a8 100644 --- a/index.ts +++ b/index.ts @@ -105,48 +105,14 @@ program }); program.command("init").action(() => { - console.log(`# Real-time output processing version -function pcli() { - local cli_command="$1" - shift - - # Use unbuffer to force line buffering, or stdbuf if available - if command -v unbuffer >/dev/null 2>&1; then - # 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 + console.log(`${CLI_NAME}() { + command ${CLI_NAME} "$@" | while IFS= read -r line; do + if [[ $line == __EXEC__* ]]; then + eval "\${line#__EXEC__}" + else + echo "$line" + fi + done }`); });