001/*
002 * SPDX-License-Identifier: Apache-2.0
003 *
004 * Copyright 2023-2026 The Enola <https://enola.dev> Authors
005 *
006 * Licensed under the Apache License, Version 2.0 (the "License");
007 * you may not use this file except in compliance with the License.
008 * You may obtain a copy of the License at
009 *
010 *     https://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018package dev.enola.cli;
019
020import dev.enola.cli.common.*;
021
022import picocli.AutoComplete;
023import picocli.CommandLine.Command;
024import picocli.CommandLine.HelpCommand;
025import picocli.CommandLine.Mixin;
026
027@Command(
028        name = "enola",
029        mixinStandardHelpOptions = true,
030        showDefaultValues = true,
031        synopsisSubcommandLabel = "COMMAND",
032        description = VersionProvider.DESCRIPTION,
033        versionProvider = VersionProvider.class,
034        subcommands = {
035            // Generic to all CLIs
036            HelpCommand.class,
037            AutoComplete.GenerateCompletion.class,
038
039            // Specific to this CLI
040            GenCommand.class,
041            DocGenCommand.class,
042            GetCommand.class,
043            RosettaCommand.class,
044            ServerCommand.class,
045            ExecMdCommand.class,
046            LoggingTestCommand.class,
047            LocaleTestCommand.class,
048            ExceptionTestCommand.class,
049            InfoCommand.class,
050            ValidateCommand.class,
051            CanonicalizeCommand.class,
052            FetchCommand.class,
053            ChatCommand.class,
054            Chat2Command.class,
055            AiCommand.class,
056            McpCommand.class,
057        })
058public class EnolaApplication extends Application {
059
060    @Mixin LoggingMixin loggingMixin;
061    @Mixin LocaleOption localeOption;
062
063    public static void main(String[] args) {
064        System.exit(cli(args).execute());
065    }
066
067    static CLI cli(String... args) {
068        return new CLI(args, new EnolaApplication());
069    }
070
071    @Override
072    protected void start() {
073        // TODO Move this (and LocaleOption localeOption) up into Application?
074        localeOption.initializeSINGLETON();
075
076        Configuration.setSingletons();
077    }
078}