module.exports = function(vorpal, config) { var websocket = config.websocket; var log = config.log; var guests = new GuestManager({websocket: websocket}); guests.load(); vorpal .command('guests save [filepath]', 'Load guests from JSON file') .autocomplete(fsAutocomplete()) .action(function(args, callback) { guests.save(args.filepath); callback(); }); vorpal .command('guests load [filepath]', 'Load guests from JSON file') .autocomplete(fsAutocomplete()) .action(function(args, callback) { guests.load(args.filepath); callback(); }); vorpal .command('guests show [id]', 'Show details of an event') .autocomplete({data: function() { return guests.autocomplete() } }) .action(function(args, callback) { this.log(guests.find(args.id)) callback(); }); vorpal .command('guests log [id]', 'Log an guest in time') .autocomplete({data: function() {return guests.autocomplete();}}) .option('-n, --name <name>', 'Name of event') .option('-t, --twitter <twitter>', 'Twitter handle') .option('-w, --website <website>', 'Website') .validate(function(args) { if (!args.id && Object.keys(args.options).length === 0) { return "You must specify an 'id' or provide details. Try --help"; } if(!args.id && !args.options.name) { return "Must specify a name if creating an event"; } }) .action(function(args, callback) { guests.log(Object.assign(args, args.options)); log.info({ 'command': 'log [id]', 'args': args }); callback(); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return grep; } vorpal.api = vorpal.api || {}; vorpal.api.grep = grep; chalk = vorpal.chalk; vorpal .command('grep <pattern> [files...]', 'Grep (POSIX) implementation.') .option('-i, --ignore-case', 'ignore case distinctions') .option('-w, --word-regexp', 'force pattern to match only whole words') .option('-s, --no-messages', 'suppress error messages') .option('-v, --invert-match', 'select non-matching lines') .option('-m, --max-count [num]', 'stop after num matches') .option('-b, --byte-offset', 'print the byte offset with output lines') .option('-n, --line-number', 'print the line number with output lines') .option('-H, --with-filename', 'print the file name for each match') .option('-h, --no-filename', 'suppress the file name prefix on output') .option('-q, --quiet', 'suppress all normal output') .option('-r, --recursive', 'recurse through subdirectories') .option('--silent', 'suppress all normal output') .option('--include [file_pattern]', 'search only files that match file_pattern') .autocomplete(fsAutocomplete()) .action(function (args, cb) { grep.exec.call(this, args, args.options, cb); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return ls; } vorpal.api.ls = ls; vorpal .command('ls [paths...]') .option('-a, --all', 'do not ignore entries starting with .') .option('-A, --almost-all', 'do not list implied . and ..') .option('-d, --directory', 'list directory entries instead of contents, and do not dereference symbolic links') .option('-F, --classify', 'append indicator (one of */=>@|) to entries') .option('-h, --human-readable', 'with -l, print sizes in human readable format (e.g., 1K 234M 2G)') .option('-i, --inode', 'print the index number of each file') .option('-l', 'use a long listing format') .option('-Q, --quote-name', 'enclose entry names in double quotes') .option('-r, --reverse', 'reverse order while sorting') .option('-R, --recursive', 'list subdirectories recursively') .option('-S', 'sort by file size') .option('-t', 'sort by modification time, newest first') .option('-U', 'do not sort; list entries in directory order') .option('-w, --width [COLS]', 'assume screen width instead of current value') .option('-x', 'list entries by lines instead of columns') .option('-1', 'list one file per line') .autocomplete(fsAutocomplete()) .action(function (args, cb) { return interfacer.call(this, { command: ls, args: args.paths, options: args.options, callback: cb }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return cp; } vorpal.api.cp = cp; vorpal.command('cp [args...]').parse(preparser).option('-f, --force', 'do not prompt before overwriting').option('-n, --no-clobber', 'do not overwrite an existing file').option('-r, --recursive', 'copy directories recursively').option('-R', 'copy directories recursively').autocomplete(fsAutocomplete()).action(function (args, callback) { args.options = args.options || {}; return interfacer.call(this, { command: cp, args: args.args, options: args.options, callback: callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return rm; } vorpal.api.rm = rm; vorpal.command('rm [files...]').option('-f, --force', 'ignore nonexistent files and arguments, never prompt').option('-r, --recursive', 'remove directories and their contents recursively').option('-R', 'remove directories and their contents recursively').autocomplete(fsAutocomplete()).action(function (args, callback) { args.options = args.options || {}; return interfacer.call(this, { command: rm, args: args.files, options: args.options, callback: callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return tail; } vorpal.api.tail = tail; vorpal.command('tail [files...]').option('-n, --lines <number>', 'Output the last N lines, instead of the last 10').option('-q, --silent', 'Suppresses printing of headers when multiple files are being examined.').option('-v, --verbose', 'Always output headers giving file names.').autocomplete(fsAutocomplete()).action(function (args, callback) { args.options = args.options || {}; return interfacer.call(this, { command: tail, args: args.files, options: args.options, callback: callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return cd; } vorpal.api.cd = cd; vorpal.command('cd [dir]').parse(preparser).autocomplete(fsAutocomplete({ directory: true })).action(function (args, callback) { args.options = args.options || {}; args.options.vorpal = vorpal; return interfacer.call(this, { command: cd, args: args.dir, options: args.options, callback: callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return cat; } vorpal.api.cat = cat; vorpal.command('cat [files...]').option('-A, --show-all', 'equivalent to -vET').option('-b, --number-nonblank', 'number nonempty output lines, overrides -n').option('-e', 'equivalent to -vE').option('-E, --show-ends', 'display $ at end of each line').option('-n, --number', 'number all output lines').option('-s, --squeeze-blank', 'suppress repeated empty output lines').option('-t', 'equivalent to -vT').option('-T, --show-tabs', 'display TAB characters as ^I').option('-v, --show-nonprinting', 'use ^ and M- notation, except for LFD and TAB') // this doesn't work yet... .autocomplete(fsAutocomplete()).action(function (args, cb) { args.options = args.options || {}; return interfacer.call(this, { command: cat, args: args, options: args.options, callback: cb }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return mv; } vorpal.api.mv = mv; vorpal.command('mv [args...]').parse(preparser).option('-f, --force', 'do not prompt before overwriting').option('-n, --no-clobber', 'do not overwrite an existing file').option('--striptrailingslashes', 'remove any trailing slashes from each source') // vorpal bug, need to add dashes between words .option('-v, --verbose', 'explain what is being done').autocomplete(fsAutocomplete()).action(function (args, callback) { args.options = args.options || {}; return interfacer.call(this, { command: mv, args: args.args, options: args.options, callback: callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return mkdir; } vorpal.api.mkdir = mkdir; vorpal .command('mkdir [directory...]') .parse(preparser) .option('-p, --parents', 'no error if existing, make parent directories as needed') .option('-v, --verbose', 'print a message for each created directory') .autocomplete(fsAutocomplete({directory: true})) .action(function (args, callback) { args.options = args.options || {}; args.options.vorpal = vorpal; return interfacer.call(this, { command: mkdir, args: args.directory, options: args.options, callback }); }); };
module.exports = function (vorpal) { if (vorpal === undefined) { return touch; } vorpal.api.touch = touch; vorpal .command('touch <files...>') .option('-a', 'change only the access time') .option('-c, --no-create', 'do not create any files') .option('-d, --date [STRING]', 'parse STRING and use it instead of current time') .option('-m', 'change only the modification time') .option('-r, --reference [FILE]', 'use this file\'s times instead of current time') .option('--time [WORD]', 'change the specified time: WORD is access, atime, or use: equivalent to -a WORD is modify or mtime: equivalent to -m') .autocomplete(fsAutocomplete()) .action(function (args, callback) { return interfacer.call(this, { command: touch, args: args.files || [], options: args.options, callback }); }); };
const fsAutocomplete = require('vorpal-autocomplete-fs'); Plop.delimiter('plop$').show(); const use = require(__dirname + '/lib/use'); const install = require(__dirname + '/lib/install'); const del = require(__dirname + '/lib/delete'); const list = require(__dirname + '/lib/list'); const init = require(__dirname + '/lib/init'); const save = require(__dirname + '/lib/save'); Plop.command('install <template_repo_url> [rename]', 'clones a plop template from github into your ~/.config/plop/ directory. Can also use `i`.') .action(install).alias('i'); Plop.command('use <template_name>', 'copies a plop template (by filename) you have saved into your working directory.') .action(use).autocomplete(fsAutocomplete()); Plop.command('delete <template_name...>', 'removes a locally saved plop template.') .action(del).autocomplete(fsAutocomplete()); Plop.command('list', 'displays a list of templates saved locally. Can also use `ls`.') .action(list).alias('ls'); Plop.command('init', 'walks you through building a plop template.') .action(init); Plop.command('save [name]', 'saves a locally created plop template to your ~/.config/plop/ directory. Can also use `s`.') .action(save).alias('s'); const exit = Plop.find('exit'); exit.alias('k').alias('q');