diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..3c03207 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +18 diff --git a/README.md b/README.md index f7db665..b899464 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,18 @@ Create and manage biological identities (BEOs), institutional entities (IEOs), c npm install -g bspctl ``` +### Shell completions + +After installing, add completions to your shell: + +```bash +# bash — add to ~/.bashrc +eval "$(bsp completions bash)" + +# zsh — add to ~/.zshrc +eval "$(bsp completions zsh)" +``` + Or run without installing: ```bash diff --git a/src/index.ts b/src/index.ts index 669f14e..d7a7918 100644 --- a/src/index.ts +++ b/src/index.ts @@ -26,4 +26,16 @@ registerIEOCommands(program) registerExchangeCommands(program) registerConfigCommands(program) +program + .command('completions [shell]') + .description('Print shell completion script (bash|zsh). Usage: eval "$(bsp completions bash)"') + .action((shell = 'bash') => { + const cmds = ['beo', 'ieo', 'consent', 'record', 'config', 'completions'] + if (shell === 'zsh') { + console.log(`compdef '_arguments "1: :(${cmds.join(' ')})"' bsp`) + } else { + console.log(`complete -W "${cmds.join(' ')}" bsp`) + } + }) + program.parse()