# tabalot

> Tab complete all the things

Latest version **0.8.0** (published 2014-12-11) · 0 weekly downloads

## Install

```sh
npm install tabalot
pnpm add tabalot
yarn add tabalot
bun add tabalot
```

## Health

**Score 10/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; low quality score; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.8.0 |
| Published | 2014-12-11 |
| First published | 2013-10-27 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 25 |
| Maintainers | mafintosh |

## Links

- npm: https://www.npmjs.com/package/tabalot
- Repository: https://github.com/mafintosh/tabalot
- Issues: https://github.com/mafintosh/tabalot/issues
- npm.io page: https://npm.io/package/tabalot

## Dependencies (1)

- [minimist](https://npm.io/package/minimist.md) ^0.2.0

## Recent versions

- 0.8.0 (latest) — 2014-12-11
- 0.7.2 — 2014-08-06
- 0.7.1 — 2014-07-24
- 0.7.0 — 2014-07-23
- 0.6.1 — 2014-07-20
- 0.6.0 — 2014-07-03
- 0.5.0 — 2014-07-03
- 0.4.0 — 2014-05-21
- 0.3.1 — 2014-04-30
- 0.3.0 — 2014-04-30
- 0.2.8 — 2013-11-16
- 0.2.7 — 2013-11-13
- 0.2.6 — 2013-11-12
- 0.2.5 — 2013-11-11
- 0.2.4 — 2013-11-10
- … 13 more at https://npm.io/package/tabalot/versions

## README

# tabalot

Tab complete all the things!

	npm install tabalot

tabalot is a node module that lets you build command line apps with
rich built in tab completion support

## Getting started

Lets make a sample app and link it with npm.
Write the example below to a file called `app.js`

``` js
#!/usr/bin/env node
var tab = require('tabalot');

tab('hello')
	(function() {
		console.log('world');
	})

tab.parse();
```

You need to add a `package.json` file as well.
The one below will make `app.js` executable as `tabtest`

``` js
{
	"name": "tabtest",
	"bin": {
		"tabtest": "./app.js" // we need a bin name
	}
}
```

To try the app locally just use npm to link it

	npm link # will add the app to your path

And install the tab completion

	tabtest completion --save # installs the completion to your bash_completion.d folder

If you use zsh you can install it with
	tabtest completion > ~./zshrc

The app is now installed and ready to be tab completed.
Open a shell and try the following

	tabtest <tab>
	tabtest hello <enter>
	world

It is as simple as that.

## Completing arguments

To complete arguments we just need to pass them to tabalot

``` js
tab('hello')
	('--world', '-w', ['world', 'welt', 'verden'])
	('--debug')
	(function(opts) {
		console.log(opts);
	})
```

In the above program we just added a boolean argument `--debug`
and a `--world` argument that should complete to one of the 3 values.

Try running

	tabtest <tab>
	tabtest hello --<tab><tab>       # prints --world --debug
	tabtest hello --world <tab><tab> # prints world verden welt
	tabtest hello --world v<tab>
	tabtest hello --world verden <enter>

The above program will output

	{
		world: 'verden',
		debug: false
	}

## Positional arguments

If you want to complete a positional (or nameless) argument
simply omit the name and it will be added as an argument to call function

``` js
tab('hello')
	(['world', 'verden', 'welt'])
	(function(world, opts) {
		console.log(world)
	})
```

Try running

	tabtest <tab>
	tabtest hello <tab><tab> # prints world verden welt
	tabtest hello v<tab>
	tabtest hello verden <enter>

The above program will output

	verden

## Dynamic completion

Instead of passing the static values `['world', 'welt', 'verden']` we can
pass an async function to the completer as well

``` js
tab('hello')
	('--world', '-w', function(callback) {
		callback(null, ['world', 'welt' 'verden']);
	})
	(function(opts) {
		console.log(opts);
	})
```

## Catch-all route

If you omit the command name from tab that route will be called and tab completed
if no one else matches

``` js
tab()
	('--world', '-w', ['world', 'welt'])
	(function() {
		console.log('I was called by doing tabtest --world world');
	})
```

## Completion helpers

Tabalot ships with support for a couple of typical completions.
Use these by passing @name as the completer.

``` js
tab('hello')
	('--file', '@file') // completes a file or directory
	('--dir', '@dir')   // completes a directory
	('--host', '@host') // completes a hostname (by looking at known_hosts)
```

# License

MIT

---
_Source: https://npm.io/package/tabalot · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
