gravitino icon indicating copy to clipboard operation
gravitino copied to clipboard

[#6798] feat(CLI): Support TableFormat and PlainFormat for Model, User and Group.

Open Abyss-lord opened this issue 9 months ago • 8 comments

What changes were proposed in this pull request?

Uniform CLI output format for Model, User and Group commands.

Why are the changes needed?

Uniform CLI output format for Model, User and Group commands.

Fix: #6798

Does this PR introduce any user-facing change?

Users can output multiple entities using the CLI's table format.

How was this patch tested?

local test + ut. TableFormat test.

bin/gcli.sh model list -m demo_metalake --name model_catalog.schema --output table
+--------+
|  Name  |
+--------+
| model2 |
+--------+

bin/gcli.sh model details -m demo_metalake --name model_catalog.schema.model2 --output table
+--------+-------------+----------------+
|  Name  |   Comment   | Latest version |
+--------+-------------+----------------+
| model2 | test rename | 0              |
+--------+-------------+----------------+


bin/gcli.sh user list -m demo_metalake --output table
+-----------+
|   Name    |
+-----------+
| anonymous |
| testRole  |
| test_user |
+-----------+

bin/gcli.sh user details -m demo_metalake --user testRole --output table
The user has no roles.

bin/gcli.sh group list -m demo_metalake --output table
+---------------+
|     Name      |
+---------------+
| group_no_role |
| test_group    |
+---------------+

bin/gcli.sh group details -m demo_metalake --group test_group --output table
The group has no roles.

PlainFormat test.

bin/gcli.sh model list -m demo_metalake --name model_catalog.schema
model2

bin/gcli.sh model list -m demo_metalake --name model_catalog.schema 
Model name model2, comment: test rename, latest version: 0

bin/gcli.sh user list -m demo_metalake
anonymous
testRole
test_user

bin/gcli.sh user details -m demo_metalake --user testRole
The user has no roles.

bin/gcli.sh group list -m demo_metalake
group_no_role
test_group

bin/gcli.sh group details -m demo_metalake --group test_group
The group has no roles.

Abyss-lord avatar Mar 31 '25 12:03 Abyss-lord

Hi @justinmclean , could you please review this PR when you have time? I’d really appreciate your feedback.

Abyss-lord avatar Mar 31 '25 12:03 Abyss-lord

@justinmclean should we support all entity? include:

  1. Tag;
  2. Role;
  3. User;
  4. Group
  5. Fileset
  6. Model
  7. Topic

Abyss-lord avatar Apr 03 '25 08:04 Abyss-lord

@justinmclean Can we add this PR in release 0.9?

Abyss-lord avatar Apr 15 '25 09:04 Abyss-lord

@justinmclean Hi Justin, could you plz help to review this pr, I think we can add this PR in release 0.9.

Abyss-lord avatar Apr 22 '25 02:04 Abyss-lord

I'm currently on holiday, so only took a quick look. My concern is that this changes the output of existing commands, which could be unexpected to users or break user scripts.

justinmclean avatar Apr 22 '25 22:04 justinmclean

I'm currently on holiday, so only took a quick look. My concern is that this changes the output of existing commands, which could be unexpected to users or break user scripts.

@justinmclean plainFormat will continue to preserve the original output format and remains the default, so it will not affect existing user scripts. Since the Model object was only introduced in version 0.8, there are not many scripts associated with it, making this the ideal time to standardize its output. The main goal of this PR is to centralize the display methods so that all output can only be produced through the printInformation or printResults methods.

Abyss-lord avatar Apr 23 '25 05:04 Abyss-lord

Yes but you have also changed the output of several plain commands.

justinmclean avatar Apr 25 '25 09:04 justinmclean

Hi @justinmclean I've completed the code updates and would appreciate your review of the PR when you have a moment. Here's a summary of the commits:

  1. revert: Keep PlainFormat message as before.

Abyss-lord avatar Apr 27 '25 02:04 Abyss-lord

Other than that one minor comment, it looks good to me

justinmclean avatar May 07 '25 06:05 justinmclean

Hi @justinmclean I've completed the code updates and would appreciate your review of the PR when you have a moment. Here's a summary of the commits:

  1. Fix ListGroup message.

Abyss-lord avatar May 07 '25 07:05 Abyss-lord