-
Notifications
You must be signed in to change notification settings - Fork 2
/
fetchOntology.js
37 lines (34 loc) · 1009 Bytes
/
fetchOntology.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
OntologyVault = require('./lib/OntologyVault');
const minimist = require('minimist');
const path = require("path");
const fs = require("fs");
const vault = new OntologyVault();
const argOptions = {
string: ['prefix', 'url'],
alias: {
p: 'prefix',
u: 'url'
}
};
const argv = minimist(process.argv.slice(2), argOptions);
const prefices = JSON.parse(fs.readFileSync(path.resolve(__dirname, 'resources/ontologies/prefix.json'), 'utf8'));
if (argv.prefix) {
if (prefices[argv.prefix]) {
vault.fetchByUrl(prefices[argv.prefix], function (err, ontoTtlPath) {
console.log(`Written to ${ontoTtlPath}`);
});
}
else {
vault.fetchByPrefix(argv.prefix, function (err, ontoTtlPath) {
console.log(`Written to ${ontoTtlPath}`);
});
}
}
else if (argv.u) {
vault.fetchByUrl(argv.uri, function (err, ontoTtlPath) {
console.log(`Written to ${ontoTtlPath}`);
});
}
else {
console.log('Either provide `-p [prefix]` or `-u [URI]` to fetch an ontology into turtle!');
}