diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 4131f13..c380062 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -2,6 +2,11 @@ Changelog ========= +Version 5.4 +=========== + +* Use default values of ``realm`` and ``client-id`` silently during ``cortex init``. Allow to overwrite the default values with command line switches ``--realm`` and ``--client-id``. `#61 `_ + Version 5.3 =========== diff --git a/src/iqm/cortex_cli/cortex_cli.py b/src/iqm/cortex_cli/cortex_cli.py index 626d3bf..f863d3c 100644 --- a/src/iqm/cortex_cli/cortex_cli.py +++ b/src/iqm/cortex_cli/cortex_cli.py @@ -305,12 +305,14 @@ def cortex_cli() -> None: @cortex_cli.command() +@click.help_option() @click.option( '--config-file', prompt='Where to save config', callback=_validate_path, default=CortexCliCommand.default_config_path, type=ResolvedPath(dir_okay=False, writable=True, resolve_path=True), + is_eager=True, help='Location where the configuration file will be saved.', ) @click.option( @@ -319,22 +321,33 @@ def cortex_cli() -> None: callback=_validate_path, default=CortexCliCommand.default_tokens_path, type=ResolvedPath(dir_okay=False, writable=True, resolve_path=True), + is_eager=True, help='Location where the tokens file will be saved.', ) @click.option( '--auth-server-url', prompt='Authentication server URL', callback=_validate_auth_server_url, + is_eager=True, help='Authentication server URL.', ) @click.option( '--realm', prompt='Realm on IQM auth server', + prompt_required=False, default=REALM_NAME, + show_default=True, callback=_validate_auth_realm, help='Name of the realm on the IQM authentication server.', ) -@click.option('--client-id', prompt='Client ID', default=CLIENT_ID, help='Client ID on the IQM authentication server.') +@click.option( + '--client-id', + prompt='Client ID', + prompt_required=False, + default=CLIENT_ID, + show_default=True, + help='Client ID on the IQM authentication server.', +) @click.option( '--username', prompt='Username (optional)', diff --git a/tests/cortex_cli_init_test.py b/tests/cortex_cli_init_test.py index 6af8c8e..7b32891 100644 --- a/tests/cortex_cli_init_test.py +++ b/tests/cortex_cli_init_test.py @@ -28,14 +28,15 @@ from tests.conftest import expect_process_terminate, prepare_auth_server_urls -@pytest.mark.parametrize('first_option', ['--config-file', '--tokens-file', '--auth-server-url', '--client-id']) +@pytest.mark.parametrize( + 'first_option', ['--config-file', '--tokens-file', '--auth-server-url', '--realm', '--client-id'] +) @pytest.mark.parametrize('absolute_path', [True, False]) def test_init_saves_config_file(config_dict, first_option, tmp_path, absolute_path): """ Tests that ``cortex init`` produces config file. Having different options as first one is tested since it can affect the initialization of ``click.Context``. - Specifying ``realm`` before ``auth-server-url`` is not allowed, so that case is not included. """ prepare_auth_server_urls(config_dict) runner = CliRunner()