UNPKG

1.42 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('-s, --service <service-name>', 'Upload the local NAS belonging to the specified service')
27 .option('-m, --mount-dir <mount-dirs>', 'Upload the local NAS corresponding to the specified mount directory', commaSeparatedList)
28 .on('--help', () => {
29 console.log(examples);
30 })
31 .parse(process.argv);
32
33program.parse(process.argv);
34
35notifier.notify();
36
37getVisitor().then(visitor => {
38 visitor.pageview('/fun/nas/sync').send();
39
40 require('../lib/commands/nas/sync')(program)
41 .then(() => {
42 visitor.event({
43 ec: 'sync',
44 ea: 'sync',
45 el: 'success',
46 dp: '/fun/nas/sync'
47 }).send();
48 })
49 .catch(error => {
50 visitor.event({
51 ec: 'sync',
52 ea: 'sync',
53 el: 'error',
54 dp: '/fun/nas/sync'
55 }).send();
56
57 require('../lib/exception-handler')(error);
58 });
59});