UNPKG

1.49 kBJavaScriptView Raw
1#!/usr/bin/env node
2
3/* eslint-disable quotes */
4'use strict';
5const program = require('commander');
6
7const getVisitor = require('../lib/visitor').getVisitor;
8const notifier = require('../lib/update-notifier');
9const commaSeparatedList = (value, dummyPrevious) => {
10 return value.split(',');
11};
12
13const examples =
14 `
15 Examples:
16
17 $ fun nas sync
18 $ fun nas sync -s nas_demo_service
19 $ fun nas sync -s nas_demo_service -m /mnt/auto
20 `;
21
22program
23 .name('fun nas sync')
24 .usage('[options]')
25 .description('Upload local NAS to remote NAS automatically')
26 .option('-t, --template [template]', 'The path of fun template file.')
27 .option('-s, --service <service-name>', 'Upload the local NAS belonging to the specified service')
28 .option('-m, --mount-dir <mount-dirs>', 'Upload the local NAS corresponding to the specified mount directory', commaSeparatedList)
29 .on('--help', () => {
30 console.log(examples);
31 })
32 .parse(process.argv);
33
34program.parse(process.argv);
35
36notifier.notify();
37
38getVisitor().then(visitor => {
39 visitor.pageview('/fun/nas/sync').send();
40
41 require('../lib/commands/nas/sync')(program)
42 .then(() => {
43 visitor.event({
44 ec: 'sync',
45 ea: 'sync',
46 el: 'success',
47 dp: '/fun/nas/sync'
48 }).send();
49 })
50 .catch(error => {
51 visitor.event({
52 ec: 'sync',
53 ea: 'sync',
54 el: 'error',
55 dp: '/fun/nas/sync'
56 }).send();
57
58 require('../lib/exception-handler')(error);
59 });
60});