diff --git a/pom.xml b/pom.xml index cb0dfda..382b52d 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ https://sonarcloud.io 1.2.8 - 1.4.3 + 1.4.5 2.4.1 3.0.0 2.0.13 @@ -122,6 +122,20 @@ ${awaitibility.version} test + + + + com.github.rvesse + airline-help-markdown + ${airline.version} + test + + + com.github.rvesse + airline-help-html + ${airline.version} + test + diff --git a/src/main/java/com/dtsx/astra/cli/db/collection/ServiceCollection.java b/src/main/java/com/dtsx/astra/cli/db/collection/ServiceCollection.java index 347d28d..8b6ee50 100644 --- a/src/main/java/com/dtsx/astra/cli/db/collection/ServiceCollection.java +++ b/src/main/java/com/dtsx/astra/cli/db/collection/ServiceCollection.java @@ -175,7 +175,8 @@ public void listEmbeddingProviders(String databaseName) { Map myCollec = dbDao .getDataAPIDatabase(databaseName) .getDatabaseAdmin() - .listEmbeddingProviders(); + .findEmbeddingProviders() + .getEmbeddingProviders(); for (Map.Entry entry : myCollec.entrySet()) { EmbeddingProvider vOptions = entry.getValue(); Map rf = new HashMap<>(); @@ -312,7 +313,8 @@ public void describeEmbeddingProvider(String databaseName, String key) { Map providers = dbDao .getDataAPIDatabase(databaseName) .getDatabaseAdmin() - .listEmbeddingProviders(); + .findEmbeddingProviders() + .getEmbeddingProviders(); if (!providers.containsKey(key)) { throw new IllegalArgumentException("Embedding provider '" + key + "' has not been found"); } diff --git a/src/test/java/com/dtsx/astra/cli/docs/MarkDownDocumentationGenerator.java b/src/test/java/com/dtsx/astra/cli/docs/MarkDownDocumentationGenerator.java new file mode 100644 index 0000000..6e0b111 --- /dev/null +++ b/src/test/java/com/dtsx/astra/cli/docs/MarkDownDocumentationGenerator.java @@ -0,0 +1,29 @@ +package com.dtsx.astra.cli.docs; + +import com.dtsx.astra.cli.AstraCli; +import com.github.rvesse.airline.Cli; +import com.github.rvesse.airline.help.GlobalUsageGenerator; +import com.github.rvesse.airline.help.markdown.MarkdownMultiPageGlobalUsageGenerator; +import org.junit.jupiter.api.Test; + +import java.io.FileOutputStream; +import java.io.IOException; + +public class MarkDownDocumentationGenerator { + + @Test + public void generateMDDocumentation() { + Cli cli = new Cli<>(AstraCli.class); + + GlobalUsageGenerator helpGenerator = new MarkdownMultiPageGlobalUsageGenerator<>(); + try { + //helpGenerator.usage(cli.getMetadata(), System.out); + + FileOutputStream out = new FileOutputStream("cli.md"); + helpGenerator.usage(cli.getMetadata(), out); + + } catch (IOException e) { + e.printStackTrace(); + } + } +} diff --git a/src/test/java/com/dtsx/astra/cli/test/db/DbCollectionsTest.java b/src/test/java/com/dtsx/astra/cli/test/db/DbCollectionsTest.java index c5543c1..a39ee8d 100644 --- a/src/test/java/com/dtsx/astra/cli/test/db/DbCollectionsTest.java +++ b/src/test/java/com/dtsx/astra/cli/test/db/DbCollectionsTest.java @@ -30,7 +30,6 @@ public void shouldShowHelp() { assertSuccessCli("help db delete-collection"); assertSuccessCli("help db create-collection"); assertSuccessCli("help db list-collections"); - } @Test @@ -99,7 +98,6 @@ public void shouldCleanCollections() { assertSuccessCli("db delete-collection %s --collection %s".formatted(DB_TEST_VECTOR, TEST_COLLECTION_VECTOR)); } - @Test @Order(9) public void shouldFindEmbeddingProvider() { @@ -113,7 +111,9 @@ public void shouldDescriptionEmbeddingProvider() { // ("db describe-embedding-provider %s --embedding-provider %s" // .formatted(DB_TEST_VECTOR, "invalid"))); - assertSuccessCli("db describe-embedding-provider %s --embedding-provider %s --output json" + assertSuccessCli("help db describe-embedding-provider"); + + assertSuccessCli("db describe-embedding-provider %s --embedding-provider %s" .formatted(DB_TEST_VECTOR, "openai")); } diff --git a/src/test/java/com/dtsx/astra/cli/test/db/DbCommandsTest.java b/src/test/java/com/dtsx/astra/cli/test/db/DbCommandsTest.java index b94f064..75ff51d 100644 --- a/src/test/java/com/dtsx/astra/cli/test/db/DbCommandsTest.java +++ b/src/test/java/com/dtsx/astra/cli/test/db/DbCommandsTest.java @@ -37,6 +37,7 @@ static void should_create_when_needed() { assertSuccessCli("db create %s --if-not-exist --vector".formatted(DB_TEST_VECTOR)); } + @Test @Order(1) void testShouldShowHelp() { diff --git a/src/test/java/com/dtsx/astra/cli/test/db/DbRegionsTest.java b/src/test/java/com/dtsx/astra/cli/test/db/DbRegionsTest.java index 85783a3..9e3362b 100644 --- a/src/test/java/com/dtsx/astra/cli/test/db/DbRegionsTest.java +++ b/src/test/java/com/dtsx/astra/cli/test/db/DbRegionsTest.java @@ -25,6 +25,7 @@ void listRegionsTest() { @Test void shouldThrowRegionAlreadyExistTest() { assertExitCodeCli(ALREADY_EXIST, "db create-region %s -r us-east1 -c gcp".formatted(DB_TEST)); + } @Test diff --git a/src/test/resources/usage.MD b/src/test/resources/usage.MD new file mode 100644 index 0000000..f821343 --- /dev/null +++ b/src/test/resources/usage.MD @@ -0,0 +1,305 @@ +# NAME + +`astra` - CLI for DataStax Astraâ„¢ + +# SYNOPSIS + +`astra` [ *group* ] *command* [ *command-args* ] + +# COMMANDS + +- `?` + + Display this help version + +- `help` + + Display help information + +- `login` + + Authenticate against Astra. + +- `setup` + + Initialize configuration file + +- `config create` + + Create a new section in configuration + +- `config delete` + + Delete section in configuration + +- `config describe` + + Show details for a configuration. + +- `config get` + + Show details for a configuration. + +- `config list` + + Show the list of available configurations. + +- `config use` + + Make a section the one used by default + +- `db count` + + Count items for a table, a query + +- `db cqlsh` + + Start Cqlsh + +- `db create` + + Create a database with cli + +- `db create-cdc` + + Create a CDC to pulsar + +- `db create-collection` + + Create a new collection + +- `db create-dotenv` + + Generate an .env configuration file associate with the db + +- `db create-keyspace` + + Create a new keyspace + +- `db create-region` + + Expand database to a new region + +- `db delete` + + Delete an existing database + +- `db delete-cdc` + + Delete a CDC connection + +- `db delete-collection` + + Delete an existing collection + +- `db delete-keyspace` + + Delete an existing keyspace + +- `db delete-region` + + Delete a region from a database + +- `db describe` + + Show details of a database + +- `db describe-collection` + + Describe an existing collection + +- `db describe-embedding-provider` + + Describe an existing embedding provider + +- `db download-scb` + + Download secure connect bundle archive for a region + +- `db get` + + Show details of a database + +- `db get-endpoint-api` + + Open the json api endpoint + +- `db get-endpoint-playground` + + Expand database to a new region + +- `db get-endpoint-swagger` + + Open the swagger user interface + +- `db list` + + Display the list of Databases in an organization + +- `db list-cdc` + + List CDC available on this databse + +- `db list-clouds` + + Show available clouds + +- `db list-collections` + + Display the list of collections in an database + +- `db list-embedding-providers` + + Display the list of embedding providers in an database + +- `db list-keyspaces` + + Display the list of Keyspaces in an database + +- `db list-regions` + + List regions for a database + +- `db list-regions-classic` + + Show available regions (classic). + +- `db list-regions-serverless` + + Show available regions (serverless). + +- `db list-regions-vector` + + Show available regions (vector). + +- `db load` + + Load data leveraging DSBulk + +- `db resume` + + Resume a db if needed + +- `db status` + + Show status of a database + +- `db unload` + + Unload data leveraging DSBulk + +- `org get` + + Show details of an organization + +- `org id` + + Show organization id. + +- `org name` + + Show organization name. + +- `role describe` + + Show role details + +- `role get` + + Show role details + +- `role list` + + Display the list of Roles in an organization + +- `streaming create` + + Create a tenant in streaming with cli + +- `streaming create-dotenv` + + Generate an .env configuration file associate with the tenant + +- `streaming delete` + + Delete an existing tenant + +- `streaming describe` + + Show details of a tenant + +- `streaming exist` + + Show existence of a tenant + +- `streaming get` + + Show details of a tenant + +- `streaming list` + + Display the list of Tenant in an organization + +- `streaming list-cdc` + + List CDC available on this tenant + +- `streaming list-clouds` + + Display the list of clouds + +- `streaming list-regions` + + Display the list of Tenant in an organization + +- `streaming pulsar-shell` + + Start pulsar admin against your tenant + +- `streaming pulsar-token` + + Show status of a tenant + +- `streaming status` + + Show status of a tenant + +- `token create` + + Display the list of tokens in an organization + +- `token delete` + + Delete a token + +- `token get` + + Show current token + +- `token list` + + Display the list of tokens in an organization + +- `token revoke` + + Revoke a token (delete) + +- `user delete` + + Delete an existing user + +- `user describe` + + Show user details + +- `user get` + + Show user details + +- `user invite` + + Invite a user to an organization + +- `user list` + + Display the list of Users in an organization \ No newline at end of file