Registry / http-networking / tabtab

tabtab

JSON →
library3.0.2jsnpmunverified

tabtab is a Node.js library designed to assist in building command-line interface (CLI) programs with robust tab completion capabilities for various shells, including Bash, Zsh, and Fish. Currently in version 3.0.2, this package underwent a significant rewrite in its 3.x series, aiming for simplification, reduced abstraction, and improved clarity. It differentiates itself by leveraging a similar shell script bridge technique to npm's acclaimed completion system, ensuring a familiar and effective user experience. While it doesn't have a rigid release cadence, major updates like the 3.0.0 overhaul introduce substantial changes, focusing on modern Node.js environments (Node.js > 7.10.1). The library specifically addresses the need for robust, fast, and debuggable completion logic for Node.js projects, moving away from previous versions' complexities and certain features like caching.

npm install tabtab
INSTALL
IMPORT
SIG · TABTAB
T
tabtab
http-networkingjavascriptv3.0.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

tabtab
const tabtab = require('tabtab');
import tabtab from 'tabtab';
tabtab primarily uses CommonJS `require` as demonstrated in official examples and is optimized for Node.js CLI scripts.
tabtab.log
tabtab.log(['suggestion1', 'suggestion2']);
import { log } from 'tabtab';
Access `log` as a property of the `tabtab` module directly after requiring it, rather than attempting a named import.
tabtab.install
await tabtab.install({ name: 'my-cli', completer: 'my-cli' });
tabtab.install('my-cli');
The `install` method expects an object with `name` and `completer` properties and returns a Promise.

This quickstart demonstrates how to set up, log, and parse tab completions for a Node.js CLI using `tabtab` and `minimist`, including installation and uninstallation commands for a hypothetical `tabtab-test` program.

#! /usr/bin/env node const tabtab = require('tabtab'); const minimist = require('minimist'); const opts = minimist(process.argv.slice(2), { string: ['foo', 'bar'], boolean: ['help', 'version', 'loglevel'] }); const args = opts._; const completion = env => { if (!env.complete) return; // Write your completions there if (env.prev === 'foo') { return tabtab.log(['is', 'this', 'the', 'real', 'life']); } if (env.prev === 'bar') { return tabtab.log(['is', 'this', 'just', 'fantasy']); } if (env.prev === '--loglevel') { return tabtab.log(['error', 'warn', 'info', 'notice', 'verbose']); } return tabtab.log([ '--help', '--version', '--loglevel', 'foo', 'bar', 'install-completion', 'completion', 'someCommand:someCommand description', { name: 'anotherOne', description: 'Another command with description' } ]); }; const run = async () => { const cmd = args[0]; if (cmd === 'install-completion') { await tabtab.install({ name: 'tabtab-test', completer: 'tabtab-test' }) .catch(err => console.error('INSTALL ERROR', err)); console.log('Completion installed for tabtab-test'); return; } if (cmd === 'uninstall-completion') { await tabtab.uninstall({ name: 'tabtab-test' }) .catch(err => console.error('UNINSTALL ERROR', err)); console.log('Completion uninstalled for tabtab-test'); return; } // If `completion` is specified, it means the shell is asking for completions if (opts.completion) { return completion(await tabtab.parse(process.env)); } // Your regular CLI logic here console.log('Running tabtab-test command with options:', opts, 'and args:', args); }; run().catch(console.error);
Debug
Known issues
breakingtabtab v3.x explicitly does not support Windows environments. Attempting to use it on Windows will result in errors.
fix
Use tabtab v2.x for older Node.js versions or seek alternative completion libraries for Windows-specific CLI tools.
affects: >=3.0.0
breakingThe internal caching mechanism present in earlier versions of tabtab has been removed in the 3.x series.
fix
Applications relying on tabtab's internal caching will need to implement their own caching logic if required.
affects: >=3.0.0
breakingtabtab v3.x requires Node.js version 7.10.1 or higher. Older Node.js versions (e.g., Node.js 6) are not supported.
fix
Upgrade your Node.js environment to 7.10.1 or newer, or downgrade tabtab to version 2.2.x for compatibility with Node.js 6.
affects: >=3.0.0
breakingThe 3.x version of tabtab no longer ships with a binary file, operating solely as a library. This changes how it might be invoked or integrated if previous versions relied on a direct binary.
fix
Ensure your CLI application integrates `tabtab` purely as a library, calling its functions directly within your Node.js script.
affects: >=3.0.0
gotchaWhile tabtab supports Bash, Zsh, and Fish, the 3.0.0 alpha version (and subsequent minor versions in the 3.x series) primarily focused on Bash. This might imply potential subtle differences or less robust support for Zsh and Fish shells compared to Bash.
fix
Thoroughly test completion behavior in Zsh and Fish shells and report any inconsistencies to the project maintainers. Be prepared for potential workarounds if issues arise.
affects: >=3.0.0
Errors
Common errors & fixes
Error: Node.js version X.Y.Z is not supported by tabtab 3.x. Please use tabtab 2.x or upgrade Node.js.
Attempting to use tabtab v3.x with a Node.js version older than 7.10.1.
fix
Upgrade Node.js to version 7.10.1 or newer, or install `tabtab@2.2.x` using `npm install tabtab@2.2.x`.
TypeError: Cannot read properties of undefined (reading 'complete') or 'Cannot set properties of undefined (setting 'completer')
Incorrectly calling `tabtab.parse()` or not providing `process.env` when setting up completion logic, or an incomplete `env` object.
fix
Ensure `tabtab.parse(process.env)` is correctly called and its result is passed to your completion handler. Verify the `env` object structure if manually creating it.
Completion not working after 'install-completion'.
The shell script generated by `tabtab.install()` might not be correctly sourced into your shell's configuration (`.bashrc`, `.zshrc`, `.config/fish/completions/`).
fix
After running `install-completion`, restart your terminal or manually source your shell configuration file (e.g., `source ~/.bashrc`). Double-check the install output for instructions.
Error: Platform not supported: Windows is not supported by tabtab 3.x.
Running `tabtab` v3.x on a Windows operating system.
fix
tabtab v3.x is not compatible with Windows. Use `tabtab@2.2.x` if you need some level of Windows support with older Node.js, or choose a different completion library for Windows.
Upgrade
Version history
3.0.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources