diff --git a/clients/cli/errors.sh b/clients/cli/bin/errors.sh similarity index 86% rename from clients/cli/errors.sh rename to clients/cli/bin/errors.sh index 9d0571742de..bc67633c06a 100644 --- a/clients/cli/errors.sh +++ b/clients/cli/bin/errors.sh @@ -41,9 +41,6 @@ gcli unknown list # Name not specified gcli metalake details -# Too many arguments -gcli metalake details more - # Unknown metalake name gcli metalake details --name unknown @@ -52,12 +49,3 @@ gcli catalog details --name metalake_demo.unknown # Unknown catalog name gcli catalog details --name metalake_demo - -# Already exists -gcli metalake create -name metalake_demo - -# Doesn't exist -gcli metalake delete -name unknown-metalake - -# Malformed name -gcli catalog details -name metalake_demo diff --git a/clients/cli/bin/examples.sh b/clients/cli/bin/examples.sh new file mode 100755 index 00000000000..bb8994e03eb --- /dev/null +++ b/clients/cli/bin/examples.sh @@ -0,0 +1,103 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +#!/bin/bash + +# These examples assume you have the Apache Gravitino playground running. + +unset GRAVITINO_METALAKE +alias gcli='java -jar clients/cli/build/libs/gravitino-cli-0.7.0-incubating-SNAPSHOT.jar' + +# display help +gcli --help + +# display version +gcli --version + +# metalake details +gcli --details + +# metalake list +gcli --list + +# list all catalogs in a metalake +gcli metalake --list --name metalake_demo + +# list catalog schema +gcli catalog --list --name metalake_demo.catalog_iceberg +gcli catalog --list --name metalake_demo.catalog_mysql +gcli catalog --list --name metalake_demo.catalog_postgres +gcli catalog --list --name metalake_demo.catalog_hive + +# list catalog details +gcli catalog --details --name metalake_demo.catalog_iceberg +gcli catalog --details --name metalake_demo.catalog_mysql +gcli catalog --details --name metalake_demo.catalog_postgres +gcli catalog --details --name metalake_demo.catalog_hive + +# list schema tables +gcli schema --list --name metalake_demo.catalog_postgres.hr +gcli schema --list --name metalake_demo.catalog_mysql.db +gcli schema --list --name metalake_demo.catalog_hive.sales + +# list schema details +gcli schema --details --name metalake_demo.catalog_postgres.hr +gcli schema --details --name metalake_demo.catalog_mysql.db +gcli schema --details --name metalake_demo.catalog_hive.sales + +# list table details +gcli table --list --name metalake_demo.catalog_postgres.hr.departments +gcli table --list --name metalake_demo.catalog_mysql.db.iceberg_tables +gcli table --list --name metalake_demo.catalog_hive.sales.products + +# Exmaples where metalake is set in an evironment variable +export GRAVITINO_METALAKE=metalake_demo + +# metalake details +gcli metalake --details + +# list all catalogs in a metalake +gcli metalake --list + +# list catalog schema +gcli catalog --list --name catalog_iceberg +gcli catalog --list --name catalog_mysql +gcli catalog --list --name catalog_postgres +gcli catalog --list --name catalog_hive + +# list catalog details +gcli catalog --details --name catalog_iceberg +gcli catalog --details --name catalog_mysql +gcli catalog --details --name catalog_postgres +gcli catalog --details --name catalog_hive + +# list schema tables +gcli schema --list --name catalog_postgres.hr +gcli schema --list --name catalog_mysql.db +gcli schema --list --name catalog_hive.sales + +# list schema details +gcli schema --details --name catalog_postgres.hr +gcli schema --details --name catalog_mysql.db +gcli schema --details --name catalog_hive.sales + +# list table details +gcli table --list --name catalog_postgres.hr.departments +gcli table --list --name catalog_mysql.db.iceberg_tables +gcli table --list --name catalog_hive.sales.products diff --git a/clients/cli/README.md b/clients/cli/docs/README.md similarity index 62% rename from clients/cli/README.md rename to clients/cli/docs/README.md index b4f7c2cfc88..f778615555c 100644 --- a/clients/cli/README.md +++ b/clients/cli/docs/README.md @@ -74,42 +74,29 @@ Before you can build and run this project, it is suggested you have the followin To run the Gravitino CLI, use the following command structure: ```bash -usage: gcli [metalake|catalog|schema|table] [list|details|create|delete|update|set|remove|properties] [options] +usage: gcli [metalake|catalog|schema|table] [list|details|create|delete|update] [options] +Options -b,--bootstrap Kafka bootstrap servers - -c,--catalog catalog name -C,--create create an entity + -c,--comment entity comment -D,--details list details about an entity -d,--database database name - -e,--entity entity type -h,--help command help information -j,--jdbcurl JDBC URL -L,--list list entity children + -l,--user database username -m,--metastore Hive metastore URI -n,--name full entity name (dot separated) -P,--properties show an entities properties - -p,--password database password - -R,--delete delete an entity + -p,--provider provider one of hadoop, hive, mysql, postgres, iceberg, kafka -r,--rename new entity name - -s,--schema schema name - -t,--table table name - -u,--user database username + -R,--delete delete an entity + -u,--url Gravitino URL (default: http://localhost:8090) -U,--update update an entity -v,--value property value -w,--warehouse warehouse name - -x,--command one of: list, details, create, delete, or update -``` - -The command line can be used in several ways to achieve the same results, depending on your preference. -```bash -gcli catalog details --name metalake_demo.catalog_postgres -gcli catalog --command details -name metalake_demo.catalog_postgres -gcli --entity catalog --command details -name metalake_demo.catalog_postgres -gcli catalog details --metalake metalake_demo --catalog catalog_postgres -gcli details --metalake metalake_demo --catalog catalog_postgres -gcli --metalake metalake_demo --catalog catalog_postgres -gcli --command details --metalake metalake_demo --catalog catalog_postgres + -z,--password database password ``` -The form `gcli [options]` is used in this document. ## Commands The following commands are available for entity management: @@ -130,55 +117,15 @@ gcli list Get Details of a Specific Metalake ```bash -gcli metalake details -name my_metalake +gcli metalake details -name my-metalake ``` List Tables in a Catalog ```bash -gcli metalake list -name my_metalake.my_catalog +gcli metalake list -name my-metalake.my-catalog ``` -Create a Metalake - -```bash -gcli metalake create -name my_metalake -comment "This is my metalake" -``` - -Create a Catalog - -```bash -gcli catalog create -name metalake_demo.iceberg --provider iceberg --metastore thrift://hive-host:9083 --warehouse hdfs://hdfs-host:9000/user/iceberg/warehouse -``` - -Delete a Catalog - -```bash -gcli catalog delete -name my_metalake.my_catalog -``` - -Rename a Metalake - -```bash -gcli metalake update -name metalake_demo -rename demo -``` - -Update a Metalake's comment - -```bash -gcli metalake update -name metalake_demo -comment "new comment" -``` - -### Setting Metalake name - -As dealing with one Metalake is a typical scenario, you can set the Metalake name in several ways. - -1. Passed in on the command line either as the first part of the entities name or via the `--metalake` parameter. -2. Set via the 'GRAVITINO_METALAKE' environment variable. -3. Placed in the Gravitino configuration file `~/.gravitino` by adding a line like `metalake=metalake_demo`. - -The command line option overrides the other options and the environment variable overrides the value in the configuration file. - ## Running Tests This project includes a suite of unit tests to verify its functionality. diff --git a/clients/cli/examples.sh b/clients/cli/examples.sh index 0cb8b4fe2f8..b4f85c293e2 100755 --- a/clients/cli/examples.sh +++ b/clients/cli/examples.sh @@ -158,4 +158,4 @@ gcli user delete --name metalake_demo --user new_user gcli group create --name metalake_demo --user new_group gcli group details --name metalake_demo --user new_group gcli group list --name metalake_demo -gcli group delete --name metalake_demo --user new_group \ No newline at end of file +gcli group delete --name metalake_demo --user new_group diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java b/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java index b5418fe3105..32aa118ae31 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/FullName.java @@ -52,11 +52,8 @@ public String getMetalakeName() { metalakeEnv = System.getenv("GRAVITINO_METALAKE"); } - // Check if the metalake name is specified as a command line option - if (line.hasOption(GravitinoOptions.METALAKE)) { - return line.getOptionValue(GravitinoOptions.METALAKE); - // Check if the metalake name is set as an environment variable - } else if (metalakeEnv != null) { + // Check if the metalake name is set as an environment variable + if (metalakeEnv != null) { return metalakeEnv; // Check if the metalake name is specified in the configuration file } else if (config.fileExists()) { @@ -76,46 +73,42 @@ public String getMetalakeName() { } /** - * Retrieves the catalog name from the command line or the second part of the full name option. + * Retrieves the catalog name from the second part of the full name option. * * @return The catalog name, or null if not found. */ public String getCatalogName() { - return getNamePart(GravitinoOptions.CATALOG, 1); + return getNamePart(1); } /** - * Retrieves the schema name from the command line or the third part of the full name option. + * Retrieves the schema name from the third part of the full name option. * * @return The schema name, or null if not found. */ public String getSchemaName() { - return getNamePart(GravitinoOptions.SCHEMA, 2); + return getNamePart(2); } /** - * Retrieves the table name from the command line or the fourth part of the full name option. + * Retrieves the table name from the fourth part of the full name option. * * @return The table name, or null if not found. */ public String getTableName() { - return getNamePart(GravitinoOptions.TABLE, 3); + return getNamePart(3); } /** * Helper method to retrieve a specific part of the full name based on the position of the part. * - * @param entity The part of the name to obtain. * @param position The position of the name part in the full name string. * @return The extracted part of the name, or {@code null} if the name part is missing or * malformed. */ - public String getNamePart(String entity, int position) { - /* Check if the name is specified as a command line option. */ - if (line.hasOption(entity)) { - return line.getOptionValue(entity); - /* Extract the name part from the full name if available. */ - } else if (line.hasOption(GravitinoOptions.NAME)) { + public String getNamePart(int position) { + /* Extract the name part from the full name if available. */ + if (line.hasOption(GravitinoOptions.NAME)) { String[] names = line.getOptionValue(GravitinoOptions.NAME).split("\\."); /* Adjust position if metalake is part of the full name. */ diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java index ef02481124c..25a0ecb2502 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoOptions.java @@ -28,13 +28,7 @@ public class GravitinoOptions { public static final String VERSION = "version"; public static final String SERVER = "server"; public static final String URL = "url"; - public static final String METALAKE = "metalake"; - public static final String CATALOG = "catalog"; - public static final String SCHEMA = "schema"; - public static final String TABLE = "table"; public static final String NAME = "name"; - public static final String ENTITY = "entity"; - public static final String COMMAND = "command"; public static final String LIST = "list"; public static final String DETAILS = "details"; public static final String CREATE = "create"; @@ -68,18 +62,9 @@ public Options options() { options.addOption(createSimpleOption("v", VERSION, "Gravitino client version")); options.addOption(createSimpleOption("r", SERVER, "Gravitino server version")); options.addOption(createArgOption("u", URL, "Gravitino URL (default: http://localhost:8090)")); - options.addOption(createArgOption("m", METALAKE, "metalake name")); - options.addOption(createArgOption("c", CATALOG, "catalog name")); - options.addOption(createArgOption("s", SCHEMA, "schema name")); - options.addOption(createArgOption("t", TABLE, "table name")); options.addOption(createArgOption("n", NAME, "full entity name (dot separated)")); - options.addOption(createArgOption("e", ENTITY, "entity type")); - // One way of specifying the command - options.addOption( - createArgOption("x", COMMAND, "one of: list, details, create, delete, or update")); - - // Another way of specifying the command + // specifying the command options.addOption(createSimpleOption("L", LIST, "list entity children")); options.addOption(createSimpleOption("D", DETAILS, "list details about an entity")); options.addOption(createSimpleOption("C", CREATE, "create an entity")); @@ -89,7 +74,7 @@ public Options options() { // Create/update options options.addOption(createArgOption("r", RENAME, "new entity name")); - options.addOption(createArgOption("d", COMMENT, "entity comment")); + options.addOption(createArgOption("c", COMMENT, "entity comment")); options.addOption(createArgOption("p", PROPERTY, "property name")); options.addOption(createArgOption("v", VALUE, "property value")); options.addOption( @@ -99,8 +84,8 @@ public Options options() { options.addOption(createArgOption("w", WAREHOUSE, "warehouse name")); options.addOption(createArgOption("b", BOOTSTRAP, "Kafka bootstrap servers")); options.addOption(createArgOption("j", JDBCURL, "JDBC URL")); - options.addOption(createArgOption("u", USER, "database username")); - options.addOption(createArgOption("p", PASSWORD, "database password")); + options.addOption(createArgOption("l", USER, "database username")); + options.addOption(createArgOption("z", PASSWORD, "database password")); options.addOption(createArgOption("d", DATABASE, "database name")); options.addOption(createArgOption("g", GROUP, "group name")); diff --git a/clients/cli/src/main/java/org/apache/gravitino/cli/Main.java b/clients/cli/src/main/java/org/apache/gravitino/cli/Main.java index 62196c2368b..2a437684839 100644 --- a/clients/cli/src/main/java/org/apache/gravitino/cli/Main.java +++ b/clients/cli/src/main/java/org/apache/gravitino/cli/Main.java @@ -40,7 +40,7 @@ public static void main(String[] args) { return; } String command = resolveCommand(line); - String entity = resolveEntity(line, command != null); + String entity = resolveEntity(line); GravitinoCommandLine commandLine = new GravitinoCommandLine(line, options, entity, command); commandLine.handleCommandLine(); } catch (ParseException exp) { @@ -56,15 +56,7 @@ public static void main(String[] args) { * @return The command, one of 'details', 'list', 'create', 'delete' or 'update'. */ protected static String resolveCommand(CommandLine line) { - /* Can be specified in the form --command XXX. */ - if (line.hasOption(GravitinoOptions.COMMAND)) { - String command = line.getOptionValue(GravitinoOptions.COMMAND); - if (CommandActions.isValidCommand(command)) { - return command; - } - } - - /* Or as --list, --details --create --delete or --update. */ + /* Passed as --list, --details --create --delete or --update. */ if (line.hasOption(GravitinoOptions.LIST)) { return CommandActions.LIST; } else if (line.hasOption(GravitinoOptions.DETAILS)) { @@ -77,65 +69,29 @@ protected static String resolveCommand(CommandLine line) { return CommandActions.UPDATE; } - /* Or as the first command or bare second argument of two arguments. */ - String[] args = line.getArgs(); - - if (args.length == 1 || args.length == 2) { - String command = args[args.length - 1]; - if (CommandActions.isValidCommand(command)) { - return command; - } else { - System.err.println(ErrorMessages.UNSUPPORTED_COMMAND); - return null; - } - } else { - return CommandActions.DETAILS; /* Default to 'details' command. */ - } + return CommandActions.DETAILS; /* Default to 'details' command. */ } /** * Determines the entity to act upon based on the command line input. * * @param line Parsed command line object. - * @param command true if command is an argument * @return The entity, e.g. metakalake, catalog, schema, table, etc. */ - protected static String resolveEntity(CommandLine line, boolean command) { - /* Can be specified in the form --entity XXX. */ - if (line.hasOption(GravitinoOptions.ENTITY)) { - String entity = line.getOptionValue(GravitinoOptions.ENTITY); - if (CommandEntities.isValidEntity(entity)) { - return entity; - } - } - - /* Or as --metalake, --catalog, --schema, --table etc. */ - if (line.hasOption(GravitinoOptions.TABLE)) { - return CommandEntities.TABLE; - } else if (line.hasOption(GravitinoOptions.SCHEMA)) { - return CommandEntities.SCHEMA; - } else if (line.hasOption(GravitinoOptions.CATALOG)) { - return CommandEntities.CATALOG; - } else if (line.hasOption(GravitinoOptions.METALAKE)) { - return CommandEntities.METALAKE; - } - - /* Or as the bare first argument of one or two arguments. */ + protected static String resolveEntity(CommandLine line) { + /* As the bare first argument. */ String[] args = line.getArgs(); - String entity = args[0]; - if (args.length == 1) { - if (CommandActions.isValidCommand(args[0])) { - return null; /* But not an error. */ + if (args.length > 0) { + String entity = args[0]; + if (CommandEntities.isValidEntity(entity)) { + return entity; + } else { + System.err.println(ErrorMessages.UNKNOWN_ENTITY); + return null; } } - if (CommandEntities.isValidEntity(entity)) { - return entity; - } else { - System.err.println(ErrorMessages.UNKNOWN_ENTITY); - } - return null; } } diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java index 448ab2dbf6c..541c1e45f51 100644 --- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java +++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestFulllName.java @@ -19,11 +19,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; -import static org.junit.jupiter.api.Assertions.assertThrows; import org.apache.commons.cli.CommandLine; import org.apache.commons.cli.DefaultParser; -import org.apache.commons.cli.MissingArgumentException; import org.apache.commons.cli.Options; import org.apache.gravitino.cli.FullName; import org.apache.gravitino.cli.GravitinoOptions; @@ -39,16 +37,6 @@ public void setUp() { options = new GravitinoOptions().options(); } - @Test - public void entityFromCommandLineOption() throws Exception { - String[] args = {"--metalake", "metalake_demo"}; - CommandLine commandLine = new DefaultParser().parse(options, args); - FullName fullName = new FullName(commandLine); - - String metalakeName = fullName.getMetalakeName(); - assertEquals("metalake_demo", metalakeName); - } - @Test public void entityFromFullNameOption() throws Exception { String[] args = {"--name", "metalakeA.catalogB.schemaC.tableD"}; @@ -76,44 +64,7 @@ public void entityNotFound() throws Exception { } @Test - public void justName() throws Exception, MissingArgumentException { - String[] args = {"--name"}; - - assertThrows(MissingArgumentException.class, () -> new DefaultParser().parse(options, args)); - } - - @Test - public void catalogFromCommandLineOption() throws Exception { - String[] args = {"--catalog", "catalogA"}; - CommandLine commandLine = new DefaultParser().parse(options, args); - FullName fullName = new FullName(commandLine); - - String catalogName = fullName.getCatalogName(); - assertEquals("catalogA", catalogName); - } - - @Test - public void schemaFromCommandLineOption() throws Exception { - String[] args = {"--schema", "schemaA"}; - CommandLine commandLine = new DefaultParser().parse(options, args); - FullName fullName = new FullName(commandLine); - - String schemaName = fullName.getSchemaName(); - assertEquals("schemaA", schemaName); - } - - @Test - public void tableFromCommandLineOption() throws Exception { - String[] args = {"--table", "tableA"}; - CommandLine commandLine = new DefaultParser().parse(options, args); - FullName fullName = new FullName(commandLine); - - String tableName = fullName.getTableName(); - assertEquals("tableA", tableName); - } - - @Test - public void malformedMissingEntityName() throws Exception { + public void malformedName() throws Exception { String[] args = {"--name", "metalake.catalog"}; CommandLine commandLine = new DefaultParser().parse(options, args); FullName fullName = new FullName(commandLine); @@ -136,7 +87,7 @@ public void missingName() throws Exception { CommandLine commandLine = new DefaultParser().parse(options, args); FullName fullName = new FullName(commandLine); - String namePart = fullName.getNamePart(GravitinoOptions.TABLE, 3); + String namePart = fullName.getNamePart(3); assertNull(namePart); } } diff --git a/clients/cli/src/test/java/org/apache/gravitino/cli/TestMain.java b/clients/cli/src/test/java/org/apache/gravitino/cli/TestMain.java index 4ea720f338a..3187c611706 100644 --- a/clients/cli/src/test/java/org/apache/gravitino/cli/TestMain.java +++ b/clients/cli/src/test/java/org/apache/gravitino/cli/TestMain.java @@ -53,29 +53,16 @@ public void restoreStreams() { System.setErr(originalErr); } - @Test - public void withCommandParameters() throws ParseException { - Options options = new GravitinoOptions().options(); - CommandLineParser parser = new DefaultParser(); - String[] args = {"--entity", "metalake", "--command", "list"}; - CommandLine line = parser.parse(options, args); - - String command = Main.resolveCommand(line); - assertEquals(CommandActions.LIST, command); - String entity = Main.resolveEntity(line, false); - assertEquals(CommandEntities.METALAKE, entity); - } - @Test public void withTwoArgsOnly() throws ParseException { Options options = new GravitinoOptions().options(); CommandLineParser parser = new DefaultParser(); - String[] args = {"metalake", "details"}; + String[] args = {"metalake", "--details"}; CommandLine line = parser.parse(options, args); String command = Main.resolveCommand(line); assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, true); + String entity = Main.resolveEntity(line); assertEquals(CommandEntities.METALAKE, entity); } @@ -83,12 +70,12 @@ public void withTwoArgsOnly() throws ParseException { public void defaultToDetails() throws ParseException { Options options = new GravitinoOptions().options(); CommandLineParser parser = new DefaultParser(); - String[] args = {"--metalake", "metalake_demo"}; + String[] args = {"metalake", "--name", "metalake_demo"}; CommandLine line = parser.parse(options, args); String command = Main.resolveCommand(line); assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, false); + String entity = Main.resolveEntity(line); assertEquals(CommandEntities.METALAKE, entity); } @@ -117,59 +104,16 @@ public void parseError() throws UnsupportedEncodingException { assertTrue(outContent.toString().contains("usage:")); // Expect help output } - @Test - public void catalogWithTwoArgs() throws ParseException { - Options options = new GravitinoOptions().options(); - CommandLineParser parser = new DefaultParser(); - String[] args = {"catalog", "details", "--name", "metalake_demo.catalog_postgres"}; - CommandLine line = parser.parse(options, args); - - String command = Main.resolveCommand(line); - assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, true); - assertEquals(CommandEntities.CATALOG, entity); - } - @Test public void catalogWithOneArg() throws ParseException { Options options = new GravitinoOptions().options(); CommandLineParser parser = new DefaultParser(); - String[] args = {"catalog", "--command", "details", "--name", "metalake_demo.catalog_postgres"}; - CommandLine line = parser.parse(options, args); - - String command = Main.resolveCommand(line); - assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, true); - assertEquals(CommandEntities.CATALOG, entity); - } - - @Test - public void catalogWithEntity() throws ParseException { - Options options = new GravitinoOptions().options(); - CommandLineParser parser = new DefaultParser(); - String[] args = { - "--entity", "catalog", "--command", "details", "--name", "metalake_demo.catalog_postgres" - }; - CommandLine line = parser.parse(options, args); - - String command = Main.resolveCommand(line); - assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, false); - assertEquals(CommandEntities.CATALOG, entity); - } - - @Test - public void catalogWithNoName() throws ParseException { - Options options = new GravitinoOptions().options(); - CommandLineParser parser = new DefaultParser(); - String[] args = { - "catalog", "details", "--metalake", "metalake_demo", "--catalog", "catalog_postgres" - }; + String[] args = {"catalog", "--details", "--name", "metalake_demo.catalog_postgres"}; CommandLine line = parser.parse(options, args); String command = Main.resolveCommand(line); assertEquals(CommandActions.DETAILS, command); - String entity = Main.resolveEntity(line, true); + String entity = Main.resolveEntity(line); assertEquals(CommandEntities.CATALOG, entity); } }