From 0680be2c311d563b0afefcbe0ecde2db3c551cb2 Mon Sep 17 00:00:00 2001 From: Maxwell Brown Date: Mon, 20 Nov 2023 14:53:05 -0500 Subject: [PATCH] run compgen in unspecified shell --- README.md | 3 --- src/internal/compgen.ts | 4 ++-- src/internal/completion.ts | 10 ++++++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 03a3908..0dd5bf0 100644 --- a/README.md +++ b/README.md @@ -184,9 +184,6 @@ const minigitAdd = Command.standard("add", { options: minigitAddOptions }).pipe( Command.map((parsed) => AddSubcommand({ verbose: parsed.options })) ) -const minigitClone = Command.standard("clone", { - options: minigitCloneOptions, - args: minigitCloneArgs const minigitClone = Command.standard("clone", { options: minigitCloneOptions, args: minigitCloneArgs diff --git a/src/internal/compgen.ts b/src/internal/compgen.ts index c55335b..43e43a9 100644 --- a/src/internal/compgen.ts +++ b/src/internal/compgen.ts @@ -28,12 +28,12 @@ export const make = (workingDirectory: Option.Option): Effect.Effect< const cmd = Option.match(workingDirectory, { onNone: () => Command.make(command).pipe( - Command.runInShell("/bin/bash") + Command.runInShell(true) ), onSome: (cwd) => Command.make(command).pipe( Command.workingDirectory(cwd), - Command.runInShell("/bin/bash") + Command.runInShell(true) ) }) return executor.lines(cmd) diff --git a/src/internal/completion.ts b/src/internal/completion.ts index d21503b..9fb1f5e 100644 --- a/src/internal/completion.ts +++ b/src/internal/completion.ts @@ -79,16 +79,17 @@ const createBashCompletionScript = ( pathToExecutable: string, programNames: ReadonlyArray.NonEmptyReadonlyArray ): string => { + const rootCommand = ReadonlyArray.headNonEmpty(programNames) const completions = pipe( programNames, ReadonlyArray.map((programName) => - `complete -F _${ReadonlyArray.headNonEmpty(programNames)} ${programName}` + `complete -F _${rootCommand}_effect_cli_completions ${programName}` ), ReadonlyArray.join("\n") ) return String.stripMargin( - `|#!/usr/bin/env bash - |_${ReadonlyArray.headNonEmpty(programNames)}() { + `|###-begin-${rootCommand}-completions-### + |_${rootCommand}_effect_cli_completions() { | local CMDLINE | local IFS=$'\\n' | CMDLINE=(--shell-type bash --shell-completion-index $COMP_CWORD) @@ -104,6 +105,7 @@ const createBashCompletionScript = ( | # Unset the environment variables. | unset $(compgen -v | grep "^COMP_WORD_") |} - |${completions}` + |${completions} + |###-end-${rootCommand}-completions-###` ) }