forked from edtechhub/zotzen-cli
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp
More file actions
284 lines (270 loc) · 11.2 KB
/
temp
File metadata and controls
284 lines (270 loc) · 11.2 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
// DELETE FROM HERE
const parser_get = subparsers.add_parser("get", { "help": "The get command gets the ids listed, and writes these out to id1.json, id2.json etc. The id can be provided as a number, as a deposit URL or record URL" });
parser_get.add_argument("id", { "nargs": "*" });
parser_get.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_get.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_get.add_argument("--show", {
"action": "store_true",
"help": "Show key information for the deposition after executing the command.",
"default": false
});
parser_get.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_get.set_defaults({ "func": saveIdsToJson });
const parser_create = subparsers.add_parser("create", { "help": "The create command creates new records based on the json files provided, optionally providing a title / date / description / files." });
parser_create.add_argument("--json", {
"action": "store",
"help": "Path of the JSON file with the metadata for the zenodo record to be created. If this file is not provided, a template is used. The following options override settings from the JSON file / template."
});
parser_create.add_argument("--title", {
"action": "store",
"help": "The title of the record. Overrides data provided via --json."
});
parser_create.add_argument("--date", {
"action": "store",
"help": "The date of the record. Overrides data provided via --json."
});
parser_create.add_argument("--description", {
"action": "store",
"help": "The description (abstract) of the record. Overrides data provided via --json."
});
parser_create.add_argument("--communities", {
"action": "store",
"help": "Read list of communities for the record from a file. Overrides data provided via --json."
});
parser_create.add_argument("--add-communities", {
"nargs": "*",
"action": "store",
"help": "List of communities to be added to the record (provided on the command line, one by one). Overrides data provided via --json."
});
parser_create.add_argument("--remove-communities", {
"nargs": "*",
"action": "store",
"help": "List of communities to be removed from the record (provided on the command line, one by one). Overrides data provided via --json."
});
parser_create.add_argument("--authors", {
"nargs": "*",
"action": "store",
"help": "List of authors, (provided on the command line, one by one). Separate institution and ORCID with semicolon, e.g. 'Lama Yunis;University of XYZ;0000-1234-...'. (You can also use --authordata.) Overrides data provided via --json."
});
parser_create.add_argument("--authordata", {
"action": "store",
"help": "A text file with a database of authors. Each line has author, institution, ORCID (tab-separated). The data is used to supplement insitution/ORCID to author names specified with --authors. Note that authors are only added to the record when specified with --authors, not because they appear in the specified authordate file. "
});
parser_create.add_argument("--zotero-link", {
"action": "store",
"help": "Zotero link of the zotero record to be linked. Overrides data provided via --json."
});
parser_create.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_create.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_create.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_create.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_create.add_argument("--verbose", {
"action": "store_true",
"help": "Show response status after calling the API",
"default": false
});
parser_create.set_defaults({ "func": create });
const parser_duplicate = subparsers.add_parser("duplicate", { "help": "The duplicate command duplicates the id to a new id, optionally providing a title / date / description / files." });
parser_duplicate.add_argument("id", { "nargs": 1 });
parser_duplicate.add_argument("--title", { "action": "store" });
parser_duplicate.add_argument("--date", { "action": "store" });
parser_duplicate.add_argument("--files", { "nargs": "*" });
parser_duplicate.add_argument("--description", { "action": "store" });
parser_duplicate.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_duplicate.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_duplicate.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_duplicate.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_duplicate.set_defaults({ "func": duplicate });
const parser_update = subparsers.add_parser("update", { "help": "The update command updates the id provided, with the title / date / description / files provided." });
parser_update.add_argument("id", { "nargs": 1 });
parser_update.add_argument("--title", { "action": "store" });
parser_update.add_argument("--date", { "action": "store" });
parser_update.add_argument("--description", { "action": "store" });
parser_update.add_argument("--files", { "nargs": "*" });
parser_update.add_argument("--add-communities", { "nargs": "*" });
parser_update.add_argument("--remove-communities", { "nargs": "*" });
parser_update.add_argument("--zotero-link", {
"action": "store",
"help": "Zotero link of the zotero record to be linked."
});
parser_update.add_argument("--json", {
"action": "store",
"help": "Path of the JSON file with the metadata of the zenodo record to be updated."
});
parser_update.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_update.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_update.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_update.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_update.set_defaults({ "func": update });
const parser_upload = subparsers.add_parser("upload", { "help": "Just upload files (shorthand for update id --files ...)" });
parser_upload.add_argument("id", { "nargs": "?" });
parser_upload.add_argument("--bucketurl", { "action": "store" });
parser_upload.add_argument("files", { "nargs": "*" });
parser_upload.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_upload.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_upload.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_upload.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_upload.set_defaults({ "func": upload });
const parser_copy = subparsers.add_parser("multiduplicate", { "help": "Duplicates existing deposit with id multiple times, once for each file." });
parser_copy.add_argument("id", { "nargs": 1 });
parser_copy.add_argument("files", { "nargs": "*" });
parser_copy.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_copy.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_copy.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_copy.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_copy.set_defaults({ "func": copy });
const parser_newversion = subparsers.add_parser("newversion", { "help": "The newversion command creates a new version of the deposition with id, optionally providing a title / date / description / files." });
parser_newversion.add_argument("id", { "nargs": 1 });
parser_newversion.add_argument("--title", { "action": "store" });
parser_newversion.add_argument("--date", { "action": "store" });
parser_newversion.add_argument("--files", { "nargs": "*" });
parser_newversion.add_argument("--description", { "action": "store" });
parser_newversion.add_argument("--publish", {
"action": "store_true",
"help": "Publish the deposition after executing the command.",
"default": false
});
parser_newversion.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_newversion.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
parser_newversion.add_argument("--dump", {
"action": "store_true",
"help": "Show json for deposition after executing the command.",
"default": false
});
parser_newversion.set_defaults({ "func": newVersion });
const parser_download = subparsers.add_parser("download", { "help": "Download all the files in the deposition." });
parser_download.add_argument("id", { "nargs": 1 });
parser_download.set_defaults({ "func": download });
const parser_concept = subparsers.add_parser("concept", { "help": "Get the record id from a helper id." });
parser_concept.add_argument("id", { "nargs": 1 });
parser_concept.add_argument("--dump", {
"action": "store_true",
"help": "Show json for list and for depositions after executing the command.",
"default": false
});
parser_concept.add_argument("--open", {
"action": "store_true",
"help": "Open the deposition in the browser after executing the command.",
"default": false
});
parser_concept.add_argument("--show", {
"action": "store_true",
"help": "Show the info of the deposition after executing the command.",
"default": false
});
//parsing agrument.
parser_concept.set_defaults({ "func": concept });
var args = parser.parse_args();
//parser.parse_args();
if ((process.argv.length === 1)) {
parser.print_help();
process.exit(1);
}
//
// zenodo-cli create --title "..." --authors "..." --dryrun
const dryrun = false
if (dryrun) {
console.log(`API command:\n ZenodoAPI(${JSON.stringify(args)})`); // Make this pretty print.
} else {
}
// TO HERE ENDS