class PicoCliDelegate {

    public CliResult execute(String... args) throws Exception {
        LOGGER.debug("Execute with args [{}]", String.join(",", args));
        final CommandLine commandLine = new CommandLine(TesseraCommand.class);

        final CLIExceptionCapturer mapper = new CLIExceptionCapturer();

        commandLine.addSubcommand(new CommandLine(CommandLine.HelpCommand.class));
        commandLine.addSubcommand(new CommandLine(KeyGenCommand.class, new KeyGenCommandFactory()));
        commandLine.addSubcommand(new CommandLine(KeyUpdateCommand.class, new KeyUpdateCommandFactory()));

        commandLine
                .registerConverter(Config.class, new ConfigConverter())
                .registerConverter(ArgonOptions.class, new ArgonOptionsConverter())
                .setSeparator(" ")
                .setCaseInsensitiveEnumValuesAllowed(true)
                .setExecutionExceptionHandler(mapper)
                .setParameterExceptionHandler(mapper)
                .setStopAtUnmatched(false);

        final CommandLine.ParseResult parseResult;
        try {
            parseResult = commandLine.parseArgs(args);
        } catch (CommandLine.ParameterException ex) {
            try {
                commandLine.getParameterExceptionHandler().handleParseException(ex, args);
                throw new CliException(ex.getMessage());
            } catch (Exception e) {
                throw new CliException(ex.getMessage());
            }
        }

        if (CommandLine.printHelpIfRequested(parseResult)) {
            return new CliResult(0, true, null);
        }

        if (!parseResult.hasSubcommand()) {
            // the node is being started
            final Config config;
            try {
                config = getConfigFromCLI(parseResult);
            } catch (NoTesseraCmdArgsException e) {
                commandLine.execute("help");
                return new CliResult(0, true, null);
            } catch (NoTesseraConfigfileOptionException e) {
                throw new CliException("Missing required option '--configfile <config>'");
            }
            LOGGER.debug("Executed with args [{}]", String.join(",", args));
            LOGGER.trace("Config {}", JaxbUtil.marshalToString(config));
            return new CliResult(0, false, config);
        }

        // there is a subcommand

        // print help as no args provided
        if (args.length == 1) {
            final CommandLine.ParseResult subcommand = parseResult.subcommand();
            subcommand.asCommandLineList().get(0).execute("help");
            return new CliResult(0, true, null);
        }

        commandLine.execute(args);

        // if an exception occurred, throw it to to the upper levels where it gets handled
        if (mapper.getThrown() != null) {
            throw mapper.getThrown();
        }
        return new CliResult(0, true, null);
    }

    public  PicoCliDelegate();
    private  PicoCliDelegate(final KeyPasswordResolver keyPasswordResolver);

}