Skip to content

Commit

Permalink
[SNOW-942561] Resolve short options conflicts (snowflakedb#481)
Browse files Browse the repository at this point in the history
  • Loading branch information
sfc-gh-pjob authored Oct 16, 2023
1 parent 8b90b42 commit 5ad9bae
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

## Fixes and improvements
* Adjust streamlit commands to PuPr syntax
* Resolved `-a` option conflict in `snow snowpark procedure update` command by removing short version of `--replace-always` option (it was conflicting with short version of `--check-anaconda-for-pypi-deps`).

# v1.1.1

Expand Down
13 changes: 9 additions & 4 deletions src/snowcli/app/cli_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ class AppContextHolder:
app_context_holder = AppContextHolder()


def _exit_with_cleanup():
_commands_registration.reset_running_instance_registration_state()
raise typer.Exit()


def _do_not_execute_on_completion(callback):
def enriched_callback(value):
if click.get_current_context().resilient_parsing:
Expand Down Expand Up @@ -81,7 +86,7 @@ def _docs_callback(value: bool):
if value:
ctx = click.get_current_context()
generate_docs(Path("gen_docs"), ctx.command)
raise typer.Exit()
_exit_with_cleanup()


@_do_not_execute_on_completion
Expand All @@ -90,14 +95,14 @@ def _commands_structure_callback(value: bool):
if value:
ctx = click.get_current_context()
generate_commands_structure(ctx.command).print()
raise typer.Exit()
_exit_with_cleanup()


@_do_not_execute_on_completion
def _version_callback(value: bool):
if value:
typer.echo(f"SnowCLI Version: {__about__.VERSION}")
raise typer.Exit()
_exit_with_cleanup()


@_do_not_execute_on_completion
Expand All @@ -110,7 +115,7 @@ def _info_callback(value: bool):
],
)
print_result(result, output_format=OutputFormat.JSON)
raise typer.Exit()
_exit_with_cleanup()


@app.callback()
Expand Down
1 change: 0 additions & 1 deletion src/snowcli/cli/common/flags.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
PasswordOption = typer.Option(
None,
"--password",
"-p",
help="Snowflake password. Overrides the value specified for the connection.",
hide_input=True,
callback=ConnectionDetails.update_callback("password"),
Expand Down
1 change: 0 additions & 1 deletion src/snowcli/cli/snowpark/function/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@
ReplaceOption = typer.Option(
False,
"--replace-always",
"-a",
help="Replace function, even if no detected changes to metadata",
)

Expand Down
4 changes: 2 additions & 2 deletions src/snowcli/cli/snowpark/jobs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
@global_options_with_connection
def create(
compute_pool: str = typer.Option(
..., "--compute-pool", "-c", help="Name of the pool in which to run the job."
..., "--compute-pool", help="Name of the pool in which to run the job."
),
spec_path: Path = typer.Option(
...,
Expand Down Expand Up @@ -70,7 +70,7 @@ def desc(id: str = typer.Argument(..., help="Job id"), **options) -> CommandResu
def logs(
id: str = typer.Argument(..., help="Job id"),
container_name: str = typer.Option(
..., "--container-name", "-c", help="Name of the container."
..., "--container-name", help="Name of the container."
),
**options,
):
Expand Down
1 change: 0 additions & 1 deletion src/snowcli/cli/snowpark/procedure/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
ReplaceOption = typer.Option(
False,
"--replace-always",
"-a",
help="Replace procedure, even if no detected changes to metadata",
)

Expand Down
1 change: 0 additions & 1 deletion tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ def _check(command: Command, path: t.Optional[t.List] = None):
assert len(errors) == 0, "\n".join(errors)


@pytest.mark.skip # TODO : unskip after resolving all options conflicts
def test_if_there_are_no_option_duplicates(runner):
runner.invoke("--help")

Expand Down

0 comments on commit 5ad9bae

Please sign in to comment.