first commit
This commit is contained in:
6
build/node_modules/coa/.npmignore
generated
vendored
Normal file
6
build/node_modules/coa/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
.idea
|
||||
*.iml
|
||||
node_modules/
|
||||
!node_modules/coa*.js
|
||||
lib-cov/
|
||||
html-report/
|
||||
1
build/node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json
generated
vendored
Normal file
1
build/node_modules/coa/.nyc_output/1f2a0db5a6d6559149db56d397f47cfc.json
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{}
|
||||
1
build/node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json
generated
vendored
Normal file
1
build/node_modules/coa/.nyc_output/75b82d38f2186df930141082076e11c6.json
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
9
build/node_modules/coa/.travis.yml
generated
vendored
Normal file
9
build/node_modules/coa/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
language: node_js
|
||||
|
||||
node_js:
|
||||
- "0.10"
|
||||
- "0.11"
|
||||
|
||||
matrix:
|
||||
allow_failures:
|
||||
- node_js: 0.11
|
||||
34
build/node_modules/coa/GNUmakefile
generated
vendored
Normal file
34
build/node_modules/coa/GNUmakefile
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
BIN = ./node_modules/.bin
|
||||
|
||||
.PHONY: all
|
||||
all: lib
|
||||
|
||||
lib: $(foreach s,$(wildcard src/*.coffee),$(patsubst src/%.coffee,lib/%.js,$s))
|
||||
|
||||
lib-cov: clean-coverage lib
|
||||
$(BIN)/istanbul instrument --output lib-cov --no-compact --variable global.__coverage__ lib
|
||||
|
||||
lib/%.js: src/%.coffee
|
||||
$(BIN)/coffee -cb -o $(@D) $<
|
||||
|
||||
.PHONY: test
|
||||
test: lib
|
||||
$(BIN)/mocha
|
||||
|
||||
.PHONY: coverage
|
||||
coverage: lib-cov
|
||||
COVER=1 $(BIN)/mocha --reporter mocha-istanbul
|
||||
@echo
|
||||
@echo Open html-report/index.html file in your browser
|
||||
|
||||
.PHONY: watch
|
||||
watch:
|
||||
$(BIN)/coffee --watch --bare --output lib src/*.coffee
|
||||
|
||||
.PHONY: clean
|
||||
clean: clean-coverage
|
||||
|
||||
.PHONY: clean-coverage
|
||||
clean-coverage:
|
||||
-rm -rf lib-cov
|
||||
-rm -rf html-report
|
||||
322
build/node_modules/coa/README.md
generated
vendored
Normal file
322
build/node_modules/coa/README.md
generated
vendored
Normal file
@@ -0,0 +1,322 @@
|
||||
# Command-Option-Argument
|
||||
[](http://travis-ci.org/veged/coa)
|
||||
|
||||
## What is it?
|
||||
|
||||
COA is a parser for command line options that aim to get maximum profit from formalization your program API.
|
||||
Once you write definition in terms of commands, options and arguments you automaticaly get:
|
||||
|
||||
* Command line help text
|
||||
* Program API for use COA-based programs as modules
|
||||
* Shell completion
|
||||
|
||||
### Other features
|
||||
|
||||
* Rich types for options and arguments, such as arrays, boolean flags and required
|
||||
* Commands can be async throught using promising (powered by [Q](https://github.com/kriskowal/q))
|
||||
* Easy submoduling some existing commands to new top-level one
|
||||
* Combined validation and complex parsing of values
|
||||
|
||||
### TODO
|
||||
|
||||
* Localization
|
||||
* Shell-mode
|
||||
* Configs
|
||||
* Aliases
|
||||
* Defaults
|
||||
|
||||
## Examples
|
||||
|
||||
````javascript
|
||||
require('coa').Cmd() // main (top level) command declaration
|
||||
.name(process.argv[1]) // set top level command name from program name
|
||||
.title('My awesome command line util') // title for use in text messages
|
||||
.helpful() // make command "helpful", i.e. options -h --help with usage message
|
||||
.opt() // add some option
|
||||
.name('version') // name for use in API
|
||||
.title('Version') // title for use in text messages
|
||||
.short('v') // short key: -v
|
||||
.long('version') // long key: --version
|
||||
.flag() // for options without value
|
||||
.act(function(opts) { // add action for option
|
||||
// return message as result of action
|
||||
return JSON.parse(require('fs').readFileSync(__dirname + '/package.json'))
|
||||
.version;
|
||||
})
|
||||
.end() // end option chain and return to main command
|
||||
.cmd().name('subcommand').apply(require('./subcommand').COA).end() // load subcommand from module
|
||||
.cmd() // inplace subcommand declaration
|
||||
.name('othercommand').title('Awesome other subcommand').helpful()
|
||||
.opt()
|
||||
.name('input').title('input file, required')
|
||||
.short('i').long('input')
|
||||
.val(function(v) { // validator function, also for translate simple values
|
||||
return require('fs').createReadStream(v) })
|
||||
.req() // make option required
|
||||
.end() // end option chain and return to command
|
||||
.end() // end subcommand chain and return to parent command
|
||||
.run(process.argv.slice(2)); // parse and run on process.argv
|
||||
````
|
||||
|
||||
````javascript
|
||||
// subcommand.js
|
||||
exports.COA = function() {
|
||||
this
|
||||
.title('Awesome subcommand').helpful()
|
||||
.opt()
|
||||
.name('output').title('output file')
|
||||
.short('o').long('output')
|
||||
.output() // use default preset for "output" option declaration
|
||||
.end()
|
||||
};
|
||||
````
|
||||
|
||||
## API reference
|
||||
|
||||
### Cmd
|
||||
Command is a top level entity. Commands may have options and arguments.
|
||||
|
||||
#### Cmd.api
|
||||
Returns object containing all its subcommands as methods to use from other programs.<br>
|
||||
**@returns** *{Object}*
|
||||
|
||||
#### Cmd.name
|
||||
Set a canonical command identifier to be used anywhere in the API.<br>
|
||||
**@param** *String* `_name` command name<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.title
|
||||
Set a long description for command to be used anywhere in text messages.<br>
|
||||
**@param** *String* `_title` command title<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.cmd
|
||||
Create new or add existing subcommand for current command.<br>
|
||||
**@param** *COA.Cmd* `[cmd]` existing command instance<br>
|
||||
**@returns** *COA.Cmd* new or added subcommand instance
|
||||
|
||||
#### Cmd.opt
|
||||
Create option for current command.<br>
|
||||
**@returns** *COA.Opt* `new` option instance
|
||||
|
||||
#### Cmd.arg
|
||||
Create argument for current command.<br>
|
||||
**@returns** *COA.Opt* `new` argument instance
|
||||
|
||||
#### Cmd.act
|
||||
Add (or set) action for current command.<br>
|
||||
**@param** *Function* `act` action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:<br>
|
||||
- *Object* `opts` parsed options<br>
|
||||
- *Array* `args` parsed arguments<br>
|
||||
- *Object* `res` actions result accumulator<br>
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.<br>
|
||||
**@param** *{Boolean}* [force=false] flag for set action instead add to existings<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.apply
|
||||
Apply function with arguments in context of command instance.<br>
|
||||
**@param** *Function* `fn`<br>
|
||||
**@param** *Array* `args`<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.comp
|
||||
Set custom additional completion for current command.<br>
|
||||
**@param** *Function* `fn` completion generation function,
|
||||
invoked in the context of command instance.
|
||||
Accepts parameters:<br>
|
||||
- *Object* `opts` completion options<br>
|
||||
It can return promise or any other value treated as result.<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.helpful
|
||||
Make command "helpful", i.e. add -h --help flags for print usage.<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.completable
|
||||
Adds shell completion to command, adds "completion" subcommand, that makes all the magic.<br>
|
||||
Must be called only on root command.<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.usage
|
||||
Build full usage text for current command instance.<br>
|
||||
**@returns** *String* `usage` text
|
||||
|
||||
#### Cmd.run
|
||||
Parse arguments from simple format like NodeJS process.argv
|
||||
and run ahead current program, i.e. call process.exit when all actions done.<br>
|
||||
**@param** *Array* `argv`<br>
|
||||
**@returns** *COA.Cmd* `this` instance (for chainability)
|
||||
|
||||
#### Cmd.invoke
|
||||
Invoke specified (or current) command using provided options and arguments.<br>
|
||||
**@param** *String|Array* `cmds` subcommand to invoke (optional)<br>
|
||||
**@param** *Object* `opts` command options (optional)<br>
|
||||
**@param** *Object* `args` command arguments (optional)<br>
|
||||
**@returns** *Q.Promise*
|
||||
|
||||
#### Cmd.reject
|
||||
Return reject of actions results promise.<br>
|
||||
Use in .act() for return with error.<br>
|
||||
**@param** *Object* `reason` reject reason<br>
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.<br>
|
||||
**@returns** *Q.promise* rejected promise
|
||||
|
||||
#### Cmd.end
|
||||
Finish chain for current subcommand and return parent command instance.<br>
|
||||
**@returns** *COA.Cmd* `parent` command
|
||||
|
||||
### Opt
|
||||
Option is a named entity. Options may have short and long keys for use from command line.<br>
|
||||
**@namespace**<br>
|
||||
**@class** Presents option
|
||||
|
||||
#### Opt.name
|
||||
Set a canonical option identifier to be used anywhere in the API.<br>
|
||||
**@param** *String* `_name` option name<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.title
|
||||
Set a long description for option to be used anywhere in text messages.<br>
|
||||
**@param** *String* `_title` option title<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.short
|
||||
Set a short key for option to be used with one hyphen from command line.<br>
|
||||
**@param** *String* `_short`<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.long
|
||||
Set a short key for option to be used with double hyphens from command line.<br>
|
||||
**@param** *String* `_long`<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.flag
|
||||
Make an option boolean, i.e. option without value.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.arr
|
||||
Makes an option accepts multiple values.<br>
|
||||
Otherwise, the value will be used by the latter passed.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.req
|
||||
Makes an option req.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.only
|
||||
Makes an option to act as a command,
|
||||
i.e. program will exit just after option action.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.val
|
||||
Set a validation (or value) function for argument.<br>
|
||||
Value from command line passes through before becoming available from API.<br>
|
||||
Using for validation and convertion simple types to any values.<br>
|
||||
**@param** *Function* `_val` validating function,
|
||||
invoked in the context of option instance
|
||||
and has one parameter with value from command line<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.def
|
||||
Set a default value for option.
|
||||
Default value passed through validation function as ordinary value.<br>
|
||||
**@param** *Object* `_def`<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.input
|
||||
Make option value inputting stream.
|
||||
It's add useful validation and shortcut for STDIN.
|
||||
**@returns** *{COA.Opt}* `this` instance (for chainability)
|
||||
|
||||
#### Opt.output
|
||||
Make option value outputing stream.<br>
|
||||
It's add useful validation and shortcut for STDOUT.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.act
|
||||
Add action for current option command.
|
||||
This action is performed if the current option
|
||||
is present in parsed options (with any value).<br>
|
||||
**@param** *Function* `act` action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:<br>
|
||||
- *Object* `opts` parsed options<br>
|
||||
- *Array* `args` parsed arguments<br>
|
||||
- *Object* `res` actions result accumulator<br>
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.comp
|
||||
Set custom additional completion for current option.<br>
|
||||
**@param** *Function* `fn` completion generation function,
|
||||
invoked in the context of command instance.
|
||||
Accepts parameters:<br>
|
||||
- *Object* `opts` completion options<br>
|
||||
It can return promise or any other value treated as result.<br>
|
||||
**@returns** *COA.Opt* `this` instance (for chainability)
|
||||
|
||||
#### Opt.end
|
||||
Finish chain for current option and return parent command instance.<br>
|
||||
**@returns** *COA.Cmd* `parent` command
|
||||
|
||||
|
||||
### Arg
|
||||
Argument is a unnamed entity.<br>
|
||||
From command line arguments passed as list of unnamed values.
|
||||
|
||||
#### Arg.name
|
||||
Set a canonical argument identifier to be used anywhere in text messages.<br>
|
||||
**@param** *String* `_name` argument name<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.title
|
||||
Set a long description for argument to be used anywhere in text messages.<br>
|
||||
**@param** *String* `_title` argument title<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.arr
|
||||
Makes an argument accepts multiple values.<br>
|
||||
Otherwise, the value will be used by the latter passed.<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.req
|
||||
Makes an argument req.<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.val
|
||||
Set a validation (or value) function for argument.<br>
|
||||
Value from command line passes through before becoming available from API.<br>
|
||||
Using for validation and convertion simple types to any values.<br>
|
||||
**@param** *Function* `_val` validating function,
|
||||
invoked in the context of argument instance
|
||||
and has one parameter with value from command line<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.def
|
||||
Set a default value for argument.
|
||||
Default value passed through validation function as ordinary value.<br>
|
||||
**@param** *Object* `_def`<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.output
|
||||
Make argument value outputing stream.<br>
|
||||
It's add useful validation and shortcut for STDOUT.<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.comp
|
||||
Set custom additional completion for current argument.<br>
|
||||
**@param** *Function* `fn` completion generation function,
|
||||
invoked in the context of command instance.
|
||||
Accepts parameters:<br>
|
||||
- *Object* `opts` completion options<br>
|
||||
It can return promise or any other value treated as result.<br>
|
||||
**@returns** *COA.Arg* `this` instance (for chainability)
|
||||
|
||||
#### Arg.end
|
||||
Finish chain for current option and return parent command instance.<br>
|
||||
**@returns** *COA.Cmd* `parent` command
|
||||
316
build/node_modules/coa/README.ru.md
generated
vendored
Normal file
316
build/node_modules/coa/README.ru.md
generated
vendored
Normal file
@@ -0,0 +1,316 @@
|
||||
# Command-Option-Argument
|
||||
[](http://travis-ci.org/veged/coa)
|
||||
|
||||
## Что это?
|
||||
|
||||
COA — парсер параметров командной строки, позволяющий извлечь максимум пользы от формального API вашей программы.
|
||||
Как только вы опишете определение в терминах команд, параметров и аргументов, вы автоматически получите:
|
||||
|
||||
* Справку для командной строки
|
||||
* API для использования программы как модуля в COA-совместимых программах
|
||||
* Автодополнение для командной строки
|
||||
|
||||
### Прочие возможности
|
||||
|
||||
* Широкий выбор настроек для параметров и аргументов, включая множественные значения, логические значения и обязательность параметров
|
||||
* Возможность асинхронного исполнения команд, используя промисы (используется библиотека [Q](https://github.com/kriskowal/q))
|
||||
* Простота использования существующих команд как подмодулей для новых команд
|
||||
* Комбинированная валидация и анализ сложных значений
|
||||
|
||||
## Примеры
|
||||
|
||||
````javascript
|
||||
require('coa').Cmd() // декларация команды верхнего уровня
|
||||
.name(process.argv[1]) // имя команды верхнего уровня, берем из имени программы
|
||||
.title('Жутко полезная утилита для командной строки') // название для использования в справке и сообщениях
|
||||
.helpful() // добавляем поддержку справки командной строки (-h, --help)
|
||||
.opt() // добавляем параметр
|
||||
.name('version') // имя параметра для использования в API
|
||||
.title('Version') // текст для вывода в сообщениях
|
||||
.short('v') // короткое имя параметра: -v
|
||||
.long('version') // длинное имя параметра: --version
|
||||
.flag() // параметр не требует ввода значения
|
||||
.act(function(opts) { // действия при вызове аргумента
|
||||
// результатом является вывод текстового сообщения
|
||||
return JSON.parse(require('fs').readFileSync(__dirname + '/package.json'))
|
||||
.version;
|
||||
})
|
||||
.end() // завершаем определение параметра и возвращаемся к определению верхнего уровня
|
||||
.cmd().name('subcommand').apply(require('./subcommand').COA).end() // загрузка подкоманды из модуля
|
||||
.cmd() // добавляем еще одну подкоманду
|
||||
.name('othercommand').title('Еще одна полезная подпрограмма').helpful()
|
||||
.opt()
|
||||
.name('input').title('input file, required')
|
||||
.short('i').long('input')
|
||||
.val(function(v) { // функция-валидатор, также может использоваться для трансформации значений параметров
|
||||
return require('fs').createReadStream(v) })
|
||||
.req() // параметр является обязательным
|
||||
.end() // завершаем определение параметра и возвращаемся к определению команды
|
||||
.end() // завершаем определение подкоманды и возвращаемся к определению команды верхнего уровня
|
||||
.run(process.argv.slice(2)); // разбираем process.argv и запускаем
|
||||
````
|
||||
|
||||
````javascript
|
||||
// subcommand.js
|
||||
exports.COA = function() {
|
||||
this
|
||||
.title('Полезная подпрограмма').helpful()
|
||||
.opt()
|
||||
.name('output').title('output file')
|
||||
.short('o').long('output')
|
||||
.output() // использовать стандартную настройку для параметра вывода
|
||||
.end()
|
||||
};
|
||||
````
|
||||
|
||||
## API
|
||||
|
||||
### Cmd
|
||||
Команда — сущность верхнего уровня. У команды могут быть определены параметры и аргументы.
|
||||
|
||||
#### Cmd.api
|
||||
Возвращает объект, который можно использовать в других программах. Подкоманды являются методами этого объекта.<br>
|
||||
**@returns** *{Object}*
|
||||
|
||||
#### Cmd.name
|
||||
Определяет канонический идентификатор команды, используемый в вызовах API.<br>
|
||||
**@param** *String* `_name` имя команды<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.title
|
||||
Определяет название команды, используемый в текстовых сообщениях.<br>
|
||||
**@param** *String* `_title` название команды<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.cmd
|
||||
Создает новую подкоманду или добавляет ранее определенную подкоманду к текущей команде.<br>
|
||||
**@param** *COA.Cmd* `[cmd]` экземпляр ранее определенной подкоманды<br>
|
||||
**@returns** *COA.Cmd* экземпляр новой или ранее определенной подкоманды
|
||||
|
||||
#### Cmd.opt
|
||||
Создает параметр для текущей команды.<br>
|
||||
**@returns** *COA.Opt* `new` экземпляр параметра
|
||||
|
||||
#### Cmd.arg
|
||||
Создает аргумент для текущей команды.<br>
|
||||
**@returns** *COA.Opt* `new` экземпляр аргумента
|
||||
|
||||
#### Cmd.act
|
||||
Добавляет (или создает) действие для текущей команды.<br>
|
||||
**@param** *Function* `act` функция,
|
||||
выполняемая в контексте экземпляра текущей команды
|
||||
и принимающая следующие параметры:<br>
|
||||
- *Object* `opts` параметры команды<br>
|
||||
- *Array* `args` аргументы команды<br>
|
||||
- *Object* `res` объект-аккумулятор результатов<br>
|
||||
Функция может вернуть проваленный промис из Cmd.reject (в случае ошибки)
|
||||
или любое другое значение, рассматриваемое как результат.<br>
|
||||
**@param** *{Boolean}* [force=false] флаг, назначающий немедленное исполнение вместо добавления к списку существующих действий<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.apply
|
||||
Исполняет функцию с переданными аргументами в контексте экземпляра текущей команды.<br>
|
||||
**@param** *Function* `fn`<br>
|
||||
**@param** *Array* `args`<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.comp
|
||||
Назначает кастомную функцию автодополнения для текущей команды.<br>
|
||||
**@param** *Function* `fn` функция-генератор автодополнения,
|
||||
исполняемая в контексте текущей команды.
|
||||
Принимает параметры:<br>
|
||||
- *Object* `opts` параметры<br>
|
||||
Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.helpful
|
||||
Ставит флаг поддержки справки командной строки, т.е. вызов команды с параметрами -h --help выводит справку по работе с командой.<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.completable
|
||||
Добавляет поддержку автодополнения командной строки. Добавляется подкоманда "completion", которая выполняет все необходимые действия.<br>
|
||||
Может быть добавлен только для главной команды.<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.usage
|
||||
Возвращает текст справки по использованию команды для текущего экземпляра.<br>
|
||||
**@returns** *String* `usage` Текст справки по использованию
|
||||
|
||||
#### Cmd.run
|
||||
Разбирает аргументы из значения, возвращаемого NodeJS process.argv,
|
||||
и запускает текущую программу, т.е. вызывает process.exit после завершения
|
||||
всех действий.<br>
|
||||
**@param** *Array* `argv`<br>
|
||||
**@returns** *COA.Cmd* `this` экземпляр команды (для поддержки цепочки методов)
|
||||
|
||||
#### Cmd.invoke
|
||||
Исполняет переданную (или текущую) команду с указанными параметрами и аргументами.<br>
|
||||
**@param** *String|Array* `cmds` подкоманда для исполнения (необязательно)<br>
|
||||
**@param** *Object* `opts` параметры, передаваемые команде (необязательно)<br>
|
||||
**@param** *Object* `args` аргументы, передаваемые команде (необязательно)<br>
|
||||
**@returns** *Q.Promise*
|
||||
|
||||
#### Cmd.reject
|
||||
Проваливает промисы, возращенные в действиях.<br>
|
||||
Используется в .act() для возврата с ошибкой.<br>
|
||||
**@param** *Object* `reason` причина провала<br>
|
||||
Вы можете определить метод toString() и свойство toString()
|
||||
объекта причины провала.<br>
|
||||
**@returns** *Q.promise* проваленный промис
|
||||
|
||||
#### Cmd.end
|
||||
Завершает цепочку методов текущей подкоманды и возвращает экземпляр родительской команды.<br>
|
||||
**@returns** *COA.Cmd* `parent` родительская команда
|
||||
|
||||
### Opt
|
||||
Параметр — именованная сущность. У параметра может быть определено короткое или длинное имя для использования из командной строки.<br>
|
||||
**@namespace**<br>
|
||||
**@class** Переданный параметр
|
||||
|
||||
#### Opt.name
|
||||
Определяет канонический идентификатор параметра, используемый в вызовах API.<br>
|
||||
**@param** *String* `_name` имя параметра<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.title
|
||||
Определяет описание для параметра, используемое в текстовых сообщениях.<br>
|
||||
**@param** *String* `_title` название параметра<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.short
|
||||
Назначает ключ для короткого имени параметра, передаваемого из командной строки с одинарным дефисом (например, `-v`).<br>
|
||||
**@param** *String* `_short`<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.long
|
||||
Назначает ключ для длинного имени параметра, передаваемого из командной строки с двойным дефисом (например, `--version`).<br>
|
||||
**@param** *String* `_long`<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.flag
|
||||
Помечает параметр как логический, т.е. параметр не имеющий значения.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.arr
|
||||
Помечает параметр как принимающий множественные значения.<br>
|
||||
Иначе будет использовано последнее переданное значение параметра.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.req
|
||||
Помечает параметр как обязательный.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.only
|
||||
Интерпретирует параметр как команду,
|
||||
т.е. программа будет завершена сразу после выполнения параметра.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.val
|
||||
Назначает функцию валидации (или трансформации значения) для значения параметра.<br>
|
||||
Значение, полученное из командной строки, передается в функцию-валидатор прежде чем оно станет доступно из API.<br>
|
||||
Используется для валидации и трансформации введенных данных.<br>
|
||||
**@param** *Function* `_val` функция валидации,
|
||||
исполняемая в контексте экземпляра параметра
|
||||
и принимающая в качестве единственного параметра значение, полученное
|
||||
из командной строки<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.def
|
||||
Назначает значение параметра по умолчанию. Это значение также передается
|
||||
в функцию валидации как обычное значение.<br>
|
||||
**@param** *Object* `_def`<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.input
|
||||
Помечает параметр как принимающий ввод пользователя. <br>
|
||||
Позволяет использовать валидацию для STDIN.<br>
|
||||
**@returns** *{COA.Opt}* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.output
|
||||
Помечает параметр как вывод.<br>
|
||||
Позволяет использовать валидацию для STDOUT.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.act
|
||||
Добавляет (или создает) действие для текущего параметра команды.
|
||||
Это действие будет выполнено, если текущий параметр есть
|
||||
в списке полученных параметров (с любым значением).<br>
|
||||
**@param** *Function* `act` функция, выполняемая в контексте
|
||||
экземпляра текущей команды и принимающая следующие параметры:<br>
|
||||
- *Object* `opts` параметры команды<br>
|
||||
- *Array* `args` аргументы команды<br>
|
||||
- *Object* `res` объект-аккумулятор результатов<br>
|
||||
Функция может вернуть проваленный промис из Cmd.reject (в случае ошибки)
|
||||
или любое другое значение, рассматриваемое как результат.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.comp
|
||||
Назначает кастомную функцию автодополнения для текущей команды.<br>
|
||||
**@param** *Function* `fn` функция-генератор автодоплнения, исполняемая в
|
||||
контексте экземпляра команды.
|
||||
Принимает параметры:<br>
|
||||
- *Object* `opts` параметры автодополнения<br>
|
||||
Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр параметра (для поддержки цепочки методов)
|
||||
|
||||
#### Opt.end
|
||||
Завершает цепочку методов текущего параметра и возвращает экземпляр родительской команды.<br>
|
||||
**@returns** *COA.Cmd* `parent` родительская команда
|
||||
|
||||
|
||||
### Arg
|
||||
Аргумент — неименованная сущность.<br>
|
||||
Аргументы передаются из командной строки как список неименованных значений.
|
||||
|
||||
#### Arg.name
|
||||
Определяет канонический идентификатор аргумента, используемый в вызовах API.<br>
|
||||
**@param** *String* `_name` имя аргумента<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.title
|
||||
Определяет описание для аргумента, используемое в текстовых сообщениях.<br>
|
||||
**@param** *String* `_title` описание аргумента<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.arr
|
||||
Помечает аргумент как принимающий множественные значения.<br>
|
||||
Иначе будет использовано последнее переданное значение аргумента.<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.req
|
||||
Помечает аргумент как обязательный.<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.val
|
||||
Назначает функцию валидации (или трансформации значения) для аргумента.<br>
|
||||
Значение, полученное из командной строки, передается в функцию-валидатор прежде чем оно станет доступно из API.<br>
|
||||
Используется для валидации и трансформации введенных данных.<br>
|
||||
**@param** *Function* `_val` функция валидации,
|
||||
исполняемая в контексте экземпляра аргумента
|
||||
и принимающая в качестве единственного параметра значение, полученное
|
||||
из командной строки<br>
|
||||
**@returns** *COA.Opt* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.def
|
||||
Назначает дефолтное значение для аргумента. Дефолтное значение передается
|
||||
в функцию валидации как обычное значение.<br>
|
||||
**@param** *Object* `_def`<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.output
|
||||
Помечает параметр как вывод.<br>
|
||||
Позволяет назначить валидацию для STDOUT.<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.comp
|
||||
Назначает кастомную функцию автодополнения для текущего аргумента.<br>
|
||||
**@param** *Function* `fn` функция-генератор автодоплнения,
|
||||
исполняемая в контексте текущей команды.
|
||||
Принимает параметры:<br>
|
||||
- *Object* `opts` параметры
|
||||
Может возвращать промис или любое другое значение, рассматриваемое как результат исполнения команды.<br>
|
||||
**@returns** *COA.Arg* `this` экземпляр аргумента (для поддержки цепочки методов)
|
||||
|
||||
#### Arg.end
|
||||
Завершает цепочку методов текущего аргумента и возвращает экземпляр родительской команды.<br>
|
||||
**@returns** *COA.Cmd* `parent` родительская команда
|
||||
212
build/node_modules/coa/coverage/base.css
generated
vendored
Normal file
212
build/node_modules/coa/coverage/base.css
generated
vendored
Normal file
@@ -0,0 +1,212 @@
|
||||
body, html {
|
||||
margin:0; padding: 0;
|
||||
height: 100%;
|
||||
}
|
||||
body {
|
||||
font-family: Helvetica Neue, Helvetica, Arial;
|
||||
font-size: 14px;
|
||||
color:#333;
|
||||
}
|
||||
.small { font-size: 12px; }
|
||||
*, *:after, *:before {
|
||||
-webkit-box-sizing:border-box;
|
||||
-moz-box-sizing:border-box;
|
||||
box-sizing:border-box;
|
||||
}
|
||||
h1 { font-size: 20px; margin: 0;}
|
||||
h2 { font-size: 14px; }
|
||||
pre {
|
||||
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
-moz-tab-size: 2;
|
||||
-o-tab-size: 2;
|
||||
tab-size: 2;
|
||||
}
|
||||
a { color:#0074D9; text-decoration:none; }
|
||||
a:hover { text-decoration:underline; }
|
||||
.strong { font-weight: bold; }
|
||||
.space-top1 { padding: 10px 0 0 0; }
|
||||
.pad2y { padding: 20px 0; }
|
||||
.pad1y { padding: 10px 0; }
|
||||
.pad2x { padding: 0 20px; }
|
||||
.pad2 { padding: 20px; }
|
||||
.pad1 { padding: 10px; }
|
||||
.space-left2 { padding-left:55px; }
|
||||
.space-right2 { padding-right:20px; }
|
||||
.center { text-align:center; }
|
||||
.clearfix { display:block; }
|
||||
.clearfix:after {
|
||||
content:'';
|
||||
display:block;
|
||||
height:0;
|
||||
clear:both;
|
||||
visibility:hidden;
|
||||
}
|
||||
.fl { float: left; }
|
||||
@media only screen and (max-width:640px) {
|
||||
.col3 { width:100%; max-width:100%; }
|
||||
.hide-mobile { display:none!important; }
|
||||
}
|
||||
|
||||
.quiet {
|
||||
color: #7f7f7f;
|
||||
color: rgba(0,0,0,0.5);
|
||||
}
|
||||
.quiet a { opacity: 0.7; }
|
||||
|
||||
.fraction {
|
||||
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
||||
font-size: 10px;
|
||||
color: #555;
|
||||
background: #E8E8E8;
|
||||
padding: 4px 5px;
|
||||
border-radius: 3px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
div.path a:link, div.path a:visited { color: #333; }
|
||||
table.coverage {
|
||||
border-collapse: collapse;
|
||||
margin: 10px 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
table.coverage td {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
vertical-align: top;
|
||||
}
|
||||
table.coverage td.line-count {
|
||||
text-align: right;
|
||||
padding: 0 5px 0 20px;
|
||||
}
|
||||
table.coverage td.line-coverage {
|
||||
text-align: right;
|
||||
padding-right: 10px;
|
||||
min-width:20px;
|
||||
}
|
||||
|
||||
table.coverage td span.cline-any {
|
||||
display: inline-block;
|
||||
padding: 0 5px;
|
||||
width: 100%;
|
||||
}
|
||||
.missing-if-branch {
|
||||
display: inline-block;
|
||||
margin-right: 5px;
|
||||
border-radius: 3px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #333;
|
||||
color: yellow;
|
||||
}
|
||||
|
||||
.skip-if-branch {
|
||||
display: none;
|
||||
margin-right: 10px;
|
||||
position: relative;
|
||||
padding: 0 4px;
|
||||
background: #ccc;
|
||||
color: white;
|
||||
}
|
||||
.missing-if-branch .typ, .skip-if-branch .typ {
|
||||
color: inherit !important;
|
||||
}
|
||||
.coverage-summary {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
}
|
||||
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
||||
.keyline-all { border: 1px solid #ddd; }
|
||||
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
||||
.coverage-summary tbody { border: 1px solid #bbb; }
|
||||
.coverage-summary td { border-right: 1px solid #bbb; }
|
||||
.coverage-summary td:last-child { border-right: none; }
|
||||
.coverage-summary th {
|
||||
text-align: left;
|
||||
font-weight: normal;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.coverage-summary th.file { border-right: none !important; }
|
||||
.coverage-summary th.pct { }
|
||||
.coverage-summary th.pic,
|
||||
.coverage-summary th.abs,
|
||||
.coverage-summary td.pct,
|
||||
.coverage-summary td.abs { text-align: right; }
|
||||
.coverage-summary td.file { white-space: nowrap; }
|
||||
.coverage-summary td.pic { min-width: 120px !important; }
|
||||
.coverage-summary tfoot td { }
|
||||
|
||||
.coverage-summary .sorter {
|
||||
height: 10px;
|
||||
width: 7px;
|
||||
display: inline-block;
|
||||
margin-left: 0.5em;
|
||||
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
||||
}
|
||||
.coverage-summary .sorted .sorter {
|
||||
background-position: 0 -20px;
|
||||
}
|
||||
.coverage-summary .sorted-desc .sorter {
|
||||
background-position: 0 -10px;
|
||||
}
|
||||
.status-line { height: 10px; }
|
||||
/* dark red */
|
||||
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
||||
.low .chart { border:1px solid #C21F39 }
|
||||
/* medium red */
|
||||
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
||||
/* light red */
|
||||
.low, .cline-no { background:#FCE1E5 }
|
||||
/* light green */
|
||||
.high, .cline-yes { background:rgb(230,245,208) }
|
||||
/* medium green */
|
||||
.cstat-yes { background:rgb(161,215,106) }
|
||||
/* dark green */
|
||||
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
||||
.high .chart { border:1px solid rgb(77,146,33) }
|
||||
|
||||
|
||||
.medium .chart { border:1px solid #666; }
|
||||
.medium .cover-fill { background: #666; }
|
||||
|
||||
.cbranch-no { background: yellow !important; color: #111; }
|
||||
|
||||
.cstat-skip { background: #ddd; color: #111; }
|
||||
.fstat-skip { background: #ddd; color: #111 !important; }
|
||||
.cbranch-skip { background: #ddd !important; color: #111; }
|
||||
|
||||
span.cline-neutral { background: #eaeaea; }
|
||||
.medium { background: #eaeaea; }
|
||||
|
||||
.cover-fill, .cover-empty {
|
||||
display:inline-block;
|
||||
height: 12px;
|
||||
}
|
||||
.chart {
|
||||
line-height: 0;
|
||||
}
|
||||
.cover-empty {
|
||||
background: white;
|
||||
}
|
||||
.cover-full {
|
||||
border-right: none !important;
|
||||
}
|
||||
pre.prettyprint {
|
||||
border: none !important;
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
.com { color: #999 !important; }
|
||||
.ignore-none { color: #999; font-weight: normal; }
|
||||
|
||||
.wrapper {
|
||||
min-height: 100%;
|
||||
height: auto !important;
|
||||
height: 100%;
|
||||
margin: 0 auto -48px;
|
||||
}
|
||||
.footer, .push {
|
||||
height: 48px;
|
||||
}
|
||||
93
build/node_modules/coa/coverage/coa/index.html
generated
vendored
Normal file
93
build/node_modules/coa/coverage/coa/index.html
generated
vendored
Normal file
@@ -0,0 +1,93 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../prettify.css" />
|
||||
<link rel="stylesheet" href="../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../index.html">All files</a> coa
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>1/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>1/1</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<div class="pad1">
|
||||
<table class="coverage-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr>
|
||||
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="1" class="abs high">1/1</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="1" class="abs high">1/1</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
68
build/node_modules/coa/coverage/coa/index.js.html
generated
vendored
Normal file
68
build/node_modules/coa/coverage/coa/index.js.html
generated
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/index.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../prettify.css" />
|
||||
<link rel="stylesheet" href="../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../index.html">All files</a> / <a href="index.html">coa</a> index.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>1/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>1/1</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">module.exports = require('./lib');
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
239
build/node_modules/coa/coverage/coa/lib/arg.js.html
generated
vendored
Normal file
239
build/node_modules/coa/coverage/coa/lib/arg.js.html
generated
vendored
Normal file
@@ -0,0 +1,239 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/arg.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> arg.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>16/16</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">87.5% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>7/8</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>6/6</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>16/16</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">31x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">28x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const
|
||||
CoaParam = require('./coaparam'),
|
||||
Color = require('./color');
|
||||
|
||||
/**
|
||||
* Argument
|
||||
*
|
||||
* Unnamed entity. From command line arguments passed as list of unnamed values.
|
||||
*
|
||||
* @class Arg
|
||||
* @extends CoaParam
|
||||
*/
|
||||
module.exports = class Arg extends CoaParam {
|
||||
/**
|
||||
* @constructs
|
||||
* @param {COA.Cmd} cmd - parent command
|
||||
*/
|
||||
constructor(cmd) {
|
||||
super(cmd);
|
||||
|
||||
this._cmd._args.push(this);
|
||||
}
|
||||
|
||||
_saveVal(args, val) {
|
||||
this._val && (<span class="branch-1 cbranch-no" title="branch not covered" >val = this._val(val))</span>;
|
||||
|
||||
const name = this._name;
|
||||
this._arr
|
||||
? (args[name] || (args[name] = [])).push(val)
|
||||
: (args[name] = val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
_parse(arg, args) {
|
||||
return this._saveVal(args, arg);
|
||||
}
|
||||
|
||||
_checkParsed(opts, args) {
|
||||
return !args.hasOwnProperty(this._name);
|
||||
}
|
||||
|
||||
_usage() {
|
||||
const res = [];
|
||||
|
||||
res.push(Color('lpurple', this._name.toUpperCase()), ' : ', this._title);
|
||||
|
||||
this._req && res.push(' ', Color('lred', '(required)'));
|
||||
|
||||
return res.join('');
|
||||
}
|
||||
|
||||
_requiredText() {
|
||||
return `Missing required argument:\n ${this._usage()}`;
|
||||
}
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1556
build/node_modules/coa/coverage/coa/lib/cmd.js.html
generated
vendored
Normal file
1556
build/node_modules/coa/coverage/coa/lib/cmd.js.html
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
365
build/node_modules/coa/coverage/coa/lib/coaobject.js.html
generated
vendored
Normal file
365
build/node_modules/coa/coverage/coa/lib/coaobject.js.html
generated
vendored
Normal file
@@ -0,0 +1,365 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/coaobject.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> coaobject.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">75% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>12/16</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">50% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>1/2</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">71.43% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>5/7</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">75% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>12/16</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line medium'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99
|
||||
100
|
||||
101</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">58x</span>
|
||||
<span class="cline-any cline-yes">58x</span>
|
||||
<span class="cline-any cline-yes">58x</span>
|
||||
<span class="cline-any cline-yes">58x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">44x</span>
|
||||
<span class="cline-any cline-yes">44x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">8x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">38x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const Q = require('q');
|
||||
|
||||
/**
|
||||
* COA Object
|
||||
*
|
||||
* Base class for all COA-related objects
|
||||
*
|
||||
* --------|-----|-----|-----
|
||||
* | Cmd | Opt | Arg
|
||||
* --------|-----|-----|-----
|
||||
* name | ✓ | ✓ | ✓
|
||||
* title | ✓ | ✓ | ✓
|
||||
* comp | ✓ | ✓ | ✓
|
||||
* reject | ✓ | ✓ | ✓
|
||||
* end | ✓ | ✓ | ✓
|
||||
* apply | ✓ | ✓ | ✓
|
||||
*
|
||||
* @class CoaObject
|
||||
*/
|
||||
module.exports = class CoaObject {
|
||||
constructor(cmd) {
|
||||
this._cmd = cmd;
|
||||
this._name = null;
|
||||
this._title = null;
|
||||
this._comp = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a canonical identifier to be used anywhere in the API.
|
||||
*
|
||||
* @param {String} name - command, option or argument name
|
||||
* @returns {COA.CoaObject} - this instance (for chainability)
|
||||
*/
|
||||
name(name) {
|
||||
this._name = name;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a long description to be used anywhere in text messages.
|
||||
* @param {String} title - human readable entity title
|
||||
* @returns {COA.CoaObject} - this instance (for chainability)
|
||||
*/
|
||||
<span class="fstat-no" title="function not covered" > ti</span>tle(title) {
|
||||
<span class="cstat-no" title="statement not covered" > this._title = title;</span>
|
||||
<span class="cstat-no" title="statement not covered" > return this;</span>
|
||||
}
|
||||
|
||||
/**
|
||||
* Set custom additional completion for current object.
|
||||
*
|
||||
* @param {Function} comp - completion generation function,
|
||||
* invoked in the context of object instance.
|
||||
* Accepts parameters:
|
||||
* - {Object} opts - completion options
|
||||
* It can return promise or any other value threated as a result.
|
||||
* @returns {COA.CoaObject} - this instance (for chainability)
|
||||
*/
|
||||
<span class="fstat-no" title="function not covered" > co</span>mp(comp) {
|
||||
<span class="cstat-no" title="statement not covered" > this._comp = comp;</span>
|
||||
<span class="cstat-no" title="statement not covered" > return this;</span>
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply function with arguments in a context of object instance.
|
||||
*
|
||||
* @param {Function} fn - body
|
||||
* @param {Array.<*>} args... - arguments
|
||||
* @returns {COA.CoaObject} - this instance (for chainability)
|
||||
*/
|
||||
apply(fn) {
|
||||
arguments.length > 1?
|
||||
<span class="branch-0 cbranch-no" title="branch not covered" > fn.apply(this, [].slice.call(arguments, 1))</span>
|
||||
: fn.call(this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return reject of actions results promise with error code.
|
||||
* Use in .act() for return with error.
|
||||
* @param {Object} reason - reject reason
|
||||
* You can customize toString() method and exitCode property
|
||||
* of reason object.
|
||||
* @returns {Q.promise} rejected promise
|
||||
*/
|
||||
reject(reason) {
|
||||
return Q.reject(reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Finish chain for current subcommand and return parent command instance.
|
||||
* @returns {COA.Cmd} parent command
|
||||
*/
|
||||
end() {
|
||||
return this._cmd;
|
||||
}
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
440
build/node_modules/coa/coverage/coa/lib/coaparam.js.html
generated
vendored
Normal file
440
build/node_modules/coa/coverage/coa/lib/coaparam.js.html
generated
vendored
Normal file
@@ -0,0 +1,440 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/coaparam.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> coaparam.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">51.61% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>16/31</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/8</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">55.56% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>5/9</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">51.61% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>16/31</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line medium'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99
|
||||
100
|
||||
101
|
||||
102
|
||||
103
|
||||
104
|
||||
105
|
||||
106
|
||||
107
|
||||
108
|
||||
109
|
||||
110
|
||||
111
|
||||
112
|
||||
113
|
||||
114
|
||||
115
|
||||
116
|
||||
117
|
||||
118
|
||||
119
|
||||
120
|
||||
121
|
||||
122
|
||||
123
|
||||
124
|
||||
125
|
||||
126</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">32x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">32x</span>
|
||||
<span class="cline-any cline-yes">32x</span>
|
||||
<span class="cline-any cline-yes">32x</span>
|
||||
<span class="cline-any cline-yes">32x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">9x</span>
|
||||
<span class="cline-any cline-yes">9x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-yes">3x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const fs = require('fs');
|
||||
|
||||
const CoaObject = require('./coaobject');
|
||||
|
||||
/**
|
||||
* COA Parameter
|
||||
*
|
||||
* Base class for options and arguments
|
||||
*
|
||||
* --------|-----|-----|-----
|
||||
* | Cmd | Opt | Arg
|
||||
* --------|-----|-----|-----
|
||||
* arr | | ✓ | ✓
|
||||
* req | | ✓ | ✓
|
||||
* val | | ✓ | ✓
|
||||
* def | | ✓ | ✓
|
||||
* input | | ✓ | ✓
|
||||
* output | | ✓ | ✓
|
||||
*
|
||||
* @class CoaParam
|
||||
* @extends CoaObject
|
||||
*/
|
||||
module.exports = class CoaParam extends CoaObject {
|
||||
constructor(cmd) {
|
||||
super(cmd);
|
||||
|
||||
this._arr = false;
|
||||
this._req = false;
|
||||
this._val = undefined;
|
||||
this._def = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a param accepts multiple values.
|
||||
* Otherwise, the value will be used by the latter passed.
|
||||
*
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
arr() {
|
||||
this._arr = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a param required.
|
||||
*
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
req() {
|
||||
this._req = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a validation (or value) function for param.
|
||||
* Value from command line passes through before becoming available from API.
|
||||
* Using for validation and convertion simple types to any values.
|
||||
*
|
||||
* @param {Function} val - validating function,
|
||||
* invoked in the context of option instance
|
||||
* and has one parameter with value from command line.
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
val(val) {
|
||||
this._val = val;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a default value for param.
|
||||
* Default value passed through validation function as ordinary value.
|
||||
*
|
||||
* @param {*} def - default value of function generator
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
def(def) {
|
||||
this._def = def;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make option value inputting stream.
|
||||
* It's add useful validation and shortcut for STDIN.
|
||||
*
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
<span class="fstat-no" title="function not covered" > in</span>put() {
|
||||
<span class="cstat-no" title="statement not covered" > process.stdin.pause();</span>
|
||||
<span class="cstat-no" title="statement not covered" > return this</span>
|
||||
.def(process.stdin)
|
||||
.val(<span class="fstat-no" title="function not covered" >fu</span>nction(v) {
|
||||
<span class="cstat-no" title="statement not covered" > if(typeof v !== 'string')</span>
|
||||
<span class="cstat-no" title="statement not covered" > return v;</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > if(v === '-')</span>
|
||||
<span class="cstat-no" title="statement not covered" > return process.stdin;</span>
|
||||
|
||||
const s = <span class="cstat-no" title="statement not covered" >fs.createReadStream(v, { encoding : 'utf8' });</span>
|
||||
<span class="cstat-no" title="statement not covered" > s.pause();</span>
|
||||
<span class="cstat-no" title="statement not covered" > return s;</span>
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make option value outputing stream.
|
||||
* It's add useful validation and shortcut for STDOUT.
|
||||
*
|
||||
* @returns {COA.CoaParam} - this instance (for chainability)
|
||||
*/
|
||||
<span class="fstat-no" title="function not covered" > ou</span>tput() {
|
||||
<span class="cstat-no" title="statement not covered" > return this</span>
|
||||
.def(process.stdout)
|
||||
.val(<span class="fstat-no" title="function not covered" >fu</span>nction(v) {
|
||||
<span class="cstat-no" title="statement not covered" > if(typeof v !== 'string')</span>
|
||||
<span class="cstat-no" title="statement not covered" > return v;</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > if(v === '-')</span>
|
||||
<span class="cstat-no" title="statement not covered" > return process.stdout;</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > return fs.createWriteStream(v, { encoding : 'utf8' });</span>
|
||||
});
|
||||
}
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
131
build/node_modules/coa/coverage/coa/lib/color.js.html
generated
vendored
Normal file
131
build/node_modules/coa/coverage/coa/lib/color.js.html
generated
vendored
Normal file
@@ -0,0 +1,131 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/color.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> color.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>3/3</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>1/1</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>2/2</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">4x</span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const colors = {
|
||||
black : '30',
|
||||
dgray : '1;30',
|
||||
red : '31',
|
||||
lred : '1;31',
|
||||
green : '32',
|
||||
lgreen : '1;32',
|
||||
brown : '33',
|
||||
yellow : '1;33',
|
||||
blue : '34',
|
||||
lblue : '1;34',
|
||||
purple : '35',
|
||||
lpurple : '1;35',
|
||||
cyan : '36',
|
||||
lcyan : '1;36',
|
||||
lgray : '37',
|
||||
white : '1;37'
|
||||
};
|
||||
|
||||
module.exports = (c, str) => `\x1B[${colors[c]}m${str}\x1B[m`;
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
593
build/node_modules/coa/coverage/coa/lib/completion.js.html
generated
vendored
Normal file
593
build/node_modules/coa/coverage/coa/lib/completion.js.html
generated
vendored
Normal file
@@ -0,0 +1,593 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/completion.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> completion.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">11.27% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>8/71</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/32</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">0% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/14</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">12.5% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>8/64</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line low'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99
|
||||
100
|
||||
101
|
||||
102
|
||||
103
|
||||
104
|
||||
105
|
||||
106
|
||||
107
|
||||
108
|
||||
109
|
||||
110
|
||||
111
|
||||
112
|
||||
113
|
||||
114
|
||||
115
|
||||
116
|
||||
117
|
||||
118
|
||||
119
|
||||
120
|
||||
121
|
||||
122
|
||||
123
|
||||
124
|
||||
125
|
||||
126
|
||||
127
|
||||
128
|
||||
129
|
||||
130
|
||||
131
|
||||
132
|
||||
133
|
||||
134
|
||||
135
|
||||
136
|
||||
137
|
||||
138
|
||||
139
|
||||
140
|
||||
141
|
||||
142
|
||||
143
|
||||
144
|
||||
145
|
||||
146
|
||||
147
|
||||
148
|
||||
149
|
||||
150
|
||||
151
|
||||
152
|
||||
153
|
||||
154
|
||||
155
|
||||
156
|
||||
157
|
||||
158
|
||||
159
|
||||
160
|
||||
161
|
||||
162
|
||||
163
|
||||
164
|
||||
165
|
||||
166
|
||||
167
|
||||
168
|
||||
169
|
||||
170
|
||||
171
|
||||
172
|
||||
173
|
||||
174
|
||||
175
|
||||
176
|
||||
177</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const constants = require('constants');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const Q = require('q');
|
||||
|
||||
const shell = require('./shell');
|
||||
const escape = shell.escape;
|
||||
const unescape = shell.unescape;
|
||||
|
||||
/**
|
||||
* Most of the code adopted from the npm package shell completion code.
|
||||
* See https://github.com/isaacs/npm/blob/master/lib/completion.js
|
||||
*
|
||||
* @returns {COA.CoaObject}
|
||||
*/
|
||||
module.exports = function <span class="fstat-no" title="function not covered" >completion(</span>) {
|
||||
<span class="cstat-no" title="statement not covered" > return this</span>
|
||||
.title('Shell completion')
|
||||
.helpful()
|
||||
.arg()
|
||||
.name('raw')
|
||||
.title('Completion words')
|
||||
.arr()
|
||||
.end()
|
||||
.act(<span class="fstat-no" title="function not covered" >(o</span>pts, args) => {
|
||||
<span class="cstat-no" title="statement not covered" > if(process.platform === 'win32') {</span>
|
||||
const e = <span class="cstat-no" title="statement not covered" >new Error('shell completion not supported on windows');</span>
|
||||
<span class="cstat-no" title="statement not covered" > e.code = 'ENOTSUP';</span>
|
||||
<span class="cstat-no" title="statement not covered" > e.errno = constants.ENOTSUP;</span>
|
||||
<span class="cstat-no" title="statement not covered" > return this.reject(e);</span>
|
||||
}
|
||||
|
||||
// if the COMP_* isn't in the env, then just dump the script
|
||||
<span class="cstat-no" title="statement not covered" > if((process.env.COMP_CWORD == null)</span>
|
||||
|| (process.env.COMP_LINE == null)
|
||||
|| (process.env.COMP_POINT == null)) {
|
||||
<span class="cstat-no" title="statement not covered" > return dumpScript(this._cmd._name);</span>
|
||||
}
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > console.error('COMP_LINE: %s', process.env.COMP_LINE);</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('COMP_CWORD: %s', process.env.COMP_CWORD);</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('COMP_POINT: %s', process.env.COMP_POINT);</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('args: %j', args.raw);</span>
|
||||
|
||||
// completion opts
|
||||
<span class="cstat-no" title="statement not covered" > opts = getOpts(args.raw);</span>
|
||||
|
||||
// cmd
|
||||
const parsed = <span class="cstat-no" title="statement not covered" >this._cmd._parseCmd(opts.partialWords);</span>
|
||||
<span class="cstat-no" title="statement not covered" > return Q.when(complete(parsed.cmd, parsed.opts), <span class="fstat-no" title="function not covered" >(c</span>ompls) => {</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('filtered: %j', compls);</span>
|
||||
<span class="cstat-no" title="statement not covered" > return console.log(compls.map(escape).join('\n'));</span>
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
function <span class="fstat-no" title="function not covered" >dumpScript(</span>name) {
|
||||
const defer = <span class="cstat-no" title="statement not covered" >Q.defer();</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', <span class="fstat-no" title="function not covered" >fu</span>nction(err, d) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > if(err) <span class="cstat-no" title="statement not covered" >return defer.reject(err);</span></span>
|
||||
<span class="cstat-no" title="statement not covered" > d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, '');</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > process.stdout.on('error', onError);</span>
|
||||
<span class="cstat-no" title="statement not covered" > process.stdout.write(d, <span class="fstat-no" title="function not covered" >()</span> => <span class="cstat-no" title="statement not covered" >defer.resolve())</span>;</span>
|
||||
});
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > return defer.promise;</span>
|
||||
|
||||
function <span class="fstat-no" title="function not covered" >onError(</span>err) {
|
||||
// Darwin is a real dick sometimes.
|
||||
//
|
||||
// This is necessary because the "source" or "." program in
|
||||
// bash on OS X closes its file argument before reading
|
||||
// from it, meaning that you get exactly 1 write, which will
|
||||
// work most of the time, and will always raise an EPIPE.
|
||||
//
|
||||
// Really, one should not be tossing away EPIPE errors, or any
|
||||
// errors, so casually. But, without this, `. <(cmd completion)`
|
||||
// can never ever work on OS X.
|
||||
<span class="cstat-no" title="statement not covered" > if(err.errno !== constants.EPIPE) <span class="cstat-no" title="statement not covered" >return defer.reject(err);</span></span>
|
||||
<span class="cstat-no" title="statement not covered" > process.stdout.removeListener('error', onError);</span>
|
||||
<span class="cstat-no" title="statement not covered" > return defer.resolve();</span>
|
||||
}
|
||||
}
|
||||
|
||||
function <span class="fstat-no" title="function not covered" >getOpts(</span>argv) {
|
||||
// get the partial line and partial word, if the point isn't at the end
|
||||
// ie, tabbing at: cmd foo b|ar
|
||||
const line = <span class="cstat-no" title="statement not covered" >process.env.COMP_LINE;</span>
|
||||
const w = <span class="cstat-no" title="statement not covered" >+process.env.COMP_CWORD;</span>
|
||||
const point = <span class="cstat-no" title="statement not covered" >+process.env.COMP_POINT;</span>
|
||||
const words = <span class="cstat-no" title="statement not covered" >argv.map(unescape);</span>
|
||||
const word = <span class="cstat-no" title="statement not covered" >words[w];</span>
|
||||
const partialLine = <span class="cstat-no" title="statement not covered" >line.substr(0, point);</span>
|
||||
const partialWords = <span class="cstat-no" title="statement not covered" >words.slice(0, w);</span>
|
||||
|
||||
// figure out where in that last word the point is
|
||||
let partialWord = <span class="cstat-no" title="statement not covered" >argv[w] || '';</span>
|
||||
let i = <span class="cstat-no" title="statement not covered" >partialWord.length;</span>
|
||||
<span class="cstat-no" title="statement not covered" > while(partialWord.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) <span class="cstat-no" title="statement not covered" >i--;</span></span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > partialWord = unescape(partialWord.substr(0, i));</span>
|
||||
<span class="cstat-no" title="statement not covered" > partialWord && partialWords.push(partialWord);</span>
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > return {</span>
|
||||
line,
|
||||
w,
|
||||
point,
|
||||
words,
|
||||
word,
|
||||
partialLine,
|
||||
partialWords,
|
||||
partialWord
|
||||
};
|
||||
}
|
||||
|
||||
function <span class="fstat-no" title="function not covered" >complete(</span>cmd, opts) {
|
||||
let optWord, optPrefix,
|
||||
compls = <span class="cstat-no" title="statement not covered" >[];</span>
|
||||
|
||||
// Complete on cmds
|
||||
<span class="cstat-no" title="statement not covered" > if(opts.partialWord.indexOf('-'))</span>
|
||||
<span class="cstat-no" title="statement not covered" > compls = Object.keys(cmd._cmdsByName);</span>
|
||||
// Complete on required opts without '-' in last partial word
|
||||
// (if required not already specified)
|
||||
//
|
||||
// Commented out because of uselessness:
|
||||
// -b, --block suggest results in '-' on cmd line;
|
||||
// next completion suggest all options, because of '-'
|
||||
//.concat Object.keys(cmd._optsByKey).filter (v) -> cmd._optsByKey[v]._req
|
||||
else {
|
||||
// complete on opt values: --opt=| case
|
||||
const m = <span class="cstat-no" title="statement not covered" >opts.partialWord.match(/^(--\w[\w-_]*)=(.*)$/);</span>
|
||||
<span class="cstat-no" title="statement not covered" > if(m) {</span>
|
||||
<span class="cstat-no" title="statement not covered" > optWord = m[1];</span>
|
||||
<span class="cstat-no" title="statement not covered" > optPrefix = optWord + '=';</span>
|
||||
} else
|
||||
// complete on opts
|
||||
// don't complete on opts in case of --opt=val completion
|
||||
// TODO: don't complete on opts in case of unknown arg after commands
|
||||
// TODO: complete only on opts with arr() or not already used
|
||||
// TODO: complete only on full opts?
|
||||
<span class="cstat-no" title="statement not covered" > compls = Object.keys(cmd._optsByKey);</span>
|
||||
}
|
||||
|
||||
// complete on opt values: next arg case
|
||||
<span class="cstat-no" title="statement not covered" > opts.partialWords[opts.w - 1].indexOf('-') || (optWord = opts.partialWords[opts.w - 1]);</span>
|
||||
|
||||
// complete on opt values: completion
|
||||
let opt;
|
||||
<span class="cstat-no" title="statement not covered" > optWord</span>
|
||||
&& (opt = cmd._optsByKey[optWord])
|
||||
&& !opt._flag
|
||||
&& opt._comp
|
||||
&& (compls = Q.join(compls,
|
||||
Q.when(opt._comp(opts),
|
||||
<span class="fstat-no" title="function not covered" > (c</span>, o) => <span class="cstat-no" title="statement not covered" >c.concat(o.map(<span class="fstat-no" title="function not covered" >v </span>=> <span class="cstat-no" title="statement not covered" >(optPrefix || '') + v)</span>))</span>));
|
||||
|
||||
// TODO: complete on args values (context aware, custom completion?)
|
||||
|
||||
// custom completion on cmds
|
||||
<span class="cstat-no" title="statement not covered" > cmd._comp && (compls = Q.join(compls, Q.when(cmd._comp(opts)), <span class="fstat-no" title="function not covered" >(c</span>, o) => <span class="cstat-no" title="statement not covered" >c.concat(o))</span>);</span>
|
||||
|
||||
// TODO: context aware custom completion on cmds, opts and args
|
||||
// (can depend on already entered values, especially options)
|
||||
|
||||
<span class="cstat-no" title="statement not covered" > return Q.when(compls, <span class="fstat-no" title="function not covered" >co</span>mplitions => {</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('partialWord: %s', opts.partialWord);</span>
|
||||
<span class="cstat-no" title="statement not covered" > console.error('compls: %j', complitions);</span>
|
||||
<span class="cstat-no" title="statement not covered" > return compls.filter(<span class="fstat-no" title="function not covered" >(c</span>) => <span class="cstat-no" title="statement not covered" >c.indexOf(opts.partialWord) === 0)</span>;</span>
|
||||
});
|
||||
}
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
197
build/node_modules/coa/coverage/coa/lib/index.html
generated
vendored
Normal file
197
build/node_modules/coa/coverage/coa/lib/index.html
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> coa/lib
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">68.17% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>257/377</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">59.05% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>124/210</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">65.35% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>66/101</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">69.8% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>245/351</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line medium'></div>
|
||||
<div class="pad1">
|
||||
<table class="coverage-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr>
|
||||
<td class="file high" data-value="arg.js"><a href="arg.js.html">arg.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="16" class="abs high">16/16</td>
|
||||
<td data-value="87.5" class="pct high">87.5%</td>
|
||||
<td data-value="8" class="abs high">7/8</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="6" class="abs high">6/6</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="16" class="abs high">16/16</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="cmd.js"><a href="cmd.js.html">cmd.js</a></td>
|
||||
<td data-value="81.22" class="pic high"><div class="chart"><div class="cover-fill" style="width: 81%;"></div><div class="cover-empty" style="width:19%;"></div></div></td>
|
||||
<td data-value="81.22" class="pct high">81.22%</td>
|
||||
<td data-value="181" class="abs high">147/181</td>
|
||||
<td data-value="71.64" class="pct medium">71.64%</td>
|
||||
<td data-value="134" class="abs medium">96/134</td>
|
||||
<td data-value="68.75" class="pct medium">68.75%</td>
|
||||
<td data-value="48" class="abs medium">33/48</td>
|
||||
<td data-value="82.53" class="pct high">82.53%</td>
|
||||
<td data-value="166" class="abs high">137/166</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file medium" data-value="coaobject.js"><a href="coaobject.js.html">coaobject.js</a></td>
|
||||
<td data-value="75" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 75%;"></div><div class="cover-empty" style="width:25%;"></div></div></td>
|
||||
<td data-value="75" class="pct medium">75%</td>
|
||||
<td data-value="16" class="abs medium">12/16</td>
|
||||
<td data-value="50" class="pct medium">50%</td>
|
||||
<td data-value="2" class="abs medium">1/2</td>
|
||||
<td data-value="71.43" class="pct medium">71.43%</td>
|
||||
<td data-value="7" class="abs medium">5/7</td>
|
||||
<td data-value="75" class="pct medium">75%</td>
|
||||
<td data-value="16" class="abs medium">12/16</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file medium" data-value="coaparam.js"><a href="coaparam.js.html">coaparam.js</a></td>
|
||||
<td data-value="51.61" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 51%;"></div><div class="cover-empty" style="width:49%;"></div></div></td>
|
||||
<td data-value="51.61" class="pct medium">51.61%</td>
|
||||
<td data-value="31" class="abs medium">16/31</td>
|
||||
<td data-value="0" class="pct low">0%</td>
|
||||
<td data-value="8" class="abs low">0/8</td>
|
||||
<td data-value="55.56" class="pct medium">55.56%</td>
|
||||
<td data-value="9" class="abs medium">5/9</td>
|
||||
<td data-value="51.61" class="pct medium">51.61%</td>
|
||||
<td data-value="31" class="abs medium">16/31</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="color.js"><a href="color.js.html">color.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="3" class="abs high">3/3</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="1" class="abs high">1/1</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="2" class="abs high">2/2</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file low" data-value="completion.js"><a href="completion.js.html">completion.js</a></td>
|
||||
<td data-value="11.27" class="pic low"><div class="chart"><div class="cover-fill" style="width: 11%;"></div><div class="cover-empty" style="width:89%;"></div></div></td>
|
||||
<td data-value="11.27" class="pct low">11.27%</td>
|
||||
<td data-value="71" class="abs low">8/71</td>
|
||||
<td data-value="0" class="pct low">0%</td>
|
||||
<td data-value="32" class="abs low">0/32</td>
|
||||
<td data-value="0" class="pct low">0%</td>
|
||||
<td data-value="14" class="abs low">0/14</td>
|
||||
<td data-value="12.5" class="pct low">12.5%</td>
|
||||
<td data-value="64" class="abs low">8/64</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="index.js"><a href="index.js.html">index.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="opt.js"><a href="opt.js.html">opt.js</a></td>
|
||||
<td data-value="91.84" class="pic high"><div class="chart"><div class="cover-fill" style="width: 91%;"></div><div class="cover-empty" style="width:9%;"></div></div></td>
|
||||
<td data-value="91.84" class="pct high">91.84%</td>
|
||||
<td data-value="49" class="abs high">45/49</td>
|
||||
<td data-value="72.73" class="pct medium">72.73%</td>
|
||||
<td data-value="22" class="abs medium">16/22</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="14" class="abs high">14/14</td>
|
||||
<td data-value="95.65" class="pct high">95.65%</td>
|
||||
<td data-value="46" class="abs high">44/46</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file high" data-value="shell.js"><a href="shell.js.html">shell.js</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="4" class="abs high">4/4</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="2" class="abs high">2/2</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="5" class="abs high">5/5</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
107
build/node_modules/coa/coverage/coa/lib/index.js.html
generated
vendored
Normal file
107
build/node_modules/coa/coverage/coa/lib/index.js.html
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/index.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> index.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>5/5</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>0/0</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>5/5</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">const
|
||||
Cmd = require('./cmd'),
|
||||
Opt = require('./opt'),
|
||||
Arg = require('./arg'),
|
||||
shell = require('./shell');
|
||||
|
||||
module.exports = {
|
||||
Cmd : Cmd.create,
|
||||
Opt : Opt.create,
|
||||
Arg : Arg.create,
|
||||
classes : { Cmd, Opt, Arg },
|
||||
shell,
|
||||
require
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
524
build/node_modules/coa/coverage/coa/lib/opt.js.html
generated
vendored
Normal file
524
build/node_modules/coa/coverage/coa/lib/opt.js.html
generated
vendored
Normal file
@@ -0,0 +1,524 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/opt.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> opt.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">91.84% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>45/49</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">72.73% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>16/22</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>14/14</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">95.65% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>44/46</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15
|
||||
16
|
||||
17
|
||||
18
|
||||
19
|
||||
20
|
||||
21
|
||||
22
|
||||
23
|
||||
24
|
||||
25
|
||||
26
|
||||
27
|
||||
28
|
||||
29
|
||||
30
|
||||
31
|
||||
32
|
||||
33
|
||||
34
|
||||
35
|
||||
36
|
||||
37
|
||||
38
|
||||
39
|
||||
40
|
||||
41
|
||||
42
|
||||
43
|
||||
44
|
||||
45
|
||||
46
|
||||
47
|
||||
48
|
||||
49
|
||||
50
|
||||
51
|
||||
52
|
||||
53
|
||||
54
|
||||
55
|
||||
56
|
||||
57
|
||||
58
|
||||
59
|
||||
60
|
||||
61
|
||||
62
|
||||
63
|
||||
64
|
||||
65
|
||||
66
|
||||
67
|
||||
68
|
||||
69
|
||||
70
|
||||
71
|
||||
72
|
||||
73
|
||||
74
|
||||
75
|
||||
76
|
||||
77
|
||||
78
|
||||
79
|
||||
80
|
||||
81
|
||||
82
|
||||
83
|
||||
84
|
||||
85
|
||||
86
|
||||
87
|
||||
88
|
||||
89
|
||||
90
|
||||
91
|
||||
92
|
||||
93
|
||||
94
|
||||
95
|
||||
96
|
||||
97
|
||||
98
|
||||
99
|
||||
100
|
||||
101
|
||||
102
|
||||
103
|
||||
104
|
||||
105
|
||||
106
|
||||
107
|
||||
108
|
||||
109
|
||||
110
|
||||
111
|
||||
112
|
||||
113
|
||||
114
|
||||
115
|
||||
116
|
||||
117
|
||||
118
|
||||
119
|
||||
120
|
||||
121
|
||||
122
|
||||
123
|
||||
124
|
||||
125
|
||||
126
|
||||
127
|
||||
128
|
||||
129
|
||||
130
|
||||
131
|
||||
132
|
||||
133
|
||||
134
|
||||
135
|
||||
136
|
||||
137
|
||||
138
|
||||
139
|
||||
140
|
||||
141
|
||||
142
|
||||
143
|
||||
144
|
||||
145
|
||||
146
|
||||
147
|
||||
148
|
||||
149
|
||||
150
|
||||
151
|
||||
152
|
||||
153
|
||||
154</td><td class="line-coverage quiet"><span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-yes">16x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-yes">7x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">9x</span>
|
||||
<span class="cline-any cline-yes">9x</span>
|
||||
<span class="cline-any cline-yes">9x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">20x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">20x</span>
|
||||
<span class="cline-any cline-yes">20x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">20x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">18x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-no"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">'use strict';
|
||||
|
||||
const
|
||||
Q = require('q'),
|
||||
|
||||
CoaParam = require('./coaparam'),
|
||||
Color = require('./color');
|
||||
|
||||
/**
|
||||
* Option
|
||||
*
|
||||
* Named entity. Options may have short and long keys for use from command line.
|
||||
*
|
||||
* @namespace
|
||||
* @class Opt
|
||||
* @extends CoaParam
|
||||
*/
|
||||
module.exports = class Opt extends CoaParam {
|
||||
/**
|
||||
* @constructs
|
||||
* @param {COA.Cmd} cmd - parent command
|
||||
*/
|
||||
constructor(cmd) {
|
||||
super(cmd);
|
||||
|
||||
this._short = null;
|
||||
this._long = null;
|
||||
this._flag = false;
|
||||
this._only = false;
|
||||
this._cmd._opts.push(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a short key for option to be used with one hyphen from command line.
|
||||
*
|
||||
* @param {String} short - short name
|
||||
* @returns {COA.Opt} - this instance (for chainability)
|
||||
*/
|
||||
short(short) {
|
||||
this._short = short;
|
||||
this._cmd._optsByKey[`-${short}`] = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a short key for option to be used with double hyphens from command line.
|
||||
*
|
||||
* @param {String} long - long name
|
||||
* @returns {COA.Opt} - this instance (for chainability)
|
||||
*/
|
||||
long(long) {
|
||||
this._long = long;
|
||||
this._cmd._optsByKey[`--${long}`] = this;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make an option boolean, i.e. option without value.
|
||||
*
|
||||
* @returns {COA.Opt} - this instance (for chainability)
|
||||
*/
|
||||
flag() {
|
||||
this._flag = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes an option to act as a command,
|
||||
* i.e. program will exit just after option action.
|
||||
*
|
||||
* @returns {COA.Opt} - this instance (for chainability)
|
||||
*/
|
||||
only() {
|
||||
this._only = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add action for current option command.
|
||||
* This action is performed if the current option
|
||||
* is present in parsed options (with any value).
|
||||
*
|
||||
* @param {Function} act - action function,
|
||||
* invoked in the context of command instance
|
||||
* and has the parameters:
|
||||
* - {Object} opts - parsed options
|
||||
* - {Array} args - parsed arguments
|
||||
* - {Object} res - actions result accumulator
|
||||
* It can return rejected promise by Cmd.reject (in case of error)
|
||||
* or any other value treated as result.
|
||||
* @returns {COA.Opt} - this instance (for chainability)
|
||||
*/
|
||||
act(act) {
|
||||
this._cmd.act((opts) => {
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(!opts.hasOwnProperty(this._name)) <span class="cstat-no" title="statement not covered" >return;</span>
|
||||
|
||||
const res = act.apply(this._cmd, arguments);
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(!this._only) <span class="cstat-no" title="statement not covered" >return res;</span>
|
||||
|
||||
return Q.when(res, (out) => this._cmd.reject({
|
||||
toString : () => out.toString(),
|
||||
exitCode : 0
|
||||
}));
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
_saveVal(opts, val) {
|
||||
this._val && (val = this._val(val));
|
||||
|
||||
const name = this._name;
|
||||
this._arr
|
||||
? (opts[name] || (opts[name] = [])).push(val)
|
||||
: (opts[name] = val);
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
_parse(argv, opts) {
|
||||
return this._saveVal(opts, this._flag ? true : argv.shift());
|
||||
}
|
||||
|
||||
_checkParsed(opts) {
|
||||
return !opts.hasOwnProperty(this._name);
|
||||
}
|
||||
|
||||
_usage() {
|
||||
const res = [],
|
||||
nameStr = this._name.toUpperCase();
|
||||
|
||||
<span class="missing-if-branch" title="else path not taken" >E</span>if(this._short) {
|
||||
res.push('-', Color('lgreen', this._short));
|
||||
this._flag || res.push(' ' + nameStr);
|
||||
res.push(', ');
|
||||
}
|
||||
|
||||
<span class="missing-if-branch" title="if path not taken" >I</span>if(this._long) {
|
||||
<span class="cstat-no" title="statement not covered" > res.push('--', Color('green', this._long));</span>
|
||||
<span class="cstat-no" title="statement not covered" > this._flag || res.push('=' + nameStr);</span>
|
||||
}
|
||||
|
||||
res.push(' : ', this._title);
|
||||
|
||||
this._req && res.push(' ', Color('lred', '(required)'));
|
||||
|
||||
return res.join('');
|
||||
}
|
||||
|
||||
_requiredText() {
|
||||
return `Missing required option:\n ${this._usage()}`;
|
||||
}
|
||||
};
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
107
build/node_modules/coa/coverage/coa/lib/shell.js.html
generated
vendored
Normal file
107
build/node_modules/coa/coverage/coa/lib/shell.js.html
generated
vendored
Normal file
@@ -0,0 +1,107 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for coa/lib/shell.js</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../../prettify.css" />
|
||||
<link rel="stylesheet" href="../../base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(../../sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
<a href="../../index.html">All files</a> / <a href="index.html">coa/lib</a> shell.js
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>5/5</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>4/4</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>2/2</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">100% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>5/5</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line high'></div>
|
||||
<pre><table class="coverage">
|
||||
<tr><td class="line-count quiet">1
|
||||
2
|
||||
3
|
||||
4
|
||||
5
|
||||
6
|
||||
7
|
||||
8
|
||||
9
|
||||
10
|
||||
11
|
||||
12
|
||||
13
|
||||
14
|
||||
15</td><td class="line-coverage quiet"><span class="cline-any cline-yes">1x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">2x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-yes">6x</span>
|
||||
<span class="cline-any cline-neutral"> </span>
|
||||
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">module.exports = { escape, unescape };
|
||||
|
||||
function unescape(w) {
|
||||
w = w.charAt(0) === '"'
|
||||
? w.replace(/^"|([^\\])"$/g, '$1')
|
||||
: w.replace(/\\ /g, ' ');
|
||||
|
||||
return w.replace(/\\("|'|\$|`|\\)/g, '$1');
|
||||
}
|
||||
|
||||
function escape(w) {
|
||||
w = w.replace(/(["'$`\\])/g,'\\$1');
|
||||
return w.match(/\s+/) ? `"${w}"` : w;
|
||||
}
|
||||
</pre></td></tr>
|
||||
</table></pre>
|
||||
<div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="../../prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="../../sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
106
build/node_modules/coa/coverage/index.html
generated
vendored
Normal file
106
build/node_modules/coa/coverage/index.html
generated
vendored
Normal file
@@ -0,0 +1,106 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>Code coverage report for All files</title>
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="prettify.css" />
|
||||
<link rel="stylesheet" href="base.css" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<style type='text/css'>
|
||||
.coverage-summary .sorter {
|
||||
background-image: url(sort-arrow-sprite.png);
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class='wrapper'>
|
||||
<div class='pad1'>
|
||||
<h1>
|
||||
All files
|
||||
</h1>
|
||||
<div class='clearfix'>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">68.25% </span>
|
||||
<span class="quiet">Statements</span>
|
||||
<span class='fraction'>258/378</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">59.05% </span>
|
||||
<span class="quiet">Branches</span>
|
||||
<span class='fraction'>124/210</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">65.35% </span>
|
||||
<span class="quiet">Functions</span>
|
||||
<span class='fraction'>66/101</span>
|
||||
</div>
|
||||
<div class='fl pad1y space-right2'>
|
||||
<span class="strong">69.89% </span>
|
||||
<span class="quiet">Lines</span>
|
||||
<span class='fraction'>246/352</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class='status-line medium'></div>
|
||||
<div class="pad1">
|
||||
<table class="coverage-summary">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-col="file" data-fmt="html" data-html="true" class="file">File</th>
|
||||
<th data-col="pic" data-type="number" data-fmt="html" data-html="true" class="pic"></th>
|
||||
<th data-col="statements" data-type="number" data-fmt="pct" class="pct">Statements</th>
|
||||
<th data-col="statements_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="branches" data-type="number" data-fmt="pct" class="pct">Branches</th>
|
||||
<th data-col="branches_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="functions" data-type="number" data-fmt="pct" class="pct">Functions</th>
|
||||
<th data-col="functions_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
<th data-col="lines" data-type="number" data-fmt="pct" class="pct">Lines</th>
|
||||
<th data-col="lines_raw" data-type="number" data-fmt="html" class="abs"></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody><tr>
|
||||
<td class="file high" data-value="coa"><a href="coa/index.html">coa</a></td>
|
||||
<td data-value="100" class="pic high"><div class="chart"><div class="cover-fill cover-full" style="width: 100%;"></div><div class="cover-empty" style="width:0%;"></div></div></td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="1" class="abs high">1/1</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="0" class="abs high">0/0</td>
|
||||
<td data-value="100" class="pct high">100%</td>
|
||||
<td data-value="1" class="abs high">1/1</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="file medium" data-value="coa/lib"><a href="coa/lib/index.html">coa/lib</a></td>
|
||||
<td data-value="68.17" class="pic medium"><div class="chart"><div class="cover-fill" style="width: 68%;"></div><div class="cover-empty" style="width:32%;"></div></div></td>
|
||||
<td data-value="68.17" class="pct medium">68.17%</td>
|
||||
<td data-value="377" class="abs medium">257/377</td>
|
||||
<td data-value="59.05" class="pct medium">59.05%</td>
|
||||
<td data-value="210" class="abs medium">124/210</td>
|
||||
<td data-value="65.35" class="pct medium">65.35%</td>
|
||||
<td data-value="101" class="abs medium">66/101</td>
|
||||
<td data-value="69.8" class="pct medium">69.8%</td>
|
||||
<td data-value="351" class="abs medium">245/351</td>
|
||||
</tr>
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div><div class='push'></div><!-- for sticky footer -->
|
||||
</div><!-- /wrapper -->
|
||||
<div class='footer quiet pad2 space-top1 center small'>
|
||||
Code coverage
|
||||
generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Fri Feb 17 2017 22:25:28 GMT+0300 (MSK)
|
||||
</div>
|
||||
</div>
|
||||
<script src="prettify.js"></script>
|
||||
<script>
|
||||
window.onload = function () {
|
||||
if (typeof prettyPrint === 'function') {
|
||||
prettyPrint();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<script src="sorter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
1
build/node_modules/coa/coverage/prettify.css
generated
vendored
Normal file
1
build/node_modules/coa/coverage/prettify.css
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
.pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee}
|
||||
1
build/node_modules/coa/coverage/prettify.js
generated
vendored
Normal file
1
build/node_modules/coa/coverage/prettify.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
BIN
build/node_modules/coa/coverage/sort-arrow-sprite.png
generated
vendored
Normal file
BIN
build/node_modules/coa/coverage/sort-arrow-sprite.png
generated
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 209 B |
158
build/node_modules/coa/coverage/sorter.js
generated
vendored
Normal file
158
build/node_modules/coa/coverage/sorter.js
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
var addSorting = (function () {
|
||||
"use strict";
|
||||
var cols,
|
||||
currentSort = {
|
||||
index: 0,
|
||||
desc: false
|
||||
};
|
||||
|
||||
// returns the summary table element
|
||||
function getTable() { return document.querySelector('.coverage-summary'); }
|
||||
// returns the thead element of the summary table
|
||||
function getTableHeader() { return getTable().querySelector('thead tr'); }
|
||||
// returns the tbody element of the summary table
|
||||
function getTableBody() { return getTable().querySelector('tbody'); }
|
||||
// returns the th element for nth column
|
||||
function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; }
|
||||
|
||||
// loads all columns
|
||||
function loadColumns() {
|
||||
var colNodes = getTableHeader().querySelectorAll('th'),
|
||||
colNode,
|
||||
cols = [],
|
||||
col,
|
||||
i;
|
||||
|
||||
for (i = 0; i < colNodes.length; i += 1) {
|
||||
colNode = colNodes[i];
|
||||
col = {
|
||||
key: colNode.getAttribute('data-col'),
|
||||
sortable: !colNode.getAttribute('data-nosort'),
|
||||
type: colNode.getAttribute('data-type') || 'string'
|
||||
};
|
||||
cols.push(col);
|
||||
if (col.sortable) {
|
||||
col.defaultDescSort = col.type === 'number';
|
||||
colNode.innerHTML = colNode.innerHTML + '<span class="sorter"></span>';
|
||||
}
|
||||
}
|
||||
return cols;
|
||||
}
|
||||
// attaches a data attribute to every tr element with an object
|
||||
// of data values keyed by column name
|
||||
function loadRowData(tableRow) {
|
||||
var tableCols = tableRow.querySelectorAll('td'),
|
||||
colNode,
|
||||
col,
|
||||
data = {},
|
||||
i,
|
||||
val;
|
||||
for (i = 0; i < tableCols.length; i += 1) {
|
||||
colNode = tableCols[i];
|
||||
col = cols[i];
|
||||
val = colNode.getAttribute('data-value');
|
||||
if (col.type === 'number') {
|
||||
val = Number(val);
|
||||
}
|
||||
data[col.key] = val;
|
||||
}
|
||||
return data;
|
||||
}
|
||||
// loads all row data
|
||||
function loadData() {
|
||||
var rows = getTableBody().querySelectorAll('tr'),
|
||||
i;
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
rows[i].data = loadRowData(rows[i]);
|
||||
}
|
||||
}
|
||||
// sorts the table using the data for the ith column
|
||||
function sortByIndex(index, desc) {
|
||||
var key = cols[index].key,
|
||||
sorter = function (a, b) {
|
||||
a = a.data[key];
|
||||
b = b.data[key];
|
||||
return a < b ? -1 : a > b ? 1 : 0;
|
||||
},
|
||||
finalSorter = sorter,
|
||||
tableBody = document.querySelector('.coverage-summary tbody'),
|
||||
rowNodes = tableBody.querySelectorAll('tr'),
|
||||
rows = [],
|
||||
i;
|
||||
|
||||
if (desc) {
|
||||
finalSorter = function (a, b) {
|
||||
return -1 * sorter(a, b);
|
||||
};
|
||||
}
|
||||
|
||||
for (i = 0; i < rowNodes.length; i += 1) {
|
||||
rows.push(rowNodes[i]);
|
||||
tableBody.removeChild(rowNodes[i]);
|
||||
}
|
||||
|
||||
rows.sort(finalSorter);
|
||||
|
||||
for (i = 0; i < rows.length; i += 1) {
|
||||
tableBody.appendChild(rows[i]);
|
||||
}
|
||||
}
|
||||
// removes sort indicators for current column being sorted
|
||||
function removeSortIndicators() {
|
||||
var col = getNthColumn(currentSort.index),
|
||||
cls = col.className;
|
||||
|
||||
cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, '');
|
||||
col.className = cls;
|
||||
}
|
||||
// adds sort indicators for current column being sorted
|
||||
function addSortIndicators() {
|
||||
getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted';
|
||||
}
|
||||
// adds event listeners for all sorter widgets
|
||||
function enableUI() {
|
||||
var i,
|
||||
el,
|
||||
ithSorter = function ithSorter(i) {
|
||||
var col = cols[i];
|
||||
|
||||
return function () {
|
||||
var desc = col.defaultDescSort;
|
||||
|
||||
if (currentSort.index === i) {
|
||||
desc = !currentSort.desc;
|
||||
}
|
||||
sortByIndex(i, desc);
|
||||
removeSortIndicators();
|
||||
currentSort.index = i;
|
||||
currentSort.desc = desc;
|
||||
addSortIndicators();
|
||||
};
|
||||
};
|
||||
for (i =0 ; i < cols.length; i += 1) {
|
||||
if (cols[i].sortable) {
|
||||
// add the click event handler on the th so users
|
||||
// dont have to click on those tiny arrows
|
||||
el = getNthColumn(i).querySelector('.sorter').parentElement;
|
||||
if (el.addEventListener) {
|
||||
el.addEventListener('click', ithSorter(i));
|
||||
} else {
|
||||
el.attachEvent('onclick', ithSorter(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// adds sorting functionality to the UI
|
||||
return function () {
|
||||
if (!getTable()) {
|
||||
return;
|
||||
}
|
||||
cols = loadColumns();
|
||||
loadData(cols);
|
||||
addSortIndicators();
|
||||
enableUI();
|
||||
};
|
||||
})();
|
||||
|
||||
window.addEventListener('load', addSorting);
|
||||
1
build/node_modules/coa/index.js
generated
vendored
Normal file
1
build/node_modules/coa/index.js
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
module.exports = require(process.env.COVER? './lib-cov' : './lib');
|
||||
175
build/node_modules/coa/lib/arg.js
generated
vendored
Normal file
175
build/node_modules/coa/lib/arg.js
generated
vendored
Normal file
@@ -0,0 +1,175 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
var Arg, Cmd, Color, Opt;
|
||||
|
||||
Color = require('./color').Color;
|
||||
|
||||
Cmd = require('./cmd').Cmd;
|
||||
|
||||
Opt = require('./opt').Opt;
|
||||
|
||||
/**
|
||||
Argument
|
||||
|
||||
Unnamed entity. From command line arguments passed as list of unnamed values.
|
||||
@namespace
|
||||
@class Presents argument
|
||||
*/
|
||||
|
||||
|
||||
exports.Arg = Arg = (function() {
|
||||
/**
|
||||
@constructs
|
||||
@param {COA.Cmd} cmd parent command
|
||||
*/
|
||||
|
||||
function Arg(_cmd) {
|
||||
this._cmd = _cmd;
|
||||
this._cmd._args.push(this);
|
||||
}
|
||||
|
||||
/**
|
||||
Set a canonical argument identifier to be used anywhere in text messages.
|
||||
@param {String} _name argument name
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.name = Opt.prototype.name;
|
||||
|
||||
/**
|
||||
Set a long description for argument to be used anywhere in text messages.
|
||||
@param {String} _title argument title
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.title = Cmd.prototype.title;
|
||||
|
||||
/**
|
||||
Makes an argument accepts multiple values.
|
||||
Otherwise, the value will be used by the latter passed.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.arr = Opt.prototype.arr;
|
||||
|
||||
/**
|
||||
Makes an argument required.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.req = Opt.prototype.req;
|
||||
|
||||
/**
|
||||
Set a validation (or value) function for argument.
|
||||
Value from command line passes through before becoming available from API.
|
||||
Using for validation and convertion simple types to any values.
|
||||
@param {Function} _val validating function,
|
||||
invoked in the context of argument instance
|
||||
and has one parameter with value from command line
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.val = Opt.prototype.val;
|
||||
|
||||
/**
|
||||
Set a default value for argument.
|
||||
Default value passed through validation function as ordinary value.
|
||||
@param {Object} _def
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.def = Opt.prototype.def;
|
||||
|
||||
/**
|
||||
Set custom additional completion for current argument.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of argument instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.comp = Cmd.prototype.comp;
|
||||
|
||||
/**
|
||||
Make argument value inputting stream.
|
||||
It's add useful validation and shortcut for STDIN.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.input = Opt.prototype.input;
|
||||
|
||||
/**
|
||||
Make argument value outputing stream.
|
||||
It's add useful validation and shortcut for STDOUT.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.output = Opt.prototype.output;
|
||||
|
||||
Arg.prototype._parse = function(arg, args) {
|
||||
return this._saveVal(args, arg);
|
||||
};
|
||||
|
||||
Arg.prototype._saveVal = Opt.prototype._saveVal;
|
||||
|
||||
Arg.prototype._checkParsed = function(opts, args) {
|
||||
return !args.hasOwnProperty(this._name);
|
||||
};
|
||||
|
||||
Arg.prototype._usage = function() {
|
||||
var res;
|
||||
res = [];
|
||||
res.push(Color('lpurple', this._name.toUpperCase()), ' : ', this._title);
|
||||
if (this._req) {
|
||||
res.push(' ', Color('lred', '(required)'));
|
||||
}
|
||||
return res.join('');
|
||||
};
|
||||
|
||||
Arg.prototype._requiredText = function() {
|
||||
return 'Missing required argument:\n ' + this._usage();
|
||||
};
|
||||
|
||||
/**
|
||||
Return rejected promise with error code.
|
||||
Use in .val() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.reject = Cmd.prototype.reject;
|
||||
|
||||
/**
|
||||
Finish chain for current option and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.end = Cmd.prototype.end;
|
||||
|
||||
/**
|
||||
Apply function with arguments in context of arg instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Arg.prototype.apply = Cmd.prototype.apply;
|
||||
|
||||
return Arg;
|
||||
|
||||
})();
|
||||
605
build/node_modules/coa/lib/cmd.js
generated
vendored
Normal file
605
build/node_modules/coa/lib/cmd.js
generated
vendored
Normal file
@@ -0,0 +1,605 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
var Cmd, Color, PATH, Q, UTIL,
|
||||
__slice = [].slice;
|
||||
|
||||
UTIL = require('util');
|
||||
|
||||
PATH = require('path');
|
||||
|
||||
Color = require('./color').Color;
|
||||
|
||||
Q = require('q');
|
||||
|
||||
/**
|
||||
Command
|
||||
|
||||
Top level entity. Commands may have options and arguments.
|
||||
@namespace
|
||||
@class Presents command
|
||||
*/
|
||||
|
||||
|
||||
exports.Cmd = Cmd = (function() {
|
||||
/**
|
||||
@constructs
|
||||
@param {COA.Cmd} [cmd] parent command
|
||||
*/
|
||||
|
||||
function Cmd(cmd) {
|
||||
if (!(this instanceof Cmd)) {
|
||||
return new Cmd(cmd);
|
||||
}
|
||||
this._parent(cmd);
|
||||
this._cmds = [];
|
||||
this._cmdsByName = {};
|
||||
this._opts = [];
|
||||
this._optsByKey = {};
|
||||
this._args = [];
|
||||
this._ext = false;
|
||||
}
|
||||
|
||||
Cmd.get = function(propertyName, func) {
|
||||
return Object.defineProperty(this.prototype, propertyName, {
|
||||
configurable: true,
|
||||
enumerable: true,
|
||||
get: func
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Returns object containing all its subcommands as methods
|
||||
to use from other programs.
|
||||
@returns {Object}
|
||||
*/
|
||||
|
||||
|
||||
Cmd.get('api', function() {
|
||||
var c, _fn,
|
||||
_this = this;
|
||||
if (!this._api) {
|
||||
this._api = function() {
|
||||
return _this.invoke.apply(_this, arguments);
|
||||
};
|
||||
}
|
||||
_fn = function(c) {
|
||||
return _this._api[c] = _this._cmdsByName[c].api;
|
||||
};
|
||||
for (c in this._cmdsByName) {
|
||||
_fn(c);
|
||||
}
|
||||
return this._api;
|
||||
});
|
||||
|
||||
Cmd.prototype._parent = function(cmd) {
|
||||
this._cmd = cmd || this;
|
||||
if (cmd) {
|
||||
cmd._cmds.push(this);
|
||||
if (this._name) {
|
||||
this._cmd._cmdsByName[this._name] = this;
|
||||
}
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a canonical command identifier to be used anywhere in the API.
|
||||
@param {String} _name command name
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.name = function(_name) {
|
||||
this._name = _name;
|
||||
if (this._cmd !== this) {
|
||||
this._cmd._cmdsByName[_name] = this;
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a long description for command to be used anywhere in text messages.
|
||||
@param {String} _title command title
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.title = function(_title) {
|
||||
this._title = _title;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Create new or add existing subcommand for current command.
|
||||
@param {COA.Cmd} [cmd] existing command instance
|
||||
@returns {COA.Cmd} new subcommand instance
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.cmd = function(cmd) {
|
||||
if (cmd) {
|
||||
return cmd._parent(this);
|
||||
} else {
|
||||
return new Cmd(this);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
Create option for current command.
|
||||
@returns {COA.Opt} new option instance
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.opt = function() {
|
||||
return new (require('./opt').Opt)(this);
|
||||
};
|
||||
|
||||
/**
|
||||
Create argument for current command.
|
||||
@returns {COA.Opt} new argument instance
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.arg = function() {
|
||||
return new (require('./arg').Arg)(this);
|
||||
};
|
||||
|
||||
/**
|
||||
Add (or set) action for current command.
|
||||
@param {Function} act action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:
|
||||
- {Object} opts parsed options
|
||||
- {Array} args parsed arguments
|
||||
- {Object} res actions result accumulator
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.
|
||||
@param {Boolean} [force=false] flag for set action instead add to existings
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.act = function(act, force) {
|
||||
if (!act) {
|
||||
return this;
|
||||
}
|
||||
if (!force && this._act) {
|
||||
this._act.push(act);
|
||||
} else {
|
||||
this._act = [act];
|
||||
}
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set custom additional completion for current command.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of command instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.comp = function(_comp) {
|
||||
this._comp = _comp;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Apply function with arguments in context of command instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.apply = function() {
|
||||
var args, fn;
|
||||
fn = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
|
||||
fn.apply(this, args);
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Make command "helpful", i.e. add -h --help flags for print usage.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.helpful = function() {
|
||||
return this.opt().name('help').title('Help').short('h').long('help').flag().only().act(function() {
|
||||
return this.usage();
|
||||
}).end();
|
||||
};
|
||||
|
||||
/**
|
||||
Adds shell completion to command, adds "completion" subcommand,
|
||||
that makes all the magic.
|
||||
Must be called only on root command.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.completable = function() {
|
||||
return this.cmd().name('completion').apply(require('./completion')).end();
|
||||
};
|
||||
|
||||
/**
|
||||
Allow command to be extendable by external node.js modules.
|
||||
@param {String} [pattern] Pattern of node.js module to find subcommands at.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.extendable = function(pattern) {
|
||||
this._ext = pattern || true;
|
||||
return this;
|
||||
};
|
||||
|
||||
Cmd.prototype._exit = function(msg, code) {
|
||||
return process.once('exit', function() {
|
||||
if (msg) {
|
||||
console.error(msg);
|
||||
}
|
||||
return process.exit(code || 0);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Build full usage text for current command instance.
|
||||
@returns {String} usage text
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.usage = function() {
|
||||
var res;
|
||||
res = [];
|
||||
if (this._title) {
|
||||
res.push(this._fullTitle());
|
||||
}
|
||||
res.push('', 'Usage:');
|
||||
if (this._cmds.length) {
|
||||
res.push(['', '', Color('lred', this._fullName()), Color('lblue', 'COMMAND'), Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')].join(' '));
|
||||
}
|
||||
if (this._opts.length + this._args.length) {
|
||||
res.push(['', '', Color('lred', this._fullName()), Color('lgreen', '[OPTIONS]'), Color('lpurple', '[ARGS]')].join(' '));
|
||||
}
|
||||
res.push(this._usages(this._cmds, 'Commands'), this._usages(this._opts, 'Options'), this._usages(this._args, 'Arguments'));
|
||||
return res.join('\n');
|
||||
};
|
||||
|
||||
Cmd.prototype._usage = function() {
|
||||
return Color('lblue', this._name) + ' : ' + this._title;
|
||||
};
|
||||
|
||||
Cmd.prototype._usages = function(os, title) {
|
||||
var o, res, _i, _len;
|
||||
if (!os.length) {
|
||||
return;
|
||||
}
|
||||
res = ['', title + ':'];
|
||||
for (_i = 0, _len = os.length; _i < _len; _i++) {
|
||||
o = os[_i];
|
||||
res.push(' ' + o._usage());
|
||||
}
|
||||
return res.join('\n');
|
||||
};
|
||||
|
||||
Cmd.prototype._fullTitle = function() {
|
||||
return (this._cmd === this ? '' : this._cmd._fullTitle() + '\n') + this._title;
|
||||
};
|
||||
|
||||
Cmd.prototype._fullName = function() {
|
||||
return (this._cmd === this ? '' : this._cmd._fullName() + ' ') + PATH.basename(this._name);
|
||||
};
|
||||
|
||||
Cmd.prototype._ejectOpt = function(opts, opt) {
|
||||
var pos;
|
||||
if ((pos = opts.indexOf(opt)) >= 0) {
|
||||
if (opts[pos]._arr) {
|
||||
return opts[pos];
|
||||
} else {
|
||||
return opts.splice(pos, 1)[0];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Cmd.prototype._checkRequired = function(opts, args) {
|
||||
var all, i;
|
||||
if (!(this._opts.filter(function(o) {
|
||||
return o._only && o._name in opts;
|
||||
})).length) {
|
||||
all = this._opts.concat(this._args);
|
||||
while (i = all.shift()) {
|
||||
if (i._req && i._checkParsed(opts, args)) {
|
||||
return this.reject(i._requiredText());
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Cmd.prototype._parseCmd = function(argv, unparsed) {
|
||||
var c, cmd, cmdDesc, e, i, optSeen, pkg;
|
||||
if (unparsed == null) {
|
||||
unparsed = [];
|
||||
}
|
||||
argv = argv.concat();
|
||||
optSeen = false;
|
||||
while (i = argv.shift()) {
|
||||
if (!i.indexOf('-')) {
|
||||
optSeen = true;
|
||||
}
|
||||
if (!optSeen && /^\w[\w-_]*$/.test(i)) {
|
||||
cmd = this._cmdsByName[i];
|
||||
if (!cmd && this._ext) {
|
||||
if (typeof this._ext === 'string') {
|
||||
if (~this._ext.indexOf('%s')) {
|
||||
pkg = UTIL.format(this._ext, i);
|
||||
} else {
|
||||
pkg = this._ext + i;
|
||||
}
|
||||
} else if (this._ext === true) {
|
||||
pkg = i;
|
||||
c = this;
|
||||
while (true) {
|
||||
pkg = c._name + '-' + pkg;
|
||||
if (c._cmd === c) {
|
||||
break;
|
||||
}
|
||||
c = c._cmd;
|
||||
}
|
||||
}
|
||||
try {
|
||||
cmdDesc = require(pkg);
|
||||
} catch (_error) {
|
||||
e = _error;
|
||||
}
|
||||
if (cmdDesc) {
|
||||
if (typeof cmdDesc === 'function') {
|
||||
this.cmd().name(i).apply(cmdDesc).end();
|
||||
} else if (typeof cmdDesc === 'object') {
|
||||
this.cmd(cmdDesc);
|
||||
cmdDesc.name(i);
|
||||
} else {
|
||||
throw new Error('Error: Unsupported command declaration type, ' + 'should be function or COA.Cmd() object');
|
||||
}
|
||||
cmd = this._cmdsByName[i];
|
||||
}
|
||||
}
|
||||
if (cmd) {
|
||||
return cmd._parseCmd(argv, unparsed);
|
||||
}
|
||||
}
|
||||
unparsed.push(i);
|
||||
}
|
||||
return {
|
||||
cmd: this,
|
||||
argv: unparsed
|
||||
};
|
||||
};
|
||||
|
||||
Cmd.prototype._parseOptsAndArgs = function(argv) {
|
||||
var a, arg, args, i, m, nonParsedArgs, nonParsedOpts, opt, opts, res;
|
||||
opts = {};
|
||||
args = {};
|
||||
nonParsedOpts = this._opts.concat();
|
||||
nonParsedArgs = this._args.concat();
|
||||
while (i = argv.shift()) {
|
||||
if (i !== '--' && !i.indexOf('-')) {
|
||||
if (m = i.match(/^(--\w[\w-_]*)=(.*)$/)) {
|
||||
i = m[1];
|
||||
if (!this._optsByKey[i]._flag) {
|
||||
argv.unshift(m[2]);
|
||||
}
|
||||
}
|
||||
if (opt = this._ejectOpt(nonParsedOpts, this._optsByKey[i])) {
|
||||
if (Q.isRejected(res = opt._parse(argv, opts))) {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return this.reject("Unknown option: " + i);
|
||||
}
|
||||
} else {
|
||||
if (i === '--') {
|
||||
i = argv.splice(0);
|
||||
}
|
||||
i = Array.isArray(i) ? i : [i];
|
||||
while (a = i.shift()) {
|
||||
if (arg = nonParsedArgs.shift()) {
|
||||
if (arg._arr) {
|
||||
nonParsedArgs.unshift(arg);
|
||||
}
|
||||
if (Q.isRejected(res = arg._parse(a, args))) {
|
||||
return res;
|
||||
}
|
||||
} else {
|
||||
return this.reject("Unknown argument: " + a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return {
|
||||
opts: this._setDefaults(opts, nonParsedOpts),
|
||||
args: this._setDefaults(args, nonParsedArgs)
|
||||
};
|
||||
};
|
||||
|
||||
Cmd.prototype._setDefaults = function(params, desc) {
|
||||
var i, _i, _len;
|
||||
for (_i = 0, _len = desc.length; _i < _len; _i++) {
|
||||
i = desc[_i];
|
||||
if (!(i._name in params) && '_def' in i) {
|
||||
i._saveVal(params, i._def);
|
||||
}
|
||||
}
|
||||
return params;
|
||||
};
|
||||
|
||||
Cmd.prototype._processParams = function(params, desc) {
|
||||
var i, n, notExists, res, v, vals, _i, _j, _len, _len1;
|
||||
notExists = [];
|
||||
for (_i = 0, _len = desc.length; _i < _len; _i++) {
|
||||
i = desc[_i];
|
||||
n = i._name;
|
||||
if (!(n in params)) {
|
||||
notExists.push(i);
|
||||
continue;
|
||||
}
|
||||
vals = params[n];
|
||||
delete params[n];
|
||||
if (!Array.isArray(vals)) {
|
||||
vals = [vals];
|
||||
}
|
||||
for (_j = 0, _len1 = vals.length; _j < _len1; _j++) {
|
||||
v = vals[_j];
|
||||
if (Q.isRejected(res = i._saveVal(params, v))) {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return this._setDefaults(params, notExists);
|
||||
};
|
||||
|
||||
Cmd.prototype._parseArr = function(argv) {
|
||||
return Q.when(this._parseCmd(argv), function(p) {
|
||||
return Q.when(p.cmd._parseOptsAndArgs(p.argv), function(r) {
|
||||
return {
|
||||
cmd: p.cmd,
|
||||
opts: r.opts,
|
||||
args: r.args
|
||||
};
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
Cmd.prototype._do = function(input) {
|
||||
var _this = this;
|
||||
return Q.when(input, function(input) {
|
||||
var cmd;
|
||||
cmd = input.cmd;
|
||||
return [_this._checkRequired].concat(cmd._act || []).reduce(function(res, act) {
|
||||
return Q.when(res, function(res) {
|
||||
return act.call(cmd, input.opts, input.args, res);
|
||||
});
|
||||
}, void 0);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Parse arguments from simple format like NodeJS process.argv
|
||||
and run ahead current program, i.e. call process.exit when all actions done.
|
||||
@param {Array} argv
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.run = function(argv) {
|
||||
var cb,
|
||||
_this = this;
|
||||
if (argv == null) {
|
||||
argv = process.argv.slice(2);
|
||||
}
|
||||
cb = function(code) {
|
||||
return function(res) {
|
||||
var _ref, _ref1;
|
||||
if (res) {
|
||||
return _this._exit((_ref = res.stack) != null ? _ref : res.toString(), (_ref1 = res.exitCode) != null ? _ref1 : code);
|
||||
} else {
|
||||
return _this._exit();
|
||||
}
|
||||
};
|
||||
};
|
||||
Q.when(this["do"](argv), cb(0), cb(1)).done();
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Convenient function to run command from tests.
|
||||
@param {Array} argv
|
||||
@returns {Q.Promise}
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype["do"] = function(argv) {
|
||||
return this._do(this._parseArr(argv || []));
|
||||
};
|
||||
|
||||
/**
|
||||
Invoke specified (or current) command using provided
|
||||
options and arguments.
|
||||
@param {String|Array} cmds subcommand to invoke (optional)
|
||||
@param {Object} opts command options (optional)
|
||||
@param {Object} args command arguments (optional)
|
||||
@returns {Q.Promise}
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.invoke = function(cmds, opts, args) {
|
||||
var _this = this;
|
||||
if (cmds == null) {
|
||||
cmds = [];
|
||||
}
|
||||
if (opts == null) {
|
||||
opts = {};
|
||||
}
|
||||
if (args == null) {
|
||||
args = {};
|
||||
}
|
||||
if (typeof cmds === 'string') {
|
||||
cmds = cmds.split(' ');
|
||||
}
|
||||
if (arguments.length < 3) {
|
||||
if (!Array.isArray(cmds)) {
|
||||
args = opts;
|
||||
opts = cmds;
|
||||
cmds = [];
|
||||
}
|
||||
}
|
||||
return Q.when(this._parseCmd(cmds), function(p) {
|
||||
if (p.argv.length) {
|
||||
return _this.reject("Unknown command: " + cmds.join(' '));
|
||||
}
|
||||
return Q.all([_this._processParams(opts, _this._opts), _this._processParams(args, _this._args)]).spread(function(opts, args) {
|
||||
return _this._do({
|
||||
cmd: p.cmd,
|
||||
opts: opts,
|
||||
args: args
|
||||
}).fail(function(res) {
|
||||
if (res && res.exitCode === 0) {
|
||||
return res.toString();
|
||||
} else {
|
||||
return _this.reject(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Return reject of actions results promise with error code.
|
||||
Use in .act() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.reject = function(reason) {
|
||||
return Q.reject(reason);
|
||||
};
|
||||
|
||||
/**
|
||||
Finish chain for current subcommand and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
*/
|
||||
|
||||
|
||||
Cmd.prototype.end = function() {
|
||||
return this._cmd;
|
||||
};
|
||||
|
||||
return Cmd;
|
||||
|
||||
})();
|
||||
25
build/node_modules/coa/lib/color.js
generated
vendored
Normal file
25
build/node_modules/coa/lib/color.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
var colors;
|
||||
|
||||
colors = {
|
||||
black: '30',
|
||||
dgray: '1;30',
|
||||
red: '31',
|
||||
lred: '1;31',
|
||||
green: '32',
|
||||
lgreen: '1;32',
|
||||
brown: '33',
|
||||
yellow: '1;33',
|
||||
blue: '34',
|
||||
lblue: '1;34',
|
||||
purple: '35',
|
||||
lpurple: '1;35',
|
||||
cyan: '36',
|
||||
lcyan: '1;36',
|
||||
lgray: '37',
|
||||
white: '1;37'
|
||||
};
|
||||
|
||||
exports.Color = function(c, str) {
|
||||
return ['\x1B[', colors[c], 'm', str, '\x1B[m'].join('');
|
||||
};
|
||||
134
build/node_modules/coa/lib/completion.js
generated
vendored
Normal file
134
build/node_modules/coa/lib/completion.js
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
/**
|
||||
Most of the code adopted from the npm package shell completion code.
|
||||
See https://github.com/isaacs/npm/blob/master/lib/completion.js
|
||||
*/
|
||||
|
||||
var Q, complete, dumpScript, escape, getOpts, unescape;
|
||||
|
||||
Q = require('q');
|
||||
|
||||
escape = require('./shell').escape;
|
||||
|
||||
unescape = require('./shell').unescape;
|
||||
|
||||
module.exports = function() {
|
||||
return this.title('Shell completion').helpful().arg().name('raw').title('Completion words').arr().end().act(function(opts, args) {
|
||||
var argv, cmd, e, _ref;
|
||||
if (process.platform === 'win32') {
|
||||
e = new Error('shell completion not supported on windows');
|
||||
e.code = 'ENOTSUP';
|
||||
e.errno = require('constants').ENOTSUP;
|
||||
return this.reject(e);
|
||||
}
|
||||
if ((process.env.COMP_CWORD == null) || (process.env.COMP_LINE == null) || (process.env.COMP_POINT == null)) {
|
||||
return dumpScript(this._cmd._name);
|
||||
}
|
||||
console.error('COMP_LINE: %s', process.env.COMP_LINE);
|
||||
console.error('COMP_CWORD: %s', process.env.COMP_CWORD);
|
||||
console.error('COMP_POINT: %s', process.env.COMP_POINT);
|
||||
console.error('args: %j', args.raw);
|
||||
opts = getOpts(args.raw);
|
||||
_ref = this._cmd._parseCmd(opts.partialWords), cmd = _ref.cmd, argv = _ref.argv;
|
||||
return Q.when(complete(cmd, opts), function(compls) {
|
||||
console.error('filtered: %j', compls);
|
||||
return console.log(compls.map(escape).join('\n'));
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
dumpScript = function(name) {
|
||||
var defer, fs, path;
|
||||
fs = require('fs');
|
||||
path = require('path');
|
||||
defer = Q.defer();
|
||||
fs.readFile(path.resolve(__dirname, 'completion.sh'), 'utf8', function(err, d) {
|
||||
var onError;
|
||||
if (err) {
|
||||
return defer.reject(err);
|
||||
}
|
||||
d = d.replace(/{{cmd}}/g, path.basename(name)).replace(/^\#\!.*?\n/, '');
|
||||
onError = function(err) {
|
||||
if (err.errno === require('constants').EPIPE) {
|
||||
process.stdout.removeListener('error', onError);
|
||||
return defer.resolve();
|
||||
} else {
|
||||
return defer.reject(err);
|
||||
}
|
||||
};
|
||||
process.stdout.on('error', onError);
|
||||
return process.stdout.write(d, function() {
|
||||
return defer.resolve();
|
||||
});
|
||||
});
|
||||
return defer.promise;
|
||||
};
|
||||
|
||||
getOpts = function(argv) {
|
||||
var i, line, partialLine, partialWord, partialWords, point, w, word, words;
|
||||
line = process.env.COMP_LINE;
|
||||
w = +process.env.COMP_CWORD;
|
||||
point = +process.env.COMP_POINT;
|
||||
words = argv.map(unescape);
|
||||
word = words[w];
|
||||
partialLine = line.substr(0, point);
|
||||
partialWords = words.slice(0, w);
|
||||
partialWord = argv[w] || '';
|
||||
i = partialWord.length;
|
||||
while (partialWord.substr(0, i) !== partialLine.substr(-1 * i) && i > 0) {
|
||||
i--;
|
||||
}
|
||||
partialWord = unescape(partialWord.substr(0, i));
|
||||
if (partialWord) {
|
||||
partialWords.push(partialWord);
|
||||
}
|
||||
return {
|
||||
line: line,
|
||||
w: w,
|
||||
point: point,
|
||||
words: words,
|
||||
word: word,
|
||||
partialLine: partialLine,
|
||||
partialWords: partialWords,
|
||||
partialWord: partialWord
|
||||
};
|
||||
};
|
||||
|
||||
complete = function(cmd, opts) {
|
||||
var compls, m, o, opt, optPrefix, optWord;
|
||||
compls = [];
|
||||
if (opts.partialWord.indexOf('-')) {
|
||||
compls = Object.keys(cmd._cmdsByName);
|
||||
} else {
|
||||
if (m = opts.partialWord.match(/^(--\w[\w-_]*)=(.*)$/)) {
|
||||
optWord = m[1];
|
||||
optPrefix = optWord + '=';
|
||||
} else {
|
||||
compls = Object.keys(cmd._optsByKey);
|
||||
}
|
||||
}
|
||||
if (!(o = opts.partialWords[opts.w - 1]).indexOf('-')) {
|
||||
optWord = o;
|
||||
}
|
||||
if (optWord && (opt = cmd._optsByKey[optWord])) {
|
||||
if (!opt._flag && opt._comp) {
|
||||
compls = Q.join(compls, Q.when(opt._comp(opts), function(c, o) {
|
||||
return c.concat(o.map(function(v) {
|
||||
return (optPrefix || '') + v;
|
||||
}));
|
||||
}));
|
||||
}
|
||||
}
|
||||
if (cmd._comp) {
|
||||
compls = Q.join(compls, Q.when(cmd._comp(opts)), function(c, o) {
|
||||
return c.concat(o);
|
||||
});
|
||||
}
|
||||
return Q.when(compls, function(compls) {
|
||||
console.error('partialWord: %s', opts.partialWord);
|
||||
console.error('compls: %j', compls);
|
||||
return compls.filter(function(c) {
|
||||
return c.indexOf(opts.partialWord) === 0;
|
||||
});
|
||||
});
|
||||
};
|
||||
43
build/node_modules/coa/lib/completion.sh
generated
vendored
Normal file
43
build/node_modules/coa/lib/completion.sh
generated
vendored
Normal file
@@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bash
|
||||
###-begin-{{cmd}}-completion-###
|
||||
#
|
||||
# {{cmd}} command completion script
|
||||
#
|
||||
# Installation: {{cmd}} completion >> ~/.bashrc (or ~/.zshrc)
|
||||
# Or, maybe: {{cmd}} completion > /usr/local/etc/bash_completion.d/{{cmd}}
|
||||
#
|
||||
|
||||
COMP_WORDBREAKS=${COMP_WORDBREAKS/=/}
|
||||
COMP_WORDBREAKS=${COMP_WORDBREAKS/@/}
|
||||
export COMP_WORDBREAKS
|
||||
|
||||
if complete &>/dev/null; then
|
||||
_{{cmd}}_completion () {
|
||||
local si="$IFS"
|
||||
IFS=$'\n' COMPREPLY=($(COMP_CWORD="$COMP_CWORD" \
|
||||
COMP_LINE="$COMP_LINE" \
|
||||
COMP_POINT="$COMP_POINT" \
|
||||
{{cmd}} completion -- "${COMP_WORDS[@]}" \
|
||||
2>/dev/null)) || return $?
|
||||
IFS="$si"
|
||||
}
|
||||
complete -F _{{cmd}}_completion {{cmd}}
|
||||
elif compctl &>/dev/null; then
|
||||
_{{cmd}}_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" \
|
||||
{{cmd}} completion -- "${words[@]}" \
|
||||
2>/dev/null)) || return $?
|
||||
IFS="$si"
|
||||
}
|
||||
compctl -K _{{cmd}}_completion {{cmd}}
|
||||
fi
|
||||
###-end-{{cmd}}-completion-###
|
||||
10
build/node_modules/coa/lib/index.js
generated
vendored
Normal file
10
build/node_modules/coa/lib/index.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
exports.Cmd = require('./cmd').Cmd;
|
||||
|
||||
exports.Opt = require('./cmd').Opt;
|
||||
|
||||
exports.Arg = require('./cmd').Arg;
|
||||
|
||||
exports.shell = require('./shell');
|
||||
|
||||
exports.require = require;
|
||||
338
build/node_modules/coa/lib/opt.js
generated
vendored
Normal file
338
build/node_modules/coa/lib/opt.js
generated
vendored
Normal file
@@ -0,0 +1,338 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
var Cmd, Color, Opt, Q, fs;
|
||||
|
||||
fs = require('fs');
|
||||
|
||||
Q = require('q');
|
||||
|
||||
Color = require('./color').Color;
|
||||
|
||||
Cmd = require('./cmd').Cmd;
|
||||
|
||||
/**
|
||||
Option
|
||||
|
||||
Named entity. Options may have short and long keys for use from command line.
|
||||
@namespace
|
||||
@class Presents option
|
||||
*/
|
||||
|
||||
|
||||
exports.Opt = Opt = (function() {
|
||||
/**
|
||||
@constructs
|
||||
@param {COA.Cmd} cmd parent command
|
||||
*/
|
||||
|
||||
function Opt(_cmd) {
|
||||
this._cmd = _cmd;
|
||||
this._cmd._opts.push(this);
|
||||
}
|
||||
|
||||
/**
|
||||
Set a canonical option identifier to be used anywhere in the API.
|
||||
@param {String} _name option name
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.name = function(_name) {
|
||||
this._name = _name;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a long description for option to be used anywhere in text messages.
|
||||
@param {String} _title option title
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.title = Cmd.prototype.title;
|
||||
|
||||
/**
|
||||
Set a short key for option to be used with one hyphen from command line.
|
||||
@param {String} _short
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.short = function(_short) {
|
||||
this._short = _short;
|
||||
return this._cmd._optsByKey['-' + _short] = this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a short key for option to be used with double hyphens from command line.
|
||||
@param {String} _long
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.long = function(_long) {
|
||||
this._long = _long;
|
||||
return this._cmd._optsByKey['--' + _long] = this;
|
||||
};
|
||||
|
||||
/**
|
||||
Make an option boolean, i.e. option without value.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.flag = function() {
|
||||
this._flag = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Makes an option accepts multiple values.
|
||||
Otherwise, the value will be used by the latter passed.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.arr = function() {
|
||||
this._arr = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Makes an option required.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.req = function() {
|
||||
this._req = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Makes an option to act as a command,
|
||||
i.e. program will exit just after option action.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.only = function() {
|
||||
this._only = true;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a validation (or value) function for option.
|
||||
Value from command line passes through before becoming available from API.
|
||||
Using for validation and convertion simple types to any values.
|
||||
@param {Function} _val validating function,
|
||||
invoked in the context of option instance
|
||||
and has one parameter with value from command line
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.val = function(_val) {
|
||||
this._val = _val;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set a default value for option.
|
||||
Default value passed through validation function as ordinary value.
|
||||
@param {Object} _def
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.def = function(_def) {
|
||||
this._def = _def;
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Make option value inputting stream.
|
||||
It's add useful validation and shortcut for STDIN.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.input = function() {
|
||||
process.stdin.pause();
|
||||
return this.def(process.stdin).val(function(v) {
|
||||
var s;
|
||||
if (typeof v === 'string') {
|
||||
if (v === '-') {
|
||||
return process.stdin;
|
||||
} else {
|
||||
s = fs.createReadStream(v, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
s.pause();
|
||||
return s;
|
||||
}
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Make option value outputing stream.
|
||||
It's add useful validation and shortcut for STDOUT.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.output = function() {
|
||||
return this.def(process.stdout).val(function(v) {
|
||||
if (typeof v === 'string') {
|
||||
if (v === '-') {
|
||||
return process.stdout;
|
||||
} else {
|
||||
return fs.createWriteStream(v, {
|
||||
encoding: 'utf8'
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
Add action for current option command.
|
||||
This action is performed if the current option
|
||||
is present in parsed options (with any value).
|
||||
@param {Function} act action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:
|
||||
- {Object} opts parsed options
|
||||
- {Array} args parsed arguments
|
||||
- {Object} res actions result accumulator
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.act = function(act) {
|
||||
var name, opt;
|
||||
opt = this;
|
||||
name = this._name;
|
||||
this._cmd.act(function(opts) {
|
||||
var res,
|
||||
_this = this;
|
||||
if (name in opts) {
|
||||
res = act.apply(this, arguments);
|
||||
if (opt._only) {
|
||||
return Q.when(res, function(res) {
|
||||
return _this.reject({
|
||||
toString: function() {
|
||||
return res.toString();
|
||||
},
|
||||
exitCode: 0
|
||||
});
|
||||
});
|
||||
} else {
|
||||
return res;
|
||||
}
|
||||
}
|
||||
});
|
||||
return this;
|
||||
};
|
||||
|
||||
/**
|
||||
Set custom additional completion for current option.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of option instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.comp = Cmd.prototype.comp;
|
||||
|
||||
Opt.prototype._saveVal = function(opts, val) {
|
||||
var _name;
|
||||
if (this._val) {
|
||||
val = this._val(val);
|
||||
}
|
||||
if (this._arr) {
|
||||
(opts[_name = this._name] || (opts[_name] = [])).push(val);
|
||||
} else {
|
||||
opts[this._name] = val;
|
||||
}
|
||||
return val;
|
||||
};
|
||||
|
||||
Opt.prototype._parse = function(argv, opts) {
|
||||
return this._saveVal(opts, this._flag ? true : argv.shift());
|
||||
};
|
||||
|
||||
Opt.prototype._checkParsed = function(opts, args) {
|
||||
return !opts.hasOwnProperty(this._name);
|
||||
};
|
||||
|
||||
Opt.prototype._usage = function() {
|
||||
var nameStr, res;
|
||||
res = [];
|
||||
nameStr = this._name.toUpperCase();
|
||||
if (this._short) {
|
||||
res.push('-', Color('lgreen', this._short));
|
||||
if (!this._flag) {
|
||||
res.push(' ' + nameStr);
|
||||
}
|
||||
res.push(', ');
|
||||
}
|
||||
if (this._long) {
|
||||
res.push('--', Color('green', this._long));
|
||||
if (!this._flag) {
|
||||
res.push('=' + nameStr);
|
||||
}
|
||||
}
|
||||
res.push(' : ', this._title);
|
||||
if (this._req) {
|
||||
res.push(' ', Color('lred', '(required)'));
|
||||
}
|
||||
return res.join('');
|
||||
};
|
||||
|
||||
Opt.prototype._requiredText = function() {
|
||||
return 'Missing required option:\n ' + this._usage();
|
||||
};
|
||||
|
||||
/**
|
||||
Return rejected promise with error code.
|
||||
Use in .val() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.reject = Cmd.prototype.reject;
|
||||
|
||||
/**
|
||||
Finish chain for current option and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.end = Cmd.prototype.end;
|
||||
|
||||
/**
|
||||
Apply function with arguments in context of option instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
*/
|
||||
|
||||
|
||||
Opt.prototype.apply = Cmd.prototype.apply;
|
||||
|
||||
return Opt;
|
||||
|
||||
})();
|
||||
14
build/node_modules/coa/lib/shell.js
generated
vendored
Normal file
14
build/node_modules/coa/lib/shell.js
generated
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
// Generated by CoffeeScript 1.6.3
|
||||
exports.unescape = function(w) {
|
||||
w = w.charAt(0) === '"' ? w.replace(/^"|([^\\])"$/g, '$1') : w.replace(/\\ /g, ' ');
|
||||
return w.replace(/\\("|'|\$|`|\\)/g, '$1');
|
||||
};
|
||||
|
||||
exports.escape = function(w) {
|
||||
w = w.replace(/(["'$`\\])/g, '\\$1');
|
||||
if (w.match(/\s+/)) {
|
||||
return '"' + w + '"';
|
||||
} else {
|
||||
return w;
|
||||
}
|
||||
};
|
||||
91
build/node_modules/coa/package.json
generated
vendored
Normal file
91
build/node_modules/coa/package.json
generated
vendored
Normal file
@@ -0,0 +1,91 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"coa@1.0.4",
|
||||
"/Users/asciidisco/Desktop/asciidisco.com/build"
|
||||
]
|
||||
],
|
||||
"_from": "coa@1.0.4",
|
||||
"_id": "coa@1.0.4",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-qe8VNmDWqGqL3sAomlxoTSF0Mv0=",
|
||||
"_location": "/coa",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "coa@1.0.4",
|
||||
"name": "coa",
|
||||
"escapedName": "coa",
|
||||
"rawSpec": "1.0.4",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "1.0.4"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/svgo"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/coa/-/coa-1.0.4.tgz",
|
||||
"_spec": "1.0.4",
|
||||
"_where": "/Users/asciidisco/Desktop/asciidisco.com/build",
|
||||
"author": {
|
||||
"name": "Sergey Berezhnoy",
|
||||
"email": "veged@ya.ru",
|
||||
"url": "http://github.com/veged"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/veged/coa/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Sergey Belov",
|
||||
"email": "peimei@ya.ru",
|
||||
"url": "http://github.com/arikon"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"q": "^1.1.2"
|
||||
},
|
||||
"description": "Command-Option-Argument: Yet another parser for command line options.",
|
||||
"devDependencies": {
|
||||
"chai": "~1.7.2",
|
||||
"coffee-script": "~1.6.3",
|
||||
"istanbul": "~0.1.40",
|
||||
"mocha": "~1.21.4",
|
||||
"mocha-istanbul": "*"
|
||||
},
|
||||
"directories": {
|
||||
"lib": "./lib"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.8.0"
|
||||
},
|
||||
"homepage": "http://github.com/veged/coa",
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT"
|
||||
}
|
||||
],
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Sergey Berezhnoy",
|
||||
"email": "veged@ya.ru",
|
||||
"url": "http://github.com/veged"
|
||||
},
|
||||
{
|
||||
"name": "Sergey Belov",
|
||||
"email": "peimei@ya.ru",
|
||||
"url": "http://github.com/arikon"
|
||||
}
|
||||
],
|
||||
"name": "coa",
|
||||
"optionalDependencies": {},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/veged/coa.git"
|
||||
},
|
||||
"scripts": {
|
||||
"coverage": "make coverage",
|
||||
"test": "make test"
|
||||
},
|
||||
"version": "1.0.4"
|
||||
}
|
||||
17
build/node_modules/coa/qq.js
generated
vendored
Normal file
17
build/node_modules/coa/qq.js
generated
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
const run = require('./test/util').run;
|
||||
|
||||
// run(cmd => cmd.arg().name('qwe').end().arg().name('zxc').end().act(function(opts, args) { console.log({opts, args}); }), ['qwe', 'zxc']) // cmd and args
|
||||
// .then(res => {
|
||||
// // code
|
||||
// // stdout
|
||||
// // stderr
|
||||
// console.log(res);
|
||||
// });
|
||||
|
||||
run(cmd => cmd.opt().name('version').short('v').only().flag().act((opts) => { return 'aasd'; }), ['-v']) // cmd and args
|
||||
.then(res => {
|
||||
// code
|
||||
// stdout
|
||||
// stderr
|
||||
console.log(res);
|
||||
});
|
||||
130
build/node_modules/coa/src/arg.coffee
generated
vendored
Normal file
130
build/node_modules/coa/src/arg.coffee
generated
vendored
Normal file
@@ -0,0 +1,130 @@
|
||||
Color = require('./color').Color
|
||||
Cmd = require('./cmd').Cmd
|
||||
Opt = require('./opt').Opt
|
||||
|
||||
###*
|
||||
Argument
|
||||
|
||||
Unnamed entity. From command line arguments passed as list of unnamed values.
|
||||
@namespace
|
||||
@class Presents argument
|
||||
###
|
||||
exports.Arg = class Arg
|
||||
|
||||
###*
|
||||
@constructs
|
||||
@param {COA.Cmd} cmd parent command
|
||||
###
|
||||
constructor: (@_cmd) -> @_cmd._args.push @
|
||||
|
||||
###*
|
||||
Set a canonical argument identifier to be used anywhere in text messages.
|
||||
@param {String} _name argument name
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
name: Opt::name
|
||||
|
||||
###*
|
||||
Set a long description for argument to be used anywhere in text messages.
|
||||
@param {String} _title argument title
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
title: Cmd::title
|
||||
|
||||
###*
|
||||
Makes an argument accepts multiple values.
|
||||
Otherwise, the value will be used by the latter passed.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
arr: Opt::arr
|
||||
|
||||
###*
|
||||
Makes an argument required.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
req: Opt::req
|
||||
|
||||
###*
|
||||
Set a validation (or value) function for argument.
|
||||
Value from command line passes through before becoming available from API.
|
||||
Using for validation and convertion simple types to any values.
|
||||
@param {Function} _val validating function,
|
||||
invoked in the context of argument instance
|
||||
and has one parameter with value from command line
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
val: Opt::val
|
||||
|
||||
###*
|
||||
Set a default value for argument.
|
||||
Default value passed through validation function as ordinary value.
|
||||
@param {Object} _def
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
def: Opt::def
|
||||
|
||||
###*
|
||||
Set custom additional completion for current argument.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of argument instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
comp: Cmd::comp
|
||||
|
||||
###*
|
||||
Make argument value inputting stream.
|
||||
It's add useful validation and shortcut for STDIN.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
input: Opt::input
|
||||
|
||||
###*
|
||||
Make argument value outputing stream.
|
||||
It's add useful validation and shortcut for STDOUT.
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
output: Opt::output
|
||||
|
||||
_parse: (arg, args) ->
|
||||
@_saveVal(args, arg)
|
||||
|
||||
_saveVal: Opt::_saveVal
|
||||
|
||||
_checkParsed: (opts, args) -> not args.hasOwnProperty(@_name)
|
||||
|
||||
_usage: ->
|
||||
res = []
|
||||
|
||||
res.push Color('lpurple', @_name.toUpperCase()), ' : ', @_title
|
||||
if @_req then res.push ' ', Color('lred', '(required)')
|
||||
|
||||
res.join ''
|
||||
|
||||
_requiredText: -> 'Missing required argument:\n ' + @_usage()
|
||||
|
||||
###*
|
||||
Return rejected promise with error code.
|
||||
Use in .val() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
###
|
||||
reject: Cmd::reject
|
||||
|
||||
###*
|
||||
Finish chain for current option and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
###
|
||||
end: Cmd::end
|
||||
|
||||
###*
|
||||
Apply function with arguments in context of arg instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Arg} this instance (for chainability)
|
||||
###
|
||||
apply: Cmd::apply
|
||||
456
build/node_modules/coa/src/cmd.coffee
generated
vendored
Normal file
456
build/node_modules/coa/src/cmd.coffee
generated
vendored
Normal file
@@ -0,0 +1,456 @@
|
||||
UTIL = require 'util'
|
||||
PATH = require 'path'
|
||||
Color = require('./color').Color
|
||||
Q = require('q')
|
||||
|
||||
#inspect = require('eyes').inspector { maxLength: 99999, stream: process.stderr }
|
||||
|
||||
###*
|
||||
Command
|
||||
|
||||
Top level entity. Commands may have options and arguments.
|
||||
@namespace
|
||||
@class Presents command
|
||||
###
|
||||
exports.Cmd = class Cmd
|
||||
|
||||
###*
|
||||
@constructs
|
||||
@param {COA.Cmd} [cmd] parent command
|
||||
###
|
||||
constructor: (cmd) ->
|
||||
if this not instanceof Cmd
|
||||
return new Cmd cmd
|
||||
|
||||
@_parent cmd
|
||||
|
||||
@_cmds = []
|
||||
@_cmdsByName = {}
|
||||
|
||||
@_opts = []
|
||||
@_optsByKey = {}
|
||||
|
||||
@_args = []
|
||||
|
||||
@_ext = false
|
||||
|
||||
@get: (propertyName, func) ->
|
||||
Object.defineProperty @::, propertyName,
|
||||
configurable: true
|
||||
enumerable: true
|
||||
get: func
|
||||
|
||||
###*
|
||||
Returns object containing all its subcommands as methods
|
||||
to use from other programs.
|
||||
@returns {Object}
|
||||
###
|
||||
@get 'api', () ->
|
||||
if not @_api
|
||||
@_api = => @invoke.apply @, arguments
|
||||
for c of @_cmdsByName
|
||||
do (c) =>
|
||||
@_api[c] = @_cmdsByName[c].api
|
||||
@_api
|
||||
|
||||
_parent: (cmd) ->
|
||||
@_cmd = cmd or this
|
||||
if cmd
|
||||
cmd._cmds.push @
|
||||
if @_name then @_cmd._cmdsByName[@_name] = @
|
||||
@
|
||||
|
||||
###*
|
||||
Set a canonical command identifier to be used anywhere in the API.
|
||||
@param {String} _name command name
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
name: (@_name) ->
|
||||
if @_cmd isnt @ then @_cmd._cmdsByName[_name] = @
|
||||
@
|
||||
|
||||
###*
|
||||
Set a long description for command to be used anywhere in text messages.
|
||||
@param {String} _title command title
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
title: (@_title) -> @
|
||||
|
||||
###*
|
||||
Create new or add existing subcommand for current command.
|
||||
@param {COA.Cmd} [cmd] existing command instance
|
||||
@returns {COA.Cmd} new subcommand instance
|
||||
###
|
||||
cmd: (cmd) ->
|
||||
if cmd then cmd._parent @
|
||||
else new Cmd @
|
||||
|
||||
###*
|
||||
Create option for current command.
|
||||
@returns {COA.Opt} new option instance
|
||||
###
|
||||
opt: -> new (require('./opt').Opt) @
|
||||
|
||||
###*
|
||||
Create argument for current command.
|
||||
@returns {COA.Opt} new argument instance
|
||||
###
|
||||
arg: -> new (require('./arg').Arg) @
|
||||
|
||||
###*
|
||||
Add (or set) action for current command.
|
||||
@param {Function} act action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:
|
||||
- {Object} opts parsed options
|
||||
- {Array} args parsed arguments
|
||||
- {Object} res actions result accumulator
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.
|
||||
@param {Boolean} [force=false] flag for set action instead add to existings
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
act: (act, force) ->
|
||||
return @ unless act
|
||||
|
||||
if not force and @_act
|
||||
@_act.push act
|
||||
else
|
||||
@_act = [act]
|
||||
|
||||
@
|
||||
|
||||
###*
|
||||
Set custom additional completion for current command.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of command instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
comp: (@_comp) -> @
|
||||
|
||||
###*
|
||||
Apply function with arguments in context of command instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
apply: (fn, args...) ->
|
||||
fn.apply this, args
|
||||
@
|
||||
|
||||
###*
|
||||
Make command "helpful", i.e. add -h --help flags for print usage.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
helpful: ->
|
||||
@opt()
|
||||
.name('help').title('Help')
|
||||
.short('h').long('help')
|
||||
.flag()
|
||||
.only()
|
||||
.act ->
|
||||
return @usage()
|
||||
.end()
|
||||
|
||||
###*
|
||||
Adds shell completion to command, adds "completion" subcommand,
|
||||
that makes all the magic.
|
||||
Must be called only on root command.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
completable: ->
|
||||
@cmd()
|
||||
.name('completion')
|
||||
.apply(require './completion')
|
||||
.end()
|
||||
|
||||
###*
|
||||
Allow command to be extendable by external node.js modules.
|
||||
@param {String} [pattern] Pattern of node.js module to find subcommands at.
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
extendable: (pattern) ->
|
||||
@_ext = pattern or true
|
||||
@
|
||||
|
||||
_exit: (msg, code) ->
|
||||
process.once 'exit', ->
|
||||
if msg then console.error msg
|
||||
process.exit code or 0
|
||||
|
||||
###*
|
||||
Build full usage text for current command instance.
|
||||
@returns {String} usage text
|
||||
###
|
||||
usage: ->
|
||||
res = []
|
||||
|
||||
if @_title then res.push @_fullTitle()
|
||||
|
||||
res.push('', 'Usage:')
|
||||
|
||||
if @_cmds.length then res.push(['', '',
|
||||
Color('lred', @_fullName()),
|
||||
Color('lblue', 'COMMAND'),
|
||||
Color('lgreen', '[OPTIONS]'),
|
||||
Color('lpurple', '[ARGS]')].join ' ')
|
||||
|
||||
if @_opts.length + @_args.length then res.push(['', '',
|
||||
Color('lred', @_fullName()),
|
||||
Color('lgreen', '[OPTIONS]'),
|
||||
Color('lpurple', '[ARGS]')].join ' ')
|
||||
|
||||
res.push(
|
||||
@_usages(@_cmds, 'Commands'),
|
||||
@_usages(@_opts, 'Options'),
|
||||
@_usages(@_args, 'Arguments'))
|
||||
|
||||
res.join '\n'
|
||||
|
||||
_usage: ->
|
||||
Color('lblue', @_name) + ' : ' + @_title
|
||||
|
||||
_usages: (os, title) ->
|
||||
unless os.length then return
|
||||
res = ['', title + ':']
|
||||
for o in os
|
||||
res.push ' ' + o._usage()
|
||||
res.join '\n'
|
||||
|
||||
_fullTitle: ->
|
||||
(if @_cmd is this then '' else @_cmd._fullTitle() + '\n') + @_title
|
||||
|
||||
_fullName: ->
|
||||
(if this._cmd is this then '' else @_cmd._fullName() + ' ') + PATH.basename(@_name)
|
||||
|
||||
_ejectOpt: (opts, opt) ->
|
||||
if (pos = opts.indexOf(opt)) >= 0
|
||||
if opts[pos]._arr
|
||||
opts[pos]
|
||||
else
|
||||
opts.splice(pos, 1)[0]
|
||||
|
||||
_checkRequired: (opts, args) ->
|
||||
if not (@_opts.filter (o) -> o._only and o._name of opts).length
|
||||
all = @_opts.concat @_args
|
||||
while i = all.shift()
|
||||
if i._req and i._checkParsed opts, args
|
||||
return @reject i._requiredText()
|
||||
|
||||
_parseCmd: (argv, unparsed = []) ->
|
||||
argv = argv.concat()
|
||||
optSeen = false
|
||||
while i = argv.shift()
|
||||
if not i.indexOf '-'
|
||||
optSeen = true
|
||||
if not optSeen and /^\w[\w-_]*$/.test(i)
|
||||
cmd = @_cmdsByName[i]
|
||||
|
||||
if not cmd and @_ext
|
||||
# construct package name to require
|
||||
if typeof @_ext is 'string'
|
||||
if ~@_ext.indexOf('%s')
|
||||
# use formatted string
|
||||
pkg = UTIL.format(@_ext, i)
|
||||
else
|
||||
# just append subcommand name to the prefix
|
||||
pkg = @_ext + i
|
||||
else if @_ext is true
|
||||
# use default scheme: <command>-<subcommand>-<subcommand> and so on
|
||||
pkg = i
|
||||
c = @
|
||||
loop
|
||||
pkg = c._name + '-' + pkg
|
||||
if c._cmd is c then break
|
||||
c = c._cmd
|
||||
|
||||
try
|
||||
cmdDesc = require(pkg)
|
||||
catch e
|
||||
|
||||
if cmdDesc
|
||||
if typeof cmdDesc == 'function'
|
||||
# set create subcommand, set its name and apply imported function
|
||||
@cmd()
|
||||
.name(i)
|
||||
.apply(cmdDesc)
|
||||
.end()
|
||||
else if typeof cmdDesc == 'object'
|
||||
# register subcommand
|
||||
@cmd(cmdDesc)
|
||||
# set command name
|
||||
cmdDesc.name(i)
|
||||
else
|
||||
throw new Error 'Error: Unsupported command declaration type, ' +
|
||||
'should be function or COA.Cmd() object'
|
||||
cmd = @_cmdsByName[i]
|
||||
if cmd
|
||||
return cmd._parseCmd argv, unparsed
|
||||
|
||||
unparsed.push i
|
||||
|
||||
{ cmd: @, argv: unparsed }
|
||||
|
||||
_parseOptsAndArgs: (argv) ->
|
||||
opts = {}
|
||||
args = {}
|
||||
|
||||
nonParsedOpts = @_opts.concat()
|
||||
nonParsedArgs = @_args.concat()
|
||||
|
||||
while i = argv.shift()
|
||||
# opt
|
||||
if i isnt '--' and not i.indexOf '-'
|
||||
|
||||
if m = i.match /^(--\w[\w-_]*)=(.*)$/
|
||||
i = m[1]
|
||||
|
||||
# suppress 'unknown argument' error for flag options with values
|
||||
if not @_optsByKey[i]._flag
|
||||
argv.unshift m[2]
|
||||
|
||||
if opt = @_ejectOpt nonParsedOpts, @_optsByKey[i]
|
||||
if Q.isRejected(res = opt._parse argv, opts)
|
||||
return res
|
||||
else
|
||||
return @reject "Unknown option: #{ i }"
|
||||
|
||||
# arg
|
||||
else
|
||||
if i is '--'
|
||||
i = argv.splice(0)
|
||||
|
||||
i = if Array.isArray(i) then i else [i]
|
||||
|
||||
while a = i.shift()
|
||||
if arg = nonParsedArgs.shift()
|
||||
if arg._arr then nonParsedArgs.unshift arg
|
||||
if Q.isRejected(res = arg._parse a, args)
|
||||
return res
|
||||
else
|
||||
return @reject "Unknown argument: #{ a }"
|
||||
|
||||
# set defaults
|
||||
{
|
||||
opts: @_setDefaults(opts, nonParsedOpts),
|
||||
args: @_setDefaults(args, nonParsedArgs)
|
||||
}
|
||||
|
||||
_setDefaults: (params, desc) ->
|
||||
for i in desc
|
||||
if i._name not of params and '_def' of i
|
||||
i._saveVal params, i._def
|
||||
params
|
||||
|
||||
_processParams: (params, desc) ->
|
||||
notExists = []
|
||||
for i in desc
|
||||
n = i._name
|
||||
if n not of params
|
||||
notExists.push i
|
||||
continue
|
||||
|
||||
vals = params[n]
|
||||
delete params[n]
|
||||
if not Array.isArray vals
|
||||
vals = [vals]
|
||||
|
||||
for v in vals
|
||||
if Q.isRejected(res = i._saveVal(params, v))
|
||||
return res
|
||||
|
||||
# set defaults
|
||||
@_setDefaults params, notExists
|
||||
|
||||
_parseArr: (argv) ->
|
||||
Q.when @_parseCmd(argv), (p) ->
|
||||
Q.when p.cmd._parseOptsAndArgs(p.argv), (r) ->
|
||||
{ cmd: p.cmd, opts: r.opts, args: r.args }
|
||||
|
||||
_do: (input) ->
|
||||
Q.when input, (input) =>
|
||||
cmd = input.cmd
|
||||
[@_checkRequired].concat(cmd._act or []).reduce(
|
||||
(res, act) ->
|
||||
Q.when res, (res) ->
|
||||
act.call(
|
||||
cmd
|
||||
input.opts
|
||||
input.args
|
||||
res)
|
||||
undefined
|
||||
)
|
||||
|
||||
###*
|
||||
Parse arguments from simple format like NodeJS process.argv
|
||||
and run ahead current program, i.e. call process.exit when all actions done.
|
||||
@param {Array} argv
|
||||
@returns {COA.Cmd} this instance (for chainability)
|
||||
###
|
||||
run: (argv = process.argv.slice(2)) ->
|
||||
cb = (code) => (res) =>
|
||||
if res
|
||||
@_exit res.stack ? res.toString(), res.exitCode ? code
|
||||
else
|
||||
@_exit()
|
||||
Q.when(@do(argv), cb(0), cb(1)).done()
|
||||
@
|
||||
|
||||
###*
|
||||
Convenient function to run command from tests.
|
||||
@param {Array} argv
|
||||
@returns {Q.Promise}
|
||||
###
|
||||
do: (argv) ->
|
||||
@_do(@_parseArr argv || [])
|
||||
|
||||
###*
|
||||
Invoke specified (or current) command using provided
|
||||
options and arguments.
|
||||
@param {String|Array} cmds subcommand to invoke (optional)
|
||||
@param {Object} opts command options (optional)
|
||||
@param {Object} args command arguments (optional)
|
||||
@returns {Q.Promise}
|
||||
###
|
||||
invoke: (cmds = [], opts = {}, args = {}) ->
|
||||
if typeof cmds == 'string'
|
||||
cmds = cmds.split(' ')
|
||||
|
||||
if arguments.length < 3
|
||||
if not Array.isArray cmds
|
||||
args = opts
|
||||
opts = cmds
|
||||
cmds = []
|
||||
|
||||
Q.when @_parseCmd(cmds), (p) =>
|
||||
if p.argv.length
|
||||
return @reject "Unknown command: " + cmds.join ' '
|
||||
|
||||
Q.all([@_processParams(opts, @_opts), @_processParams(args, @_args)])
|
||||
.spread (opts, args) =>
|
||||
@_do({ cmd: p.cmd, opts: opts, args: args })
|
||||
# catch fails from .only() options
|
||||
.fail (res) =>
|
||||
if res and res.exitCode is 0
|
||||
res.toString()
|
||||
else
|
||||
@reject(res)
|
||||
|
||||
###*
|
||||
Return reject of actions results promise with error code.
|
||||
Use in .act() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
###
|
||||
reject: (reason) -> Q.reject(reason)
|
||||
|
||||
###*
|
||||
Finish chain for current subcommand and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
###
|
||||
end: -> @_cmd
|
||||
25
build/node_modules/coa/src/color.coffee
generated
vendored
Normal file
25
build/node_modules/coa/src/color.coffee
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
colors =
|
||||
black: '30'
|
||||
dgray: '1;30'
|
||||
red: '31'
|
||||
lred: '1;31'
|
||||
green: '32'
|
||||
lgreen: '1;32'
|
||||
brown: '33'
|
||||
yellow: '1;33'
|
||||
blue: '34'
|
||||
lblue: '1;34'
|
||||
purple: '35'
|
||||
lpurple: '1;35'
|
||||
cyan: '36'
|
||||
lcyan: '1;36'
|
||||
lgray: '37'
|
||||
white: '1;37'
|
||||
|
||||
exports.Color = (c, str) ->
|
||||
# Use \x1B instead of \033 because of CoffeeScript 1.3.x compilation error
|
||||
[
|
||||
'\x1B[', colors[c], 'm'
|
||||
str
|
||||
'\x1B[m'
|
||||
].join ''
|
||||
156
build/node_modules/coa/src/completion.coffee
generated
vendored
Normal file
156
build/node_modules/coa/src/completion.coffee
generated
vendored
Normal file
@@ -0,0 +1,156 @@
|
||||
###*
|
||||
Most of the code adopted from the npm package shell completion code.
|
||||
See https://github.com/isaacs/npm/blob/master/lib/completion.js
|
||||
###
|
||||
|
||||
Q = require 'q'
|
||||
escape = require('./shell').escape
|
||||
unescape = require('./shell').unescape
|
||||
|
||||
module.exports = ->
|
||||
@title('Shell completion')
|
||||
.helpful()
|
||||
.arg()
|
||||
.name('raw')
|
||||
.title('Completion words')
|
||||
.arr()
|
||||
.end()
|
||||
.act (opts, args) ->
|
||||
if process.platform == 'win32'
|
||||
e = new Error 'shell completion not supported on windows'
|
||||
e.code = 'ENOTSUP'
|
||||
e.errno = require('constants').ENOTSUP
|
||||
return @reject(e)
|
||||
|
||||
# if the COMP_* isn't in the env, then just dump the script
|
||||
if !process.env.COMP_CWORD? or !process.env.COMP_LINE? or !process.env.COMP_POINT?
|
||||
return dumpScript(@_cmd._name)
|
||||
|
||||
console.error 'COMP_LINE: %s', process.env.COMP_LINE
|
||||
console.error 'COMP_CWORD: %s', process.env.COMP_CWORD
|
||||
console.error 'COMP_POINT: %s', process.env.COMP_POINT
|
||||
console.error 'args: %j', args.raw
|
||||
|
||||
# completion opts
|
||||
opts = getOpts args.raw
|
||||
|
||||
# cmd
|
||||
{ cmd, argv } = @_cmd._parseCmd opts.partialWords
|
||||
Q.when complete(cmd, opts), (compls) ->
|
||||
console.error 'filtered: %j', compls
|
||||
console.log compls.map(escape).join('\n')
|
||||
|
||||
|
||||
dumpScript = (name) ->
|
||||
fs = require 'fs'
|
||||
path = require 'path'
|
||||
defer = Q.defer()
|
||||
|
||||
fs.readFile path.resolve(__dirname, 'completion.sh'), 'utf8', (err, d) ->
|
||||
if err then return defer.reject err
|
||||
d = d.replace(/{{cmd}}/g, path.basename name).replace(/^\#\!.*?\n/, '')
|
||||
|
||||
onError = (err) ->
|
||||
# Darwin is a real dick sometimes.
|
||||
#
|
||||
# This is necessary because the "source" or "." program in
|
||||
# bash on OS X closes its file argument before reading
|
||||
# from it, meaning that you get exactly 1 write, which will
|
||||
# work most of the time, and will always raise an EPIPE.
|
||||
#
|
||||
# Really, one should not be tossing away EPIPE errors, or any
|
||||
# errors, so casually. But, without this, `. <(cmd completion)`
|
||||
# can never ever work on OS X.
|
||||
if err.errno == require('constants').EPIPE
|
||||
process.stdout.removeListener 'error', onError
|
||||
defer.resolve()
|
||||
else
|
||||
defer.reject(err)
|
||||
|
||||
process.stdout.on 'error', onError
|
||||
process.stdout.write d, -> defer.resolve()
|
||||
|
||||
defer.promise
|
||||
|
||||
|
||||
getOpts = (argv) ->
|
||||
# get the partial line and partial word, if the point isn't at the end
|
||||
# ie, tabbing at: cmd foo b|ar
|
||||
line = process.env.COMP_LINE
|
||||
w = +process.env.COMP_CWORD
|
||||
point = +process.env.COMP_POINT
|
||||
words = argv.map unescape
|
||||
word = words[w]
|
||||
partialLine = line.substr 0, point
|
||||
partialWords = words.slice 0, w
|
||||
|
||||
# figure out where in that last word the point is
|
||||
partialWord = argv[w] or ''
|
||||
i = partialWord.length
|
||||
while partialWord.substr(0, i) isnt partialLine.substr(-1 * i) and i > 0
|
||||
i--
|
||||
partialWord = unescape partialWord.substr 0, i
|
||||
if partialWord then partialWords.push partialWord
|
||||
|
||||
{
|
||||
line: line
|
||||
w: w
|
||||
point: point
|
||||
words: words
|
||||
word: word
|
||||
partialLine: partialLine
|
||||
partialWords: partialWords
|
||||
partialWord: partialWord
|
||||
}
|
||||
|
||||
|
||||
complete = (cmd, opts) ->
|
||||
compls = []
|
||||
|
||||
# complete on cmds
|
||||
if opts.partialWord.indexOf('-')
|
||||
compls = Object.keys(cmd._cmdsByName)
|
||||
# Complete on required opts without '-' in last partial word
|
||||
# (if required not already specified)
|
||||
#
|
||||
# Commented out because of uselessness:
|
||||
# -b, --block suggest results in '-' on cmd line;
|
||||
# next completion suggest all options, because of '-'
|
||||
#.concat Object.keys(cmd._optsByKey).filter (v) -> cmd._optsByKey[v]._req
|
||||
else
|
||||
# complete on opt values: --opt=| case
|
||||
if m = opts.partialWord.match /^(--\w[\w-_]*)=(.*)$/
|
||||
optWord = m[1]
|
||||
optPrefix = optWord + '='
|
||||
else
|
||||
# complete on opts
|
||||
# don't complete on opts in case of --opt=val completion
|
||||
# TODO: don't complete on opts in case of unknown arg after commands
|
||||
# TODO: complete only on opts with arr() or not already used
|
||||
# TODO: complete only on full opts?
|
||||
compls = Object.keys cmd._optsByKey
|
||||
|
||||
# complete on opt values: next arg case
|
||||
if not (o = opts.partialWords[opts.w - 1]).indexOf '-'
|
||||
optWord = o
|
||||
|
||||
# complete on opt values: completion
|
||||
if optWord and opt = cmd._optsByKey[optWord]
|
||||
if not opt._flag and opt._comp
|
||||
compls = Q.join compls, Q.when opt._comp(opts), (c, o) ->
|
||||
c.concat o.map (v) -> (optPrefix or '') + v
|
||||
|
||||
# TODO: complete on args values (context aware, custom completion?)
|
||||
|
||||
# custom completion on cmds
|
||||
if cmd._comp
|
||||
compls = Q.join compls, Q.when(cmd._comp(opts)), (c, o) ->
|
||||
c.concat o
|
||||
|
||||
# TODO: context aware custom completion on cmds, opts and args
|
||||
# (can depend on already entered values, especially options)
|
||||
|
||||
Q.when compls, (compls) ->
|
||||
console.error 'partialWord: %s', opts.partialWord
|
||||
console.error 'compls: %j', compls
|
||||
compls.filter (c) -> c.indexOf(opts.partialWord) is 0
|
||||
5
build/node_modules/coa/src/index.coffee
generated
vendored
Normal file
5
build/node_modules/coa/src/index.coffee
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
exports.Cmd = require('./cmd').Cmd
|
||||
exports.Opt = require('./cmd').Opt
|
||||
exports.Arg = require('./cmd').Arg
|
||||
exports.shell = require('./shell')
|
||||
exports.require = require;
|
||||
243
build/node_modules/coa/src/opt.coffee
generated
vendored
Normal file
243
build/node_modules/coa/src/opt.coffee
generated
vendored
Normal file
@@ -0,0 +1,243 @@
|
||||
fs = require 'fs'
|
||||
Q = require 'q'
|
||||
Color = require('./color').Color
|
||||
Cmd = require('./cmd').Cmd
|
||||
|
||||
###*
|
||||
Option
|
||||
|
||||
Named entity. Options may have short and long keys for use from command line.
|
||||
@namespace
|
||||
@class Presents option
|
||||
###
|
||||
exports.Opt = class Opt
|
||||
|
||||
###*
|
||||
@constructs
|
||||
@param {COA.Cmd} cmd parent command
|
||||
###
|
||||
constructor: (@_cmd) -> @_cmd._opts.push @
|
||||
|
||||
###*
|
||||
Set a canonical option identifier to be used anywhere in the API.
|
||||
@param {String} _name option name
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
name: (@_name) -> @
|
||||
|
||||
###*
|
||||
Set a long description for option to be used anywhere in text messages.
|
||||
@param {String} _title option title
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
title: Cmd::title
|
||||
|
||||
###*
|
||||
Set a short key for option to be used with one hyphen from command line.
|
||||
@param {String} _short
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
short: (@_short) -> @_cmd._optsByKey['-' + _short] = @
|
||||
|
||||
###*
|
||||
Set a short key for option to be used with double hyphens from command line.
|
||||
@param {String} _long
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
long: (@_long) -> @_cmd._optsByKey['--' + _long] = @
|
||||
|
||||
###*
|
||||
Make an option boolean, i.e. option without value.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
flag: () ->
|
||||
@_flag = true
|
||||
@
|
||||
|
||||
###*
|
||||
Makes an option accepts multiple values.
|
||||
Otherwise, the value will be used by the latter passed.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
arr: ->
|
||||
@_arr = true
|
||||
@
|
||||
|
||||
###*
|
||||
Makes an option required.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
req: ->
|
||||
@_req = true
|
||||
@
|
||||
|
||||
###*
|
||||
Makes an option to act as a command,
|
||||
i.e. program will exit just after option action.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
only: ->
|
||||
@_only = true
|
||||
@
|
||||
|
||||
###*
|
||||
Set a validation (or value) function for option.
|
||||
Value from command line passes through before becoming available from API.
|
||||
Using for validation and convertion simple types to any values.
|
||||
@param {Function} _val validating function,
|
||||
invoked in the context of option instance
|
||||
and has one parameter with value from command line
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
val: (@_val) -> @
|
||||
|
||||
###*
|
||||
Set a default value for option.
|
||||
Default value passed through validation function as ordinary value.
|
||||
@param {Object} _def
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
def: (@_def) -> @
|
||||
|
||||
###*
|
||||
Make option value inputting stream.
|
||||
It's add useful validation and shortcut for STDIN.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
input: ->
|
||||
# XXX: hack to workaround a bug in node 0.6.x,
|
||||
# see https://github.com/joyent/node/issues/2130
|
||||
process.stdin.pause();
|
||||
|
||||
@
|
||||
.def(process.stdin)
|
||||
.val (v) ->
|
||||
if typeof v is 'string'
|
||||
if v is '-'
|
||||
process.stdin
|
||||
else
|
||||
s = fs.createReadStream v, { encoding: 'utf8' }
|
||||
s.pause()
|
||||
s
|
||||
else v
|
||||
|
||||
###*
|
||||
Make option value outputing stream.
|
||||
It's add useful validation and shortcut for STDOUT.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
output: ->
|
||||
@
|
||||
.def(process.stdout)
|
||||
.val (v) ->
|
||||
if typeof v is 'string'
|
||||
if v is '-'
|
||||
process.stdout
|
||||
else
|
||||
fs.createWriteStream v, { encoding: 'utf8' }
|
||||
else v
|
||||
|
||||
###*
|
||||
Add action for current option command.
|
||||
This action is performed if the current option
|
||||
is present in parsed options (with any value).
|
||||
@param {Function} act action function,
|
||||
invoked in the context of command instance
|
||||
and has the parameters:
|
||||
- {Object} opts parsed options
|
||||
- {Array} args parsed arguments
|
||||
- {Object} res actions result accumulator
|
||||
It can return rejected promise by Cmd.reject (in case of error)
|
||||
or any other value treated as result.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
act: (act) ->
|
||||
opt = @
|
||||
name = @_name
|
||||
@_cmd.act (opts) ->
|
||||
if name of opts
|
||||
res = act.apply @, arguments
|
||||
if opt._only
|
||||
Q.when res, (res) =>
|
||||
@reject {
|
||||
toString: -> res.toString()
|
||||
exitCode: 0
|
||||
}
|
||||
else
|
||||
res
|
||||
@
|
||||
|
||||
###*
|
||||
Set custom additional completion for current option.
|
||||
@param {Function} completion generation function,
|
||||
invoked in the context of option instance.
|
||||
Accepts parameters:
|
||||
- {Object} opts completion options
|
||||
It can return promise or any other value treated as result.
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
comp: Cmd::comp
|
||||
|
||||
_saveVal: (opts, val) ->
|
||||
if @_val then val = @_val val
|
||||
if @_arr
|
||||
(opts[@_name] or= []).push val
|
||||
else
|
||||
opts[@_name] = val
|
||||
val
|
||||
|
||||
_parse: (argv, opts) ->
|
||||
@_saveVal(
|
||||
opts,
|
||||
if @_flag
|
||||
true
|
||||
else
|
||||
argv.shift()
|
||||
)
|
||||
|
||||
_checkParsed: (opts, args) -> not opts.hasOwnProperty @_name
|
||||
|
||||
_usage: ->
|
||||
res = []
|
||||
nameStr = @_name.toUpperCase()
|
||||
|
||||
if @_short
|
||||
res.push '-', Color 'lgreen', @_short
|
||||
unless @_flag then res.push ' ' + nameStr
|
||||
res.push ', '
|
||||
|
||||
if @_long
|
||||
res.push '--', Color 'green', @_long
|
||||
unless @_flag then res.push '=' + nameStr
|
||||
|
||||
res.push ' : ', @_title
|
||||
|
||||
if @_req then res.push ' ', Color('lred', '(required)')
|
||||
|
||||
res.join ''
|
||||
|
||||
_requiredText: -> 'Missing required option:\n ' + @_usage()
|
||||
|
||||
###*
|
||||
Return rejected promise with error code.
|
||||
Use in .val() for return with error.
|
||||
@param {Object} reject reason
|
||||
You can customize toString() method and exitCode property
|
||||
of reason object.
|
||||
@returns {Q.promise} rejected promise
|
||||
###
|
||||
reject: Cmd::reject
|
||||
|
||||
###*
|
||||
Finish chain for current option and return parent command instance.
|
||||
@returns {COA.Cmd} parent command
|
||||
###
|
||||
end: Cmd::end
|
||||
|
||||
###*
|
||||
Apply function with arguments in context of option instance.
|
||||
@param {Function} fn
|
||||
@param {Array} args
|
||||
@returns {COA.Opt} this instance (for chainability)
|
||||
###
|
||||
apply: Cmd::apply
|
||||
10
build/node_modules/coa/src/shell.coffee
generated
vendored
Normal file
10
build/node_modules/coa/src/shell.coffee
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
exports.unescape = (w) ->
|
||||
w = if w.charAt(0) is '"'
|
||||
w.replace(/^"|([^\\])"$/g, '$1')
|
||||
else
|
||||
w.replace(/\\ /g, ' ')
|
||||
w.replace(/\\("|'|\$|`|\\)/g, '$1')
|
||||
|
||||
exports.escape = (w) ->
|
||||
w = w.replace(/(["'$`\\])/g,'\\$1')
|
||||
if w.match(/\s+/) then '"' + w + '"' else w
|
||||
496
build/node_modules/coa/test/coa.js
generated
vendored
Normal file
496
build/node_modules/coa/test/coa.js
generated
vendored
Normal file
@@ -0,0 +1,496 @@
|
||||
var assert = require('chai').assert,
|
||||
COA = require('..');
|
||||
|
||||
/**
|
||||
* Mocha BDD interface.
|
||||
*/
|
||||
/** @name describe @function */
|
||||
/** @name it @function */
|
||||
/** @name before @function */
|
||||
/** @name after @function */
|
||||
/** @name beforeEach @function */
|
||||
/** @name afterEach @function */
|
||||
|
||||
describe('Opt', function() {
|
||||
|
||||
describe('Unknown option', function() {
|
||||
|
||||
var cmd = COA.Cmd();
|
||||
|
||||
it('should fail', function() {
|
||||
return cmd.do(['-a'])
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Short options', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('a')
|
||||
.short('a')
|
||||
.end()
|
||||
.opt()
|
||||
.name('b')
|
||||
.short('b')
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should return passed values', function() {
|
||||
return cmd.do(['-a', 'a', '-b', 'b'])
|
||||
.then(function(res) {
|
||||
assert.deepEqual(res, { a: 'a', b: 'b' });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Long options', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('long1')
|
||||
.long('long1')
|
||||
.end()
|
||||
.opt()
|
||||
.name('long2')
|
||||
.long('long2')
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should return passed values', function() {
|
||||
return cmd.do(['--long1', 'long value', '--long2=another long value'])
|
||||
.then(function(res) {
|
||||
assert.deepEqual(res, { long1: 'long value', long2: 'another long value' });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Array option', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('a')
|
||||
.short('a')
|
||||
.arr()
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should return array of passed values', function() {
|
||||
return cmd.do(['-a', '1', '-a', '2'])
|
||||
.then(function(res) {
|
||||
assert.deepEqual(res, { a: ['1', '2'] });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Required option', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('a')
|
||||
.short('a')
|
||||
.req()
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should fail if not specified', function() {
|
||||
return cmd.do()
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
it('should return passed value if specified', function() {
|
||||
return cmd.do(['-a', 'test'])
|
||||
.then(function(opts) {
|
||||
assert.equal(opts.a, 'test');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Option with default value', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('a')
|
||||
.short('a')
|
||||
.def('aaa')
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should return default value if not specified', function() {
|
||||
return cmd.do()
|
||||
.then(function(opts) {
|
||||
assert.equal(opts.a, 'aaa');
|
||||
});
|
||||
});
|
||||
|
||||
it('should return passed value if specified', function() {
|
||||
return cmd.do(['-a', 'test'])
|
||||
.then(function(opts) {
|
||||
assert.equal(opts.a, 'test');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Validated / transformed option', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('a')
|
||||
.short('a')
|
||||
.val(function(v) {
|
||||
if (v === 'invalid') return this.reject('fail');
|
||||
return { value: v };
|
||||
})
|
||||
.end()
|
||||
.act(function(opts) {
|
||||
return opts;
|
||||
});
|
||||
|
||||
it('should fail if custom checks suppose to do so', function() {
|
||||
return cmd.do(['-a', 'invalid'])
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
it('should return transformed value', function() {
|
||||
return cmd.do(['-a', 'test'])
|
||||
.then(function(opts) {
|
||||
assert.deepEqual(opts.a, { value: 'test' });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Only option (--version case)', function() {
|
||||
|
||||
var ver = require('../package.json').version,
|
||||
cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('version')
|
||||
.long('version')
|
||||
.flag()
|
||||
.only()
|
||||
.act(function() {
|
||||
return ver;
|
||||
})
|
||||
.end()
|
||||
.opt()
|
||||
.name('req')
|
||||
.short('r')
|
||||
.req()
|
||||
.end();
|
||||
|
||||
it('should process the only() option', function() {
|
||||
return cmd.do(['--version'])
|
||||
.then(assert.fail, function(res) {
|
||||
assert.equal(res, ver);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('input()');
|
||||
it('output()');
|
||||
|
||||
});
|
||||
|
||||
describe('Arg', function() {
|
||||
|
||||
describe('Unknown arg', function() {
|
||||
|
||||
var cmd = COA.Cmd();
|
||||
|
||||
it('should fail', function() {
|
||||
return cmd.do(['test'])
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Unknown arg after known', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.arg()
|
||||
.name('a')
|
||||
.end();
|
||||
|
||||
it('should fail', function() {
|
||||
return cmd.do(['test', 'unknown'])
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Array arg', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.arg()
|
||||
.name('a')
|
||||
.arr()
|
||||
.end()
|
||||
.act(function(opts, args) {
|
||||
return args;
|
||||
});
|
||||
|
||||
it('should return array of passed values', function() {
|
||||
return cmd.do(['value 1', 'value 2'])
|
||||
.then(function(args) {
|
||||
assert.deepEqual(args, { a: ['value 1', 'value 2'] });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Required arg', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.arg()
|
||||
.name('a')
|
||||
.req()
|
||||
.end()
|
||||
.act(function(opts, args) {
|
||||
return args;
|
||||
});
|
||||
|
||||
it('should fail if not specified', function() {
|
||||
return cmd.do()
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
it('should return passed value if specified', function() {
|
||||
return cmd.do(['value'])
|
||||
.then(function(args) {
|
||||
assert.equal(args.a, 'value');
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Args after options', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.opt()
|
||||
.name('opt')
|
||||
.long('opt')
|
||||
.end()
|
||||
.arg()
|
||||
.name('arg1')
|
||||
.end()
|
||||
.arg()
|
||||
.name('arg2')
|
||||
.arr()
|
||||
.end()
|
||||
.act(function(opts, args) {
|
||||
return { opts: opts, args: args };
|
||||
});
|
||||
|
||||
it('should return passed values', function() {
|
||||
return cmd.do(['--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(function(o) {
|
||||
assert.deepEqual(o, {
|
||||
opts: { opt: 'value' },
|
||||
args: {
|
||||
arg1: 'value',
|
||||
arg2: ['value 1', 'value 2']
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Raw args', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.arg()
|
||||
.name('raw')
|
||||
.arr()
|
||||
.end()
|
||||
.act(function(opts, args) {
|
||||
return args;
|
||||
});
|
||||
|
||||
it('should return passed arg values', function() {
|
||||
return cmd.do(['--', 'raw', 'arg', 'values'])
|
||||
.then(function(args) {
|
||||
assert.deepEqual(args, { raw: ['raw', 'arg', 'values'] });
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('Cmd', function() {
|
||||
|
||||
var doTest = function(o) {
|
||||
assert.deepEqual(o, {
|
||||
opts: { opt: 'value' },
|
||||
args: {
|
||||
arg1: 'value',
|
||||
arg2: ['value 1', 'value 2']
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
invokeOpts = { opt: 'value' },
|
||||
invokeArgs = {
|
||||
arg1: 'value',
|
||||
arg2: ['value 1', 'value 2']
|
||||
};
|
||||
|
||||
describe('Subcommand', function() {
|
||||
|
||||
var cmd = COA.Cmd()
|
||||
.cmd()
|
||||
.name('command')
|
||||
.opt()
|
||||
.name('opt')
|
||||
.long('opt')
|
||||
.end()
|
||||
.arg()
|
||||
.name('arg1')
|
||||
.end()
|
||||
.arg()
|
||||
.name('arg2')
|
||||
.arr()
|
||||
.end()
|
||||
.act(function(opts, args) {
|
||||
return { opts: opts, args: args };
|
||||
})
|
||||
.end();
|
||||
|
||||
describe('when specified on command line', function() {
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['command', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when invoked using api', function() {
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.api.command(invokeOpts, invokeArgs)
|
||||
.then(doTest);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when invoked using invoke()', function() {
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.invoke('command', invokeOpts, invokeArgs)
|
||||
.then(doTest);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('when unexisting command invoked using invoke()', function() {
|
||||
|
||||
it('should fail', function() {
|
||||
return cmd.invoke('unexistent')
|
||||
.then(assert.fail, emptyFn);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('External subcommand', function() {
|
||||
|
||||
describe('default scheme: cmd.extendable()', function() {
|
||||
|
||||
describe('when described as a function', function() {
|
||||
var cmd = COA.Cmd()
|
||||
.name('coa')
|
||||
.extendable();
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
});
|
||||
|
||||
describe('when described as an COA.Cmd() object', function() {
|
||||
var cmd = COA.Cmd()
|
||||
.name('coa')
|
||||
.extendable();
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['test-obj', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
});
|
||||
|
||||
describe('2nd level subcommand', function() {
|
||||
var cmd = COA.Cmd()
|
||||
.name('coa')
|
||||
.cmd()
|
||||
.name('test')
|
||||
.extendable()
|
||||
.end();
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['test', 'obj', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("common prefix: cmd.extendable('coa-')", function() {
|
||||
|
||||
describe('when described as a function', function() {
|
||||
var cmd = COA.Cmd()
|
||||
.name('coa')
|
||||
.extendable('coa-');
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("format string: cmd.extendable('coa-%s')", function() {
|
||||
|
||||
describe('when described as a function', function() {
|
||||
var cmd = COA.Cmd()
|
||||
.name('coa')
|
||||
.extendable('coa-%s');
|
||||
|
||||
it('should be invoked and accept passed opts and args', function() {
|
||||
return cmd.do(['test', '--opt', 'value', 'value', 'value 1', 'value 2'])
|
||||
.then(doTest);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
it('helpful(), name(), title()');
|
||||
|
||||
});
|
||||
|
||||
function emptyFn() {
|
||||
// empty function
|
||||
}
|
||||
2
build/node_modules/coa/test/mocha.opts
generated
vendored
Normal file
2
build/node_modules/coa/test/mocha.opts
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
--reporter spec
|
||||
--timeout 20
|
||||
60
build/node_modules/coa/test/shell-test.js
generated
vendored
Normal file
60
build/node_modules/coa/test/shell-test.js
generated
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
var assert = require('chai').assert,
|
||||
shell = require('..').shell;
|
||||
|
||||
/**
|
||||
* Mocha BDD interface.
|
||||
*/
|
||||
/** @name describe @function */
|
||||
/** @name it @function */
|
||||
/** @name before @function */
|
||||
/** @name after @function */
|
||||
/** @name beforeEach @function */
|
||||
/** @name afterEach @function */
|
||||
|
||||
describe('shell', function() {
|
||||
|
||||
describe('escape()', function() {
|
||||
|
||||
var escape = shell.escape;
|
||||
|
||||
it('Should wrap values with spaces in double quotes', function() {
|
||||
assert.equal(escape('asd abc'), '"asd abc"');
|
||||
});
|
||||
|
||||
it('Should escape double quote "', function() {
|
||||
assert.equal(escape('"asd'), '\\"asd');
|
||||
});
|
||||
|
||||
it("Should escape single quote '", function() {
|
||||
assert.equal(escape("'asd"), "\\'asd");
|
||||
});
|
||||
|
||||
it('Should escape backslash \\', function() {
|
||||
assert.equal(escape('\\asd'), '\\\\asd');
|
||||
});
|
||||
|
||||
it('Should escape dollar $', function() {
|
||||
assert.equal(escape('$asd'), '\\$asd');
|
||||
});
|
||||
|
||||
it('Should escape backtick `', function() {
|
||||
assert.equal(escape('`asd'), '\\`asd');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('unescape()', function() {
|
||||
|
||||
var unescape = shell.unescape;
|
||||
|
||||
it('Should strip double quotes at the both ends', function() {
|
||||
assert.equal(unescape('"asd"'), 'asd');
|
||||
});
|
||||
|
||||
it('Should not strip escaped double quotes at the both ends', function() {
|
||||
assert.equal(unescape('\\"asd\\"'), '"asd"');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
9
build/node_modules/coa/tests/api-h.js
generated
vendored
Normal file
9
build/node_modules/coa/tests/api-h.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
require('..').Cmd()
|
||||
.name('bla')
|
||||
.title('Bla bla bla')
|
||||
.helpful()
|
||||
.invoke({ help: true })
|
||||
.then(function(res) {
|
||||
console.log(res);
|
||||
})
|
||||
.done(); // Q.done()
|
||||
6
build/node_modules/coa/tests/h.js
generated
vendored
Normal file
6
build/node_modules/coa/tests/h.js
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
var argv = process.argv.slice(2);
|
||||
require('..').Cmd()
|
||||
.name('bla')
|
||||
.title('Bla bla bla')
|
||||
.helpful()
|
||||
.run(argv.length? argv : ['-h']);
|
||||
Reference in New Issue
Block a user