Skip to content
This repository has been archived by the owner on Jul 16, 2024. It is now read-only.

Commit

Permalink
run compgen in unspecified shell
Browse files Browse the repository at this point in the history
  • Loading branch information
IMax153 committed Nov 20, 2023
1 parent 249bab1 commit 0680be2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/internal/compgen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ export const make = (workingDirectory: Option.Option<string>): 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)
Expand Down
10 changes: 6 additions & 4 deletions src/internal/completion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,17 @@ const createBashCompletionScript = (
pathToExecutable: string,
programNames: ReadonlyArray.NonEmptyReadonlyArray<string>
): 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)
Expand All @@ -104,6 +105,7 @@ const createBashCompletionScript = (
| # Unset the environment variables.
| unset $(compgen -v | grep "^COMP_WORD_")
|}
|${completions}`
|${completions}
|###-end-${rootCommand}-completions-###`
)
}

0 comments on commit 0680be2

Please sign in to comment.