Skip to content
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
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[MAIN]
disable=missing-module-docstring, missing-class-docstring, missing-function-docstring
disable=missing-module-docstring, missing-class-docstring, missing-function-docstring, too-many-arguments, too-many-positional-arguments
max-line-length=120
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## v0.1.6 - 2025-16-01

### Features

- New watch option for exists command, e.g: `cube exists <cube_name> --watch`

## v0.1.5 - 2025-16-01

### Features
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ tm1cli process dump <name> --folder <path> --format <json|yaml>
tm1cli process load <name> --folder <path> --format <json|yaml>

tm1cli cube list
tm1cli cube exists <cube_name>
tm1cli cube exists <cube_name> --watch

tm1cli dimension list
tm1cli dimension exists <dimension_name>
tm1cli dimension exists <dimension_name> -w

tm1cli view list <cube_name>
tm1cli view exists <cube_name> <view_name>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tm1cli"
version = "0.1.5"
version = "0.1.6"
description = "A command-line interface (CLI) tool for interacting with TM1 servers using TM1py."
authors = ["onefloid <onefloid@gmx.de>"]
license = "MIT License"
Expand Down
6 changes: 5 additions & 1 deletion tm1cli/commands/cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from rich import print # pylint: disable=redefined-builtin
from TM1py.Services import TM1Service

from tm1cli.utils.cli_param import DATABASE_OPTION
from tm1cli.utils.cli_param import DATABASE_OPTION, INTERVAL_OPTION, WATCH_OPTION
from tm1cli.utils.various import resolve_database
from tm1cli.utils.watch import watch_option

app = typer.Typer()

Expand Down Expand Up @@ -34,10 +35,13 @@ def list_cube(


@app.command()
@watch_option
def exists(
ctx: typer.Context,
cube_name: str,
database: Annotated[str, DATABASE_OPTION] = None,
watch: Annotated[bool, WATCH_OPTION] = False, # pylint: disable=unused-argument
interval: Annotated[int, INTERVAL_OPTION] = 5, # pylint: disable=unused-argument
):
"""
Check if cube exists
Expand Down
6 changes: 5 additions & 1 deletion tm1cli/commands/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from rich import print # pylint: disable=redefined-builtin
from TM1py.Services import TM1Service

from tm1cli.utils.cli_param import DATABASE_OPTION
from tm1cli.utils.cli_param import DATABASE_OPTION, INTERVAL_OPTION, WATCH_OPTION
from tm1cli.utils.various import resolve_database
from tm1cli.utils.watch import watch_option

app = typer.Typer()

Expand Down Expand Up @@ -34,10 +35,13 @@ def list_dimension(


@app.command()
@watch_option
def exists(
ctx: typer.Context,
dimension_name: str,
database: Annotated[str, DATABASE_OPTION] = None,
watch: Annotated[bool, WATCH_OPTION] = False, # pylint: disable=unused-argument
interval: Annotated[int, INTERVAL_OPTION] = 5, # pylint: disable=unused-argument
):
"""
Check if dimension exists
Expand Down
6 changes: 5 additions & 1 deletion tm1cli/commands/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
from TM1py.Services import TM1Service
from typing_extensions import Annotated

from tm1cli.utils.cli_param import DATABASE_OPTION
from tm1cli.utils.cli_param import DATABASE_OPTION, INTERVAL_OPTION, WATCH_OPTION
from tm1cli.utils.tm1yaml import dump_process, load_process
from tm1cli.utils.various import print_error_and_exit, resolve_database
from tm1cli.utils.watch import watch_option

app = typer.Typer()

Expand Down Expand Up @@ -38,10 +39,13 @@ def list_process(


@app.command()
@watch_option
def exists(
ctx: typer.Context,
name: str,
database: Annotated[str, DATABASE_OPTION] = None,
watch: Annotated[bool, WATCH_OPTION] = False, # pylint: disable=unused-argument
interval: Annotated[int, INTERVAL_OPTION] = 5, # pylint: disable=unused-argument
):
"""
Shows if process exists
Expand Down
6 changes: 5 additions & 1 deletion tm1cli/commands/subset.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from rich import print # pylint: disable=redefined-builtin
from TM1py.Services import TM1Service

from tm1cli.utils.cli_param import DATABASE_OPTION
from tm1cli.utils.cli_param import DATABASE_OPTION, INTERVAL_OPTION, WATCH_OPTION
from tm1cli.utils.various import resolve_database
from tm1cli.utils.watch import watch_option

app = typer.Typer()

Expand All @@ -28,6 +29,7 @@ def list_subset(


@app.command()
@watch_option
def exists(
ctx: typer.Context,
dimension_name: str,
Expand All @@ -36,6 +38,8 @@ def exists(
bool, typer.Option("-p", "--private", help="Flag to specify if view is private")
] = False,
database: Annotated[str, DATABASE_OPTION] = None,
watch: Annotated[bool, WATCH_OPTION] = False, # pylint: disable=unused-argument
interval: Annotated[int, INTERVAL_OPTION] = 5, # pylint: disable=unused-argument
):
"""
Check if subset exists
Expand Down
6 changes: 5 additions & 1 deletion tm1cli/commands/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
from rich import print # pylint: disable=redefined-builtin
from TM1py.Services import TM1Service

from tm1cli.utils.cli_param import DATABASE_OPTION
from tm1cli.utils.cli_param import DATABASE_OPTION, INTERVAL_OPTION, WATCH_OPTION
from tm1cli.utils.various import resolve_database
from tm1cli.utils.watch import watch_option

app = typer.Typer()

Expand All @@ -27,6 +28,7 @@ def list_view(


@app.command()
@watch_option
def exists(
ctx: typer.Context,
cube_name: str,
Expand All @@ -35,6 +37,8 @@ def exists(
bool, typer.Option("-p", "--private", help="Flag to specify if view is private")
] = False,
database: Annotated[str, DATABASE_OPTION] = None,
watch: Annotated[bool, WATCH_OPTION] = False, # pylint: disable=unused-argument
interval: Annotated[int, INTERVAL_OPTION] = 5, # pylint: disable=unused-argument
):
"""
Check if view exists
Expand Down
6 changes: 6 additions & 0 deletions tm1cli/utils/cli_param.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import typer

DATABASE_OPTION = typer.Option("--database", "-d", help="Specify the database to use")
WATCH_OPTION = typer.Option(
"--watch", "-w", help="Watch the command output periodically."
)
INTERVAL_OPTION = (
typer.Option("--interval", help="Interval in seconds for the watch option."),
)
15 changes: 15 additions & 0 deletions tm1cli/utils/watch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import time
from functools import wraps


def watch_option(func):
@wraps(func)
def wrapper(*args, watch: bool = False, interval: int = 5, **kwargs):
if watch:
while True:
func(*args, **kwargs)
time.sleep(interval)
else:
func(*args, **kwargs)

return wrapper
Loading