Skip to content

Commit cd1a7a9

Browse files
committed
New item work in progress
1 parent bdbe37a commit cd1a7a9

File tree

6 files changed

+86
-2
lines changed

6 files changed

+86
-2
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

index.js

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
const ArgumentParser = require('argparse').ArgumentParser;
2+
const childProcess = require('child_process');
3+
const fs = require('fs');
4+
5+
const parser = new ArgumentParser({
6+
version: '1.0.0',
7+
addHelp: true,
8+
description: 'Zotzen utility',
9+
});
10+
11+
parser.addArgument('--new', {
12+
action: 'storeTrue',
13+
help: 'Create a new document',
14+
});
15+
parser.addArgument('--title', { help: 'Create a new document' });
16+
17+
const args = parser.parseArgs();
18+
19+
const zoteroPrefix = 'node bin\\zotero-cli.js';
20+
21+
function runZoteroCommand(command) {
22+
return childProcess
23+
.execSync(`${zoteroPrefix} ${command}`, { cwd: 'zotero-cli' })
24+
.toString();
25+
}
26+
27+
if (args.new) {
28+
if (args.title) {
29+
const zoteroCreateItemTemplate = runZoteroCommand(
30+
'create-item --template report'
31+
);
32+
const templateJson = JSON.parse(zoteroCreateItemTemplate);
33+
templateJson.title = args.title;
34+
fs.writeFileSync('zotero-cli\\tmp', JSON.stringify(templateJson));
35+
runZoteroCommand(`create-item tmp`);
36+
fs.unlinkSync('zotero-cli\\tmp');
37+
console.log('Item successfully created.');
38+
}
39+
}

package-lock.json

+21
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "zotzen",
3+
"version": "1.0.0",
4+
"description": "Command line utility to go from Zotero to Zenodo",
5+
"main": "index.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "node index.js"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git+https://github.com/edtechhub/zotzen.git"
13+
},
14+
"author": "",
15+
"license": "ISC",
16+
"bugs": {
17+
"url": "https://github.com/edtechhub/zotzen/issues"
18+
},
19+
"homepage": "https://github.com/edtechhub/zotzen#readme",
20+
"dependencies": {
21+
"argparse": "^1.0.10"
22+
}
23+
}

zenodo-cli

0 commit comments

Comments
 (0)