Skip to content

Commit 2ea3ce0

Browse files
Replace click.MultiCommand with click.Group (#2096)
click.MultiCommand is deprecated and will be removed in click 9. This change migrates to click.Group which is the recommended replacement. - Changed ElementaryCLI base class from click.MultiCommand to click.Group - Replaced @click.command with @click.group decorator - Removed _CMD_MAP dictionary and list_commands() method - Added commands using cli.add_command() instead - Updated get_command() to call super().get_command() Fixes ELE-5220 Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Itamar Hartstein <haritamar@gmail.com>
1 parent 3b870a6 commit 2ea3ce0

1 file changed

Lines changed: 9 additions & 13 deletions

File tree

elementary/cli/cli.py

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,10 @@ def get_quiet_logs(ctx):
3636
return False
3737

3838

39-
class ElementaryCLI(click.MultiCommand): # type: ignore[misc, valid-type]
40-
_CMD_MAP = {
41-
"monitor": monitor,
42-
"report": report,
43-
"send-report": send_report,
44-
"run-operation": run_operation,
45-
}
46-
47-
def list_commands(self, ctx):
48-
return self._CMD_MAP.keys()
49-
39+
class ElementaryCLI(click.Group):
5040
def get_command(self, ctx, name):
5141
ctx.auto_envvar_prefix = "EDR"
52-
return self._CMD_MAP.get(name)
42+
return super().get_command(ctx, name)
5343

5444
def format_help(self, ctx, formatter):
5545
try:
@@ -75,7 +65,7 @@ def invoke(self, ctx: click.Context) -> Any:
7565
return super().invoke(ctx)
7666

7767

78-
@click.command(
68+
@click.group(
7969
cls=ElementaryCLI,
8070
help="Open source data reliability solution (https://docs.elementary-data.com/)",
8171
)
@@ -87,5 +77,11 @@ def cli():
8777
pass
8878

8979

80+
cli.add_command(monitor)
81+
cli.add_command(report)
82+
cli.add_command(send_report, name="send-report")
83+
cli.add_command(run_operation, name="run-operation")
84+
85+
9086
if __name__ == "__main__":
9187
cli()

0 commit comments

Comments
 (0)