-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathezunpaywall
executable file
·159 lines (137 loc) · 5.46 KB
/
ezunpaywall
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env node
const program = require('commander');
const pkg = require('./package.json');
const { manageConfig } = require('./cmds/config');
const ping = require('./cmds/ping');
const {
updateJobFile,
updateJobPeriod,
updateJobSnapshot,
updateReport,
updateStatus,
} = require('./cmds/update');
const enrich = require('./cmds/enrich');
const {
apiKeyCreate,
apiKeyUpdate,
apiKeyDelete,
apiKeyGet,
apiKeyLoad,
} = require('./cmds/apikey');
program.on('command:*', () => {
console.error(`Invalid command: ${program.args.join(' ')}\nSee --help for a list of available commands.`);
process.exit(1);
});
program.version(pkg.version);
program
.command('config')
.description('config management command to establish the connection between the command and ezunpaywall')
.option('-g --get', 'display the configuration')
.option('-s --set <key> <value>', 'update config')
.option('-L --list', 'list of attributes required for configuration')
.action((option) => manageConfig(option));
program
.command('ping')
.description('check if services are available')
.action((option) => ping(option));
program
.command('update-job-file')
.description('insert the content of changefile installed on ezunpaywall')
.option('--file <file>', 'changefiles file installed on ezunpaywall')
.option('--offset <offset>', 'line where processing will start')
.option('--limit <limit>', 'line where processing will end')
.option('-L --list', 'list of changefile installed on ezunpaywall')
.option('-I --index <index>', 'name of the index to which the data is inserted')
.action((
option,
) => updateJobFile(option).catch((err) => console.log(err)));
program
.command('update-job-period')
.description('start an unpaywall data update process')
.option('--force', 'force update without check if is already installed')
.option('--startDate <startDate>', 'start date to download and insert updates from unpaywall')
.option('--endDate <endDate>', 'end date to download and insert updates from unpaywall')
.option('--interval <interval>', 'interval of update (day or week)')
.option('-I --index <index>', 'name of the index to which the data is inserted')
.action((
option,
) => updateJobPeriod(option).catch((err) => console.log(err)));
program
.command('update-job-snapshot')
.description('download and insert the current snapshot')
.option('-I --index <index>', 'name of the index to which the data is inserted')
.action((
option,
) => updateJobSnapshot(option).catch((err) => console.log(err)));
program
.command('update-report')
.description('get report of update process')
.option('--file <file>', 'name of report on ezunpaywall')
.option('--latest', 'latest report')
.option('-L --list', 'list of reports on ezunpaywall')
.action((
option,
) => updateReport(option).catch((err) => console.log(err)));
program
.command('update-status')
.description('get status of update process')
.option('--verbose', 'dynamic display')
.action((
option,
) => updateStatus(option).catch((err) => console.log(err)));
program
.command('enrich')
.description('enrich file with unpaywall attributes')
.option('--file <file>', 'file which must be enriched')
.option('--separator <separator>', 'separator of csv file')
.option('--attributes <attributes>', 'attributes which must be enriched in graphql format. By default, all attributes are added')
.option('--out <out>', 'name of enriched file. By default the output file is named: out.jsonl')
.option('--verbose', 'display loadbar and exit if process end')
.option('-I --index <index>', 'name of the index from which the data will be retrieved')
.action((
option,
) => enrich(option));
program
.command('apikey-create')
.description('create new apikey')
.option('--keyname <keyname>', 'name of apikey')
.option('--access <access>', 'name of access services of apikey seperated by comma. By default it set at [\'graphql\']')
.option('--attributes <attributes>', 'unpaywall attributes seperated apikey seperated by comma. By default it set at \'*\'')
.option('--allowed <allowed>', ' indicates if the key is authorized or not. "true" or "false" only. By default it set at true')
.action((
option,
) => apiKeyCreate(option).catch((err) => console.log(err)));
program
.command('apikey-update')
.description('update apikey')
.option('--apikey <apikey>', 'apikey')
.option('--keyname <keyname>', 'name of apikey')
.option('--access <access>', 'name of access services of apikey seperated by comma')
.option('--attributes <attributes>', 'unpaywall attributes seperated apikey seperated by comma')
.option('--allowed <allowed>', 'indicates if the key is authorized or not. "true" or "false" only')
.action((
option,
) => apiKeyUpdate(option).catch((err) => console.log(err)));
program
.command('apikey-delete')
.description('delete apikey')
.option('--apikey <apikey>', 'apikey')
.action((
option,
) => apiKeyDelete(option).catch((err) => console.log(err)));
program
.command('apikey-get')
.description('get config of apikey')
.option('--apikey <apikey>', 'apikey')
.option('--all', 'get all apikey')
.action((
option,
) => apiKeyGet(option).catch((err) => console.log(err)));
program
.command('apikey-load')
.description('load the content of JSON file of apikey')
.option('--file <file>', 'filepath of JSON file of apikey')
.action((
option,
) => apiKeyLoad(option).catch((err) => console.log(err)));
program.parse(process.argv);