1 | #!/usr/bin/env node
|
2 |
|
3 |
|
4 |
|
5 | 'use strict';
|
6 |
|
7 | const program = require('commander');
|
8 | const getVisitor = require('../lib/visitor').getVisitor;
|
9 | const notifier = require('../lib/update-notifier');
|
10 |
|
11 | let srcPath;
|
12 | let dstPath;
|
13 |
|
14 | program
|
15 | .name('fun nas cp')
|
16 | .description('Copy file/folder between remote NAS and local path.')
|
17 | .usage('[options] <src_path> <dst_path>')
|
18 | .option('-r, --recursive', 'copy folders recursively')
|
19 | .option('-n, --no-clobber', 'Do not overwrite an existing file')
|
20 | .arguments("<srcPathValue> <dstPathValue>")
|
21 | .action((srcPathValue, dstPathValue) => {
|
22 |
|
23 | srcPath = srcPathValue;
|
24 | dstPath = dstPathValue;
|
25 | })
|
26 | .parse(process.argv);
|
27 |
|
28 | if (program.args.length < 2) {
|
29 | console.error();
|
30 | console.error(" error: too few arguments");
|
31 | program.help();
|
32 | } else if (program.args.length < 2) {
|
33 | console.error();
|
34 | console.error(" error: too many arguments");
|
35 | program.help();
|
36 | }
|
37 |
|
38 | notifier.notify();
|
39 |
|
40 | getVisitor(true).then((visitor) => {
|
41 | visitor.pageview('/fun/nas/cp').send();
|
42 |
|
43 | require('../lib/commands/nas/cp')(srcPath, dstPath, program)
|
44 | .then(() => {
|
45 | visitor.event({
|
46 | ec: 'cp',
|
47 | ea: `cp`,
|
48 | el: 'success',
|
49 | dp: '/fun/nas/cp'
|
50 | }).send();
|
51 | })
|
52 | .catch(error => {
|
53 | visitor.event({
|
54 | ec: 'cp',
|
55 | ea: `cp`,
|
56 | el: 'error',
|
57 | dp: '/fun/nas/cp'
|
58 | }).send();
|
59 |
|
60 | require('../lib/exception-handler')(error);
|
61 | });
|
62 | });
|