-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.js
37 lines (30 loc) · 1.67 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
const { program } = require('commander');
const fetch = require('node-fetch');
const exportAppSearchEngine = require('./export-app-search-engine');
const importAppSearchEngine = require('./import-app-seach-engine');
async function main() {
program
.name('entsporter')
.description('CLI to import and export Elastic App Search engine settings')
.version('1.0.0');
program.command('export-app-search-engine')
.description('Export an App Search engine as JSON')
.argument('<engine-name>', 'Name of the App Search engine to export')
.requiredOption('--app-search-endpoint <value>', 'Must specify an App Search server endpoint, e.g. http://localhost:3002')
.requiredOption('--app-search-private-key <value>', 'Must specify an App Search private key')
.requiredOption('--output-json <value>', 'File to output the exported engine settings as JSON')
.action((engineName, options, command) => {
exportAppSearchEngine(engineName, options)
});
program.command('import-app-search-engine')
.description("Import an App Search engine's settings from JSON into a new engine.")
.argument('<engine-name>', 'Name of a new App Search engine to create with the specified engine settings')
.requiredOption('--app-search-endpoint <value>', 'Must specify an App Search server endpoint, e.g. http://localhost:3002')
.requiredOption('--app-search-private-key <value>', 'Must specify an App Search private key')
.requiredOption('--input-json <value>', 'File containing exported engine settings JSON')
.action((engineName, options, command) => {
importAppSearchEngine(engineName, options)
});
await program.parseAsync(process.argv);
}
main();