Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add epilog in commands help to link to arlas_cli documentation #47

Merged
merged 1 commit into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions arlas/cli/collections.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,15 @@ def configuration(config: str = typer.Option(default=None, help="Name of the ARL
variables["arlas"] = Configuration.solve_config(config)


@collections.command(help="List collections", name="list")
@collections.command(help="List collections", name="list", epilog=variables["help_epilog"])
def list_collections():
config = variables["arlas"]
collections = Service.list_collections(config)
__print_table(collections[0], collections[1:], sortby="name")


@collections.command(help="Count the number of hits within a collection (or all collection if not provided)")
@collections.command(help="Count the number of hits within a collection (or all collection if not provided)",
epilog=variables["help_epilog"])
def count(
collection: str = typer.Argument(default=None, help="Collection's name")
):
Expand All @@ -32,7 +33,7 @@ def count(
__print_table(count[0], count[1:], sortby="collection name")


@collections.command(help="Describe a collection")
@collections.command(help="Describe a collection", epilog=variables["help_epilog"])
def describe(
collection: str = typer.Argument(help="Collection's name")
):
Expand All @@ -44,7 +45,7 @@ def describe(
__print_table(fields[0], fields[1:], sortby=None)


@collections.command(help="Set collection visibility to public")
@collections.command(help="Set collection visibility to public", epilog=variables["help_epilog"])
def public(
collection: str = typer.Argument(help="Collection's name")
):
Expand All @@ -53,7 +54,7 @@ def public(
print("{} is {}".format(collection, "public" if ispublic else "private"))


@collections.command(help="Set collection visibility to private")
@collections.command(help="Set collection visibility to private", epilog=variables["help_epilog"])
def private(
collection: str = typer.Argument(help="Collection's name")
):
Expand All @@ -62,7 +63,7 @@ def private(
print("{} is {}".format(collection, "public" if ispublic else "private"))


@collections.command(help="Share the collection with the organisation")
@collections.command(help="Share the collection with the organisation", epilog=variables["help_epilog"])
def share(
collection: str = typer.Argument(help="Collection's name"),
organisation: str = typer.Argument(help="Organisation's name")
Expand All @@ -72,7 +73,7 @@ def share(
print("{} is shared with {}".format(collection, ", ".join(shared)))


@collections.command(help="Unshare the collection with the organisation")
@collections.command(help="Unshare the collection with the organisation", epilog=variables["help_epilog"])
def unshare(
collection: str = typer.Argument(help="Collection's name"),
organisation: str = typer.Argument(help="Organisation's name")
Expand All @@ -82,7 +83,7 @@ def unshare(
print("{} is shared with {}".format(collection, ", ".join(shared)))


@collections.command(help="Set the collection display name", name="name")
@collections.command(help="Set the collection display name", name="name", epilog=variables["help_epilog"])
def set_display_name(
collection: str = typer.Argument(help="Collection's name"),
name: str = typer.Argument(help="The display name")
Expand All @@ -92,7 +93,7 @@ def set_display_name(
print("{} display name is {}".format(collection, name))


@collections.command(help="Set the field display name", name="set_alias")
@collections.command(help="Set the field display name", name="set_alias", epilog=variables["help_epilog"])
def set_field_display_name(
collection: str = typer.Argument(help="Collection's name"),
field_path: str = typer.Argument(help="The field path"),
Expand All @@ -103,7 +104,7 @@ def set_field_display_name(
__print_table(fields[0], fields[1:], sortby=None)


@collections.command(help="Display a sample of a collection")
@collections.command(help="Display a sample of a collection", epilog=variables["help_epilog"])
def sample(
collection: str = typer.Argument(help="Collection's name"),
pretty: bool = typer.Option(default=True),
Expand All @@ -114,7 +115,7 @@ def sample(
print(json.dumps(sample.get("hits", []), indent=2 if pretty else None))


@collections.command(help="Delete a collection")
@collections.command(help="Delete a collection", epilog=variables["help_epilog"])
def delete(
collection: str = typer.Argument(help="collection's name")
):
Expand All @@ -128,7 +129,7 @@ def delete(
print("{} has been deleted on {}.".format(collection, config))


@collections.command(help="Create a collection")
@collections.command(help="Create a collection", epilog=variables["help_epilog"])
def create(
collection: str = typer.Argument(help="Collection's name"),
model: str = typer.Option(default=None, help="Name of the model within your configuration, or URL or file path"),
Expand Down
10 changes: 5 additions & 5 deletions arlas/cli/configurations.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
configurations = typer.Typer()


@configurations.command(help="List configurations", name="list")
@configurations.command(help="List configurations", name="list", epilog=variables["help_epilog"])
def list_configurations():
confs = []
for (name, conf) in Configuration.settings.arlas.items():
Expand All @@ -20,7 +20,7 @@ def list_configurations():
print(tab)


@configurations.command(help="Add a configuration", name="create")
@configurations.command(help="Add a configuration", name="create", epilog=variables["help_epilog"])
def create_configuration(
name: str = typer.Argument(help="Name of the configuration"),
server: str = typer.Option(help="ARLAS Server url"),
Expand Down Expand Up @@ -76,7 +76,7 @@ def create_configuration(
print("Configuration {} created.".format(name))


@configurations.command(help="Add a configuration for ARLAS Cloud", name="login")
@configurations.command(help="Add a configuration for ARLAS Cloud", name="login", epilog=variables["help_epilog"])
def login(
auth_login: str = typer.Argument(help="ARLAS login"),
elastic_login: str = typer.Argument(help="Elasticsearch login"),
Expand Down Expand Up @@ -130,7 +130,7 @@ def login(
print("{} is now your default configuration.".format(name))


@configurations.command(help="Delete a configuration", name="delete")
@configurations.command(help="Delete a configuration", name="delete", epilog=variables["help_epilog"])
def delete_configuration(
config: str = typer.Argument(help="Name of the configuration"),
):
Expand All @@ -143,7 +143,7 @@ def delete_configuration(
print("Configuration {} deleted.".format(config))


@configurations.command(help="Describe a configuration", name="describe")
@configurations.command(help="Describe a configuration", name="describe", epilog=variables["help_epilog"])
def describe_configuration(
config: str = typer.Argument(help="Name of the configuration"),
):
Expand Down
19 changes: 10 additions & 9 deletions arlas/cli/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def configuration(config: str = typer.Option(default=None, help="Name of the ARL
variables["arlas"] = Configuration.solve_config(config)


@indices.command(help="List indices", name="list")
@indices.command(help="List indices", name="list", epilog=variables["help_epilog"])
def list_indices():
config = variables["arlas"]
indices = Service.list_indices(config)
Expand All @@ -27,7 +27,7 @@ def list_indices():
print(f"Total count: {sum([int(index_info[2]) for index_info in indices[1:]])}")


@indices.command(help="Describe an index")
@indices.command(help="Describe an index", epilog=variables["help_epilog"])
def describe(
index: str = typer.Argument(help="index's name")
):
Expand All @@ -38,7 +38,7 @@ def describe(
print(tab)


@indices.command(help="Clone an index and set its name")
@indices.command(help="Clone an index and set its name", epilog=variables["help_epilog"])
def clone(
source: str = typer.Argument(help="Source index name"),
target: str = typer.Argument(help="Target cloned index name")
Expand All @@ -50,7 +50,8 @@ def clone(
print(tab)


@indices.command(help="Migrate an index on another arlas configuration, and set the target index name")
@indices.command(help="Migrate an index on another arlas configuration, and set the target index name",
epilog=variables["help_epilog"])
def migrate(
source: str = typer.Argument(help="Source index name"),
arlas_target: str = typer.Argument(help="Target ARLAS Configuration name"),
Expand All @@ -63,7 +64,7 @@ def migrate(
print(tab)


@indices.command(help="Display a sample of an index")
@indices.command(help="Display a sample of an index", epilog=variables["help_epilog"])
def sample(
index: str = typer.Argument(help="index's name"),
pretty: bool = typer.Option(default=True),
Expand All @@ -74,7 +75,7 @@ def sample(
print(json.dumps(sample["hits"].get("hits", []), indent=2 if pretty else None))


@indices.command(help="Create an index")
@indices.command(help="Create an index", epilog=variables["help_epilog"])
def create(
index: str = typer.Argument(help="index's name"),
mapping: str = typer.Option(help="Name of the mapping within your configuration, or URL or file path"),
Expand All @@ -96,7 +97,7 @@ def create(
print("Index {} created on {}".format(index, config))


@indices.command(help="Index data")
@indices.command(help="Index data", epilog=variables["help_epilog"])
def data(
index: str = typer.Argument(help="index's name"),
files: list[str] = typer.Argument(help="List of paths to the file(s) containing the data. Format: NDJSON"),
Expand All @@ -114,7 +115,7 @@ def data(
i = i + 1


@indices.command(help="Generate the mapping based on the data")
@indices.command(help="Generate the mapping based on the data", epilog=variables["help_epilog"])
def mapping(
file: str = typer.Argument(help="Path to the file containing the data. Format: NDJSON"),
nb_lines: int = typer.Option(default=2, help="Number of line to consider for generating the mapping. Avoid going over 10."),
Expand Down Expand Up @@ -150,7 +151,7 @@ def mapping(
print(json.dumps(mapping, indent=2))


@indices.command(help="Delete an index")
@indices.command(help="Delete an index", epilog=variables["help_epilog"])
def delete(
index: str = typer.Argument(help="index's name")
):
Expand Down
39 changes: 22 additions & 17 deletions arlas/cli/org.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
org = typer.Typer()


@org.command(help="List organisations", name="list")
@org.command(help="List organisations", name="list", epilog=variables["help_epilog"])
def list_organisations():
config = variables["arlas"]
organisations = Service.list_organisations(config)
Expand All @@ -17,19 +17,19 @@ def list_organisations():
print(tab)


@org.command(help="Create organisation with the given name", name="add")
@org.command(help="Create organisation with the given name", name="add", epilog=variables["help_epilog"])
def create_organisation(organisation: str = typer.Argument(help="Organisation's name")):
config = variables["arlas"]
print(Service.create_organisation(config, organisation).get("id"))


@org.command(help="Delete the organisation", name="delete")
@org.command(help="Delete the organisation", name="delete", epilog=variables["help_epilog"])
def delete_organisation(org_id: str = typer.Argument(help="Organisation's identifier")):
config = variables["arlas"]
print(Service.delete_organisation(config, org_id).get("message"))


@org.command(help="List the collections of the organisation", name="collections")
@org.command(help="List the collections of the organisation", name="collections", epilog=variables["help_epilog"])
def collections(org_id: str = typer.Argument(help="Organisation's identifier")):
config = variables["arlas"]
organisations = Service.list_organisation_collections(config, org_id)
Expand All @@ -39,7 +39,7 @@ def collections(org_id: str = typer.Argument(help="Organisation's identifier")):
print(tab)


@org.command(help="List the users of the organisation", name="users")
@org.command(help="List the users of the organisation", name="users", epilog=variables["help_epilog"])
def users(org_id: str = typer.Argument(help="Organisation's identifier")):
config = variables["arlas"]
users = Service.list_organisation_users(config, org_id)
Expand All @@ -48,22 +48,23 @@ def users(org_id: str = typer.Argument(help="Organisation's identifier")):
print(tab)


@org.command(help="Add a user to the organisation, and optionally within groups", name="add_user")
@org.command(help="Add a user to the organisation, and optionally within groups", name="add_user",
epilog=variables["help_epilog"])
def add_user(org_id: str = typer.Argument(help="Organisation's identifier"),
email: str = typer.Argument(help="User's email"),
group: list[str] = typer.Option([], help="Group identifier")):
config = variables["arlas"]
print(Service.add_user_in_organisation(config, org_id, email, group))


@org.command(help="Remove the user from the organisation", name="delete_user")
@org.command(help="Remove the user from the organisation", name="delete_user", epilog=variables["help_epilog"])
def delete_user(org_id: str = typer.Argument(help="Organisation's identifier"),
user_id: str = typer.Argument(help="User ID")):
config = variables["arlas"]
Service.delete_user_in_organisation(config, org_id, user_id)


@org.command(help="List the groups of the organisation", name="groups")
@org.command(help="List the groups of the organisation", name="groups", epilog=variables["help_epilog"])
def groups(org_id: str = typer.Argument(help="Organisation's identifier")):
config = variables["arlas"]
tab = PrettyTable(["id", "name", "description", "is technical", "type"], sortby="name", align="l")
Expand All @@ -74,7 +75,7 @@ def groups(org_id: str = typer.Argument(help="Organisation's identifier")):
print(tab)


@org.command(help="List the permissions of the organisation", name="permissions")
@org.command(help="List the permissions of the organisation", name="permissions", epilog=variables["help_epilog"])
def permissions(org_id: str = typer.Argument(help="Organisation's identifier")):
config = variables["arlas"]
groups = Service.list_organisation_permissions(config, org_id)
Expand All @@ -83,61 +84,65 @@ def permissions(org_id: str = typer.Argument(help="Organisation's identifier")):
print(tab)


@org.command(help="Add a group to the organisation", name="add_group")
@org.command(help="Add a group to the organisation", name="add_group", epilog=variables["help_epilog"])
def add_group(org_id: str = typer.Argument(help="Organisation's identifier"),
name: str = typer.Argument(help="Group name"),
description: str = typer.Argument(help="Group description")):
config = variables["arlas"]
print(Service.add_group_in_organisation(config, org_id, name, description).get("id"))


@org.command(help="Remove the group from the organisation", name="delete_group")
@org.command(help="Remove the group from the organisation", name="delete_group", epilog=variables["help_epilog"])
def delete_group(org_id: str = typer.Argument(help="Organisation's identifier"),
id: str = typer.Argument(help="Group ID")):
config = variables["arlas"]
print(Service.delete_group_in_organisation(config, org_id, id).get("message"))


@org.command(help="Add a permission to the organisation", name="add_permission")
@org.command(help="Add a permission to the organisation", name="add_permission", epilog=variables["help_epilog"])
def add_permission(org_id: str = typer.Argument(help="Organisation's identifier"),
value: str = typer.Argument(help="Permission value"),
description: str = typer.Argument(help="Permission description")):
config = variables["arlas"]
print(Service.add_permission_in_organisation(config, org_id, value, description).get("id"))


@org.command(help="Remove the permission from the organisation", name="delete_permission")
@org.command(help="Remove the permission from the organisation", name="delete_permission",
epilog=variables["help_epilog"])
def delete_permission(org_id: str = typer.Argument(help="Organisation's identifier"),
id: str = typer.Argument(help="Permission ID")):
config = variables["arlas"]
print(Service.delete_permission_in_organisation(config, org_id, id).get("message"))


@org.command(help="Add a permission to a group within the organisation", name="add_permission_to_group")
@org.command(help="Add a permission to a group within the organisation", name="add_permission_to_group",
epilog=variables["help_epilog"])
def add_permission_to_group(org_id: str = typer.Argument(help="Organisation's identifier"),
group_id: str = typer.Argument(help="Group identifier"),
permission_id: str = typer.Argument(help="Permission identifier")):
config = variables["arlas"]
print(Service.add_permission_to_group_in_organisation(config, org_id, group_id, permission_id))


@org.command(help="Remove a permission to a group within the organisation", name="delete_permission_from_group")
@org.command(help="Remove a permission to a group within the organisation", name="delete_permission_from_group",
epilog=variables["help_epilog"])
def delete_permission_from_group(organisation: str = typer.Argument(help="Organisation's identifier"),
group_id: str = typer.Argument(help="Group identifier"),
permission_id: str = typer.Argument(help="Permission identifier")):
config = variables["arlas"]
print(Service.delete_permission_from_group_in_organisation(config, organisation, group_id, permission_id))


@org.command(help="Add a user to a group within the organisation", name="add_user_to_group")
@org.command(help="Add a user to a group within the organisation", name="add_user_to_group",
epilog=variables["help_epilog"])
def add_user_to_group(org_id: str = typer.Argument(help="Organisation's identifier"),
user_id: str = typer.Argument(help="User identifier"),
group_id: str = typer.Argument(help="Group identifier")):
config = variables["arlas"]
print(Service.add_permission_to_group_in_organisation(config, org_id, user_id, group_id))


@org.command(help="Remove a user from a group within the organisation", name="delete_user_from_group")
@org.command(help="Remove a user from a group within the organisation", name="delete_user_from_group", epilog=variables["help_epilog"])
def delete_user_from_group(org_id: str = typer.Argument(help="Organisation's identifier"),
user_id: str = typer.Argument(help="User identifier"),
group_id: str = typer.Argument(help="Group identifier")):
Expand Down
Loading