2020-11-19 19:41:48 +01:00
|
|
|
/*
|
2021-01-20 02:52:56 +01:00
|
|
|
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
|
|
|
* or more contributor license agreements. Licensed under the Elastic License
|
2021-02-04 03:12:39 +01:00
|
|
|
* 2.0 and the Server Side Public License, v 1; you may not use this file except
|
|
|
|
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
|
|
|
* Side Public License, v 1.
|
2020-11-19 19:41:48 +01:00
|
|
|
*/
|
|
|
|
|
2021-04-06 09:25:36 +02:00
|
|
|
import { kibanaPackageJson as pkg } from '@kbn/utils';
|
|
|
|
|
2020-11-19 19:41:48 +01:00
|
|
|
import Command from '../cli/command';
|
|
|
|
import { EncryptionConfig } from './encryption_config';
|
|
|
|
|
|
|
|
import { generateCli } from './generate';
|
|
|
|
|
2020-12-04 22:28:06 +01:00
|
|
|
const argv = process.argv.slice();
|
2020-11-19 19:41:48 +01:00
|
|
|
const program = new Command('bin/kibana-encryption-keys');
|
|
|
|
|
|
|
|
program.version(pkg.version).description('A tool for managing encryption keys');
|
|
|
|
|
|
|
|
const encryptionConfig = new EncryptionConfig();
|
|
|
|
|
|
|
|
generateCli(program, encryptionConfig);
|
|
|
|
|
|
|
|
program
|
|
|
|
.command('help <command>')
|
|
|
|
.description('Get the help for a specific command')
|
|
|
|
.action(function (cmdName) {
|
|
|
|
const cmd = Object.values(program.commands).find((command) => command._name === cmdName);
|
|
|
|
if (!cmd) return program.error(`unknown command ${cmdName}`);
|
|
|
|
cmd.help();
|
|
|
|
});
|
|
|
|
|
|
|
|
program.command('*', null, { noHelp: true }).action(function (cmd) {
|
|
|
|
program.error(`unknown command ${cmd}`);
|
|
|
|
});
|
|
|
|
|
|
|
|
// check for no command name
|
|
|
|
const subCommand = argv[2] && !String(argv[2][0]).match(/^-|^\.|\//);
|
|
|
|
if (!subCommand) {
|
|
|
|
program.defaultHelp();
|
|
|
|
}
|
|
|
|
|
|
|
|
program.parse(process.argv);
|