Initial commit
This commit is contained in:
59
node_modules/cliss/test/specs/cliss-options/index.js
generated
vendored
Normal file
59
node_modules/cliss/test/specs/cliss-options/index.js
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
'use strict';
|
||||
|
||||
const cliss = require('../../../');
|
||||
|
||||
const cliSpec = {
|
||||
name: 'main',
|
||||
options: [{
|
||||
name: 'param1',
|
||||
description: 'param1 description',
|
||||
required: true
|
||||
}],
|
||||
action: (param1 = 'defaultParam1', param2) => `mainOutput`,
|
||||
commands: [{
|
||||
name: 'nested1',
|
||||
action: param1 => {
|
||||
return `nested1:` + param1;
|
||||
},
|
||||
pipe: {
|
||||
stdin: input => {
|
||||
return {
|
||||
param1: input
|
||||
};
|
||||
}
|
||||
},
|
||||
commands: [{
|
||||
name: 'nested1.1',
|
||||
action: (param1 = 'defaultParam1', param2) => {
|
||||
return `nested1-nested1.1:` + param1;
|
||||
},
|
||||
pipe: {
|
||||
after: result => `${result}commandPipe`
|
||||
}
|
||||
}]
|
||||
}, {
|
||||
name: 'nested2',
|
||||
action: param1 => {
|
||||
return `nested2:` + param1;
|
||||
}
|
||||
}]
|
||||
};
|
||||
|
||||
cliss(cliSpec, {
|
||||
command: {
|
||||
subcommandsDelimiter: '-'
|
||||
},
|
||||
options: {
|
||||
validateRequiredParameters: true
|
||||
},
|
||||
help: {
|
||||
stripAnsi: true
|
||||
},
|
||||
pipe: {
|
||||
before: args => {
|
||||
args.param1 = args.param1.toLowerCase()
|
||||
return args;
|
||||
},
|
||||
after: result => `${result}optionsPipe`
|
||||
}
|
||||
});
|
||||
28
node_modules/cliss/test/specs/cliss-options/specs.js
generated
vendored
Normal file
28
node_modules/cliss/test/specs/cliss-options/specs.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
const tests = [{
|
||||
description: 'options.validateRequiredParameters = true',
|
||||
input: '--param2=A',
|
||||
output: `
|
||||
Usage:
|
||||
|
||||
$ main <options>
|
||||
$ main [command]
|
||||
|
||||
Options:
|
||||
|
||||
--param1 Required - param1 description
|
||||
--param2
|
||||
|
||||
Commands:
|
||||
|
||||
nested1
|
||||
nested2
|
||||
`
|
||||
}, {
|
||||
description: `command.subcommandsDelimiter = '-' + options.pipe.before + command.pipe.after`,
|
||||
input: 'nested1-nested1.1 --param1=A',
|
||||
output: `nested1-nested1.1:aoptionsPipecommandPipe`
|
||||
}];
|
||||
|
||||
module.exports = tests;
|
||||
Reference in New Issue
Block a user