All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.arangodb.shaded.vertx.core.cli.CLI Maven / Gradle / Ivy

There is a newer version: 7.8.0
Show newest version
/*
 * Copyright (c) 2011-2019 Contributors to the Eclipse Foundation
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
 * which is available at https://www.apache.org/licenses/LICENSE-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
 */

package com.arangodb.shaded.vertx.core.cli;

import com.arangodb.shaded.vertx.codegen.annotations.Fluent;
import com.arangodb.shaded.vertx.codegen.annotations.GenIgnore;
import com.arangodb.shaded.vertx.codegen.annotations.Nullable;
import com.arangodb.shaded.vertx.codegen.annotations.VertxGen;
import com.arangodb.shaded.vertx.core.cli.annotations.CLIConfigurator;
import com.arangodb.shaded.vertx.core.cli.impl.DefaultCLI;

import java.util.List;

/**
 * Interface defining a command-line interface (in other words a command such as 'run', 'ls'...).
 * This interface is polyglot to ease reuse such as in Vert.x Shell.
 * 

* A command line interface has a name, and defines a set of options and arguments. Options are key-value pair such * as {@code -foo=bar} or {@code -flag}. The supported formats depend on the used parser. Arguments are unlike * options raw values. Options are defined using * {@link Option}, while argument are defined using {@link Argument}. *

* Command line interfaces also define a summary and a description. These attributes are used in the usage generation * . To disable the help generation, set the {@code hidden} attribute to {@code true}. *

* Command Line Interface object does not contains "value", it's a model. It must be evaluated by a * parser that returns a {@link CommandLine} object containing the argument and option values. * * @author Clement Escoffier * @see Argument * @see Option */ @VertxGen public interface CLI { /** * Creates an instance of {@link CLI} using the default implementation. * * @param name the name of the CLI (must not be {@code null}) * @return the created instance of {@link CLI} */ static CLI create(String name) { return new DefaultCLI().setName(name); } /** * Creates an instance of {@link CLI} from the given Java class. It instantiates the {@link CLI} object from the * annotations used in the class. * * @param clazz the annotated class * @return the created instance of {@link CLI} */ @GenIgnore static CLI create(Class clazz) { return CLIConfigurator.define(clazz); } /** * Parses the user command line interface and create a new {@link CommandLine} containing extracting values. * * @param arguments the arguments * @return the creates command line */ CommandLine parse(List arguments); /** * Parses the user command line interface and create a new {@link CommandLine} containing extracting values. * * @param arguments the arguments * @param validate enable / disable parsing validation * @return the creates command line */ CommandLine parse(List arguments, boolean validate); /** * @return the CLI name. */ String getName(); /** * Sets the name of the CLI. * * @param name the name * @return the current {@link CLI} instance */ @Fluent CLI setName(String name); /** * @return the CLI description. */ @Nullable String getDescription(); @Fluent CLI setDescription(String desc); /** * @return the CLI summary. */ @Nullable String getSummary(); /** * Sets the summary of the CLI. * * @param summary the summary * @return the current {@link CLI} instance */ @Fluent CLI setSummary(String summary); /** * Checks whether or not the current {@link CLI} instance is hidden. * * @return {@code true} if the current {@link CLI} is hidden, {@link false} otherwise */ boolean isHidden(); /** * Sets whether or not the current instance of {@link CLI} must be hidden. Hidden CLI are not listed when * displaying usages / help messages. In other words, hidden commands are for power user. * * @param hidden enables or disables the hidden aspect of the CI * @return the current {@link CLI} instance */ @Fluent CLI setHidden(boolean hidden); /** * Gets the list of options. * * @return the list of options, empty if none. */ List





© 2015 - 2024 Weber Informatics LLC | Privacy Policy