Skip to content

Commit

Permalink
chore: proposal to update the terminal output for the login (#140)
Browse files Browse the repository at this point in the history
Making it easier for users to understand the login functionality.
  • Loading branch information
uriii3 authored and renaudjester committed Oct 28, 2024
1 parent a6d85c5 commit bbeabbe
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
10 changes: 9 additions & 1 deletion copernicusmarine/core_functions/credentials_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,15 @@ def _load_credential_from_motu_configuration_file(
def _retrieve_credential_from_prompt(
credential_type: Literal["username", "password"], hide_input: bool
) -> str:
return click.prompt(credential_type, hide_input=hide_input)
if credential_type == "username":
logger.info(
"Downloading CMEMS data requires a Copernicus Marine username "
"and password, sign up for free at:"
" https://data.marine.copernicus.eu/register"
)
return click.prompt(
"copernicusmarine " + credential_type, hide_input=hide_input
)


def _retrieve_credential_from_environment_variable(
Expand Down
7 changes: 6 additions & 1 deletion tests/test_command_line_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,12 @@ def test_login_is_prompt_when_configuration_file_doest_not_exist(
command, env=environment_without_crendentials
)
assert self.output.returncode == 1
assert b"username:" in self.output.stdout
assert (
b"Downloading CMEMS data requires a Copernicus Marine username "
b"and password, sign up for free at:"
b" https://data.marine.copernicus.eu/register"
) in self.output.stderr
assert b"copernicusmarine username:" in self.output.stdout

def test_login_command(self, tmp_path):
self.check_credentials_username_specified_password_prompt(tmp_path)
Expand Down

0 comments on commit bbeabbe

Please sign in to comment.