-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathindex.js
executable file
·110 lines (94 loc) · 2.97 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env node
const { LotusWsClient } = require('./core/infrastructure/lotus/LotusWsClient');
const commander = require('commander');
const { Logger } = require('./utils');
require('dotenv').config();
const program = new commander.Command();
program.version('0.5.6', '-v, --version', 'output the current version');
program.name('starling').usage('<command> [command arguments] [--help]');
program.helpOption('-h, --help', 'read more information');
const { store, list, monitor, retry, verify, get } = require('./commands');
const { createConfig } = require('./utils');
async function init() {
try {
program
.command('store')
.description('path to file or folder you would like to store')
.option('<path/to/folder>', 'store a folder')
.option('<path/to/file>', 'store a file')
.action(() => {
store();
});
program
.command('retry')
.description('retries to upload failed jobs')
.action(() => {
retry();
});
program
.command('get')
.description('retrieves/downloads a file')
.option('<file id>', 'id of the file to retrieve')
.option('<output path>', 'path to where the retrieved file will be stored')
.action( () => {
get();
});
program
.command('monitor')
.description('launches interactive monitoring interface')
.option(
'<refresh rate>',
'a number (in seconds) to set the refresh rate of the interface'
)
.action(() => {
if (process.argv.length > 4) {
throw new Error(
'\nplease provide 1 argument as the monitor refresh rate in seconds'
);
} else if (process.argv[3] < 3) {
throw new Error('\nplease provide a period of 3 seconds or greater');
}
monitor(process.argv[3]);
});
program
.command('list')
.description('outputs a csv of all files you have stored in filecoin')
.option('<path/to/folder>', 'a path to store the generated csv file')
.action(() => {
if (process.argv.length > 4) {
throw new Error('\nplease provide 1 argument as the directory');
}
list();
});
program
.command('verify')
.description('outputs a csv report of file fixity')
.option('<path/to/folder>', 'a path to store the generated csv file')
.action(() => {
if (process.argv.length > 4) {
throw new Error('\nplease provide 1 argument as the directory');
}
verify();
});
program
.command('help')
.description('displays this help file')
.action(() => {
program.help();
});
program
.command('config')
.description('modifies the global config settings')
.action(() => {
createConfig(false);
});
if (process.argv.length < 3) {
program.help();
}
program.parse(process.argv);
} catch (err) {
console.log(err);
Logger.error(err.stack);
}
}
init();