-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
177 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
node_modules | ||
*.swp | ||
src |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,9 @@ babel: | |
|
||
lint: | ||
eslint . | ||
jscs . | ||
|
||
env: | ||
@echo $(PATH) | ||
|
||
build: babel test lint | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/usr/bin/env node | ||
|
||
process.env.DEBUG = process.env.DEBUG || 'tabtab*'; | ||
require('../src/cli'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
var tabtab = module.exports = require('./src'); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
|
||
const debug = require('debug')('tabtab'); | ||
const minimist = require('minimist'); | ||
const npmlog = require('npmlog'); | ||
const commands = require('./commands'); | ||
|
||
let opts = minimist(process.argv.slice(2), { | ||
alias: { | ||
h: 'help', | ||
v: 'version' | ||
} | ||
}); | ||
|
||
const cmd = opts._[0]; | ||
|
||
|
||
debug('Init tabtab with %s cmd', cmd); | ||
|
||
if (opts.help) { | ||
console.log(commands.help()); | ||
process.exit(0); | ||
} else if (opts.version) { | ||
console.log(commands.help()); | ||
process.exit(0); | ||
} else if (commands[cmd]) { | ||
debug('Run command %s with options', cmd, opts); | ||
commands[cmd](opts); | ||
} else { | ||
console.log(commands.help()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
const debug = require('debug')('tabtab:commands'); | ||
const { join } = require('path'); | ||
|
||
const { | ||
readFileSync: read, | ||
existsSync: exists | ||
} = require('fs'); | ||
|
||
class Commands { | ||
|
||
get completion() { | ||
return read(join(__dirname, '../../scripts/completion.sh'), 'utf8') | ||
} | ||
|
||
// Fow now, just output to the console | ||
install() { | ||
var script = this.completion; | ||
console.log(this.completion); | ||
} | ||
|
||
uninstall() {} | ||
search() {} | ||
list() {} | ||
add() {} | ||
rm() {} | ||
|
||
help() { | ||
return ` | ||
$ tabtab <command> [options] | ||
Options: | ||
-h, --help Show this help output | ||
-v, --version Show package version | ||
-s, --silent Silent mode for commands like install | ||
-y, --yes Skips confirmation prompts | ||
Commands: | ||
install Install and enable completion file on user system | ||
uninstall Undo the install command | ||
list List the completion files managed by tabtab | ||
search Search npm registry for tabtab completion files / dictionaries | ||
add Install additional completion files / dictionaries | ||
rm/remove Uninstall completion file / dictionnary | ||
`; | ||
} | ||
} | ||
|
||
|
||
module.exports = new Commands(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
|
||
|
||
// ok so how about staring it |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# Copyright (c) npm, Inc. and Contributors | ||
# All rights reserved. | ||
|
||
###-begin-{pkgname}-completion-### | ||
### credits to npm, this file is coming directly from isaacs/npm repo | ||
# | ||
# Just testing for now. (trying to learn this cool stuff) | ||
# | ||
# npm command completion script | ||
# | ||
# Installation: {completer} completion >> ~/.bashrc (or ~/.zshrc) | ||
# | ||
|
||
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/} | ||
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/} | ||
export COMP_WORDBREAKS | ||
|
||
if type complete &>/dev/null; then | ||
_{pkgname}_completion () { | ||
local si="$IFS" | ||
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \ | ||
COMP_LINE="$COMP_LINE" \ | ||
COMP_POINT="$COMP_POINT" \ | ||
{completer} completion -- "${COMP_WORDS[@]}" \ | ||
2>/dev/null)) || return $? | ||
IFS="$si" | ||
} | ||
complete -F _{pkgname}_completion {pkgname} | ||
elif type compctl &>/dev/null; then | ||
_{pkgname}_completion () { | ||
local cword line point words si | ||
read -Ac words | ||
read -cn cword | ||
let cword-=1 | ||
read -l line | ||
read -ln point | ||
si="$IFS" | ||
IFS=$'\n' reply=($(COMP_CWORD="$cword" \ | ||
COMP_LINE="$line" \ | ||
COMP_POINT="$point" \ | ||
{completer} completion -- "${words[@]}" \ | ||
2>/dev/null)) || return $? | ||
IFS="$si" | ||
} | ||
# if the completer function returns on matches, default | ||
# to filesystem matching | ||
compctl -K _{pkgname}_completion + -f + {pkgname} | ||
fi | ||
###-end-{pkgname}-completion-### | ||
|