Skip to content

Add filtering, paging, and richer output to all list commands - #9

Open
151N3 wants to merge 4 commits into
onefloid:mainfrom
151N3:main
Open

Add filtering, paging, and richer output to all list commands#9
151N3 wants to merge 4 commits into
onefloid:mainfrom
151N3:main

Conversation

@151N3

@151N3 151N3 commented Aug 14, 2026

Copy link
Copy Markdown

✨ This pull request was developed with the assistance of GitHub Copilot.

Summary

Upgrades all five list commands (cube, dimension, process, subset, view) with a consistent set
of new options, fixes a code bug, hardens the test suite, and patches a crash in the threads command.


New features

Shared utility (tm1cli/utils/list_utils.py)

New module with OutputFormat (yaml/json), VisibilityType (public/private/both), apply_filter,
apply_paging, and render_output — reused by all list commands.

Common new options on cube list, dimension list, process list

Flag Description
--filter / -f Case-insensitive regex or substring filter on names
--output / -o Output format: yaml (default) or json
--limit Maximum number of results
--offset Number of results to skip (for paging)

Output format changed from one name per line to a YAML/JSON list (- Name).

subset list and view list — richer structured output

  • Positional dimension_name / cube_name arguments replaced by optional --dimension / --cube
    flags; omitting them iterates over all non-control dimensions/cubes.
  • New --type / -t flag: public (default), private, or both.
  • Output is now structured records — each entry includes dimension/cube, name, and type.
  • All four filter/paging/output flags also added.

process list — skip control TIs

New --skip-control-tis / -s flag to exclude processes whose names start with }.

dimension list

Flag renamed from --skip-control-cubes--skip-control-dims (was a copy-paste mistake).


Bug fixes

process.py — duplicate Annotated import removed

from typing_extensions import Annotated was left in place after the new
from typing import Annotated, Optional was added, silently shadowing it.
The stale typing_extensions import was removed.

main.pythreads --beautify crash on empty list

threads[0].keys() raised IndexError when no threads were active for the current session.
Added an empty-list guard; prints "No threads." in that case.


Test improvements

tests/conftest.py

  • MockedCubeService.get_all_names signature fixed to match the real API (skip_control_cubes kwarg).
  • MockedViewService.get_all_names now returns a (private, public) tuple matching TM1py's actual return type.
  • MockedSubsetService.get_all_names extended with hierarchy_name and private parameters.
  • MockedProcessService added with get_all_names, exists, get, and update_or_create.

New tests/test_cmd_process.py

8 mocked unit tests covering list/ls aliases, JSON output (--output json),
--filter, --limit, --offset, and exists true/false.

tests/test_tm1cli.py

  • test_process_clone_not_exists converted to a mocked test: patches both TM1Service and
    resolve_database so the process-not-found path is reached before any database-lookup error.
  • All 5 previously failing tests now pass.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant