added old data
This commit is contained in:
17
project2/node_modules/cli/examples/cat.js
generated
vendored
Executable file
17
project2/node_modules/cli/examples/cat.js
generated
vendored
Executable file
@ -0,0 +1,17 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
var output_file = function (file) {
|
||||
cli.withInput(file, function (line, sep, eof) {
|
||||
if (!eof) {
|
||||
cli.output(line + sep);
|
||||
} else if (cli.args.length) {
|
||||
output_file(cli.args.shift());
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
if (cli.args.length) {
|
||||
output_file(cli.args.shift());
|
||||
}
|
16
project2/node_modules/cli/examples/command.js
generated
vendored
Executable file
16
project2/node_modules/cli/examples/command.js
generated
vendored
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
//The second (optional) argument of cli.parse() is a command list
|
||||
//Type `./command.js --help` for usage info
|
||||
|
||||
//cli enables auto-completion of commands (similiar to npm), e.g. all of
|
||||
//the following are equivalent and result in "Command is: install":
|
||||
// $ ./command.js install
|
||||
// $ ./command.js inst
|
||||
// $ ./command.js i
|
||||
|
||||
cli.parse(null, ['install', 'test', 'edit', 'remove', 'uninstall', 'ls']);
|
||||
|
||||
console.log('Command is: ' + cli.command);
|
54
project2/node_modules/cli/examples/echo.js
generated
vendored
Executable file
54
project2/node_modules/cli/examples/echo.js
generated
vendored
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
/* All of the following commands are equivalent and write `foo\tbar foo` to out.txt
|
||||
$ ./echo.js -n -e --output=out.txt "foo\tbar" "foo"
|
||||
$ ./echo.js --newline --escape --output "out.txt" "foo\tbar" "foo"
|
||||
$ ./echo.js -ne --output=out.txt "foo\tbar" "foo"
|
||||
$ ./echo.js -en --output="out.txt" "foo\tbar" "foo"
|
||||
*/
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
cli.parse({
|
||||
newline: ['n', 'Do not output the trailing newline'],
|
||||
escape: ['e', 'Enable interpretation of backslash escapes'],
|
||||
separator: ['s', 'Separate arguments using this value', 'string', ' '],
|
||||
output: [false, 'Write to FILE rather than the console', 'file']
|
||||
});
|
||||
|
||||
cli.main(function (args, options) {
|
||||
var output = '', i, j, l, output_stream;
|
||||
|
||||
if (this.argc) {
|
||||
if (options.escape) {
|
||||
var replace = {'\\n':'\n','\\r':'\r','\\t':'\t','\\e':'\e','\\v':'\v','\\f':'\f','\\c':'\c','\\b':'\b','\\a':'\a','\\\\':'\\'};
|
||||
var escape = function (str) {
|
||||
str += '';
|
||||
for (j in replace) {
|
||||
str = str.replace(i, replace[i]);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
for (i = 0, l = this.argc; i < l; i++) {
|
||||
args[i] = escape(args[i]);
|
||||
}
|
||||
options.separator = escape(options.separator);
|
||||
}
|
||||
output += args.join(options.separator);
|
||||
}
|
||||
|
||||
if (!options.newline) {
|
||||
output += '\n';
|
||||
}
|
||||
|
||||
try {
|
||||
if (options.output) {
|
||||
output_stream = this.native.fs.createWriteStream(options.output)
|
||||
} else {
|
||||
output_stream = process.stdout;
|
||||
}
|
||||
output_stream.write(output);
|
||||
} catch (e) {
|
||||
this.fatal('Could not write to output stream');
|
||||
}
|
||||
});
|
6
project2/node_modules/cli/examples/glob.js
generated
vendored
Executable file
6
project2/node_modules/cli/examples/glob.js
generated
vendored
Executable file
@ -0,0 +1,6 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli').enable('glob');
|
||||
|
||||
//Running `./glob.js *.js` will output a list of .js files in this directory
|
||||
console.log(cli.args);
|
20
project2/node_modules/cli/examples/long_desc.js
generated
vendored
Executable file
20
project2/node_modules/cli/examples/long_desc.js
generated
vendored
Executable file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('../');
|
||||
|
||||
//You can (optionally) boost the width of output with:
|
||||
//cli.width = 120;
|
||||
|
||||
//You can also adjust the width of the options/command definitions
|
||||
//cli.option_width = 25;
|
||||
|
||||
var long_desc = 'Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s '
|
||||
+ 'standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make'
|
||||
+ ' a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, '
|
||||
+ 'remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing '
|
||||
+ 'Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions'
|
||||
+ ' of Lorem Ipsum.';
|
||||
|
||||
cli.parse({
|
||||
foo: ['f', long_desc]
|
||||
});
|
11
project2/node_modules/cli/examples/progress.js
generated
vendored
Executable file
11
project2/node_modules/cli/examples/progress.js
generated
vendored
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
var i = 0, interval = setInterval(function () {
|
||||
cli.progress(++i / 100);
|
||||
if (i === 100) {
|
||||
clearInterval(interval);
|
||||
cli.ok('Finished!');
|
||||
}
|
||||
}, 50);
|
18
project2/node_modules/cli/examples/sort.js
generated
vendored
Executable file
18
project2/node_modules/cli/examples/sort.js
generated
vendored
Executable file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
var options = cli.parse({
|
||||
numeric: ['n', 'Compare using a numeric sort'],
|
||||
reverse: ['r', 'Reverse the results']
|
||||
});
|
||||
|
||||
cli.withStdinLines(function (lines, newline) {
|
||||
lines.sort(!options.numeric ? null : function (a, b) {
|
||||
return parseInt(a) > parseInt(b);
|
||||
});
|
||||
if (options.reverse) {
|
||||
lines.reverse();
|
||||
}
|
||||
this.output(lines.join(newline));
|
||||
});
|
9
project2/node_modules/cli/examples/spinner.js
generated
vendored
Executable file
9
project2/node_modules/cli/examples/spinner.js
generated
vendored
Executable file
@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
var cli = require('cli');
|
||||
|
||||
cli.spinner('Working..');
|
||||
|
||||
setTimeout(function () {
|
||||
cli.spinner('Working.. done!', true); //End the spinner
|
||||
}, 3000);
|
Reference in New Issue
Block a user