Skip to content

Commit

Permalink
small issue and color the "ctrl+c" text
Browse files Browse the repository at this point in the history
  • Loading branch information
axif0 committed Oct 27, 2024
1 parent 81cb9e3 commit dde47f1
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 32 deletions.
60 changes: 32 additions & 28 deletions src/scribe_data/cli/get.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,34 +96,38 @@ def get_data(
subprocess_result = False

# Mark: Get All for Specified Language

if all and language:
print(f"Updating all data types for language: {language}")
query_data(
languages=[language],
data_type=None,
output_dir=output_dir,
overwrite=overwrite,
)
subprocess_result = True

# Mark: Get All for Specified Data Type

if all and data_type:
print(f"Updating all languages for data type: {data_type}")
query_data(
languages=None,
data_type=[data_type],
output_dir=output_dir,
overwrite=overwrite,
)
subprocess_result = True

# Mark: Get All for All Languages and Data Types

elif all:
print("Updating all languages and data types ...")
query_data(None, None, output_dir, overwrite)
if all:
if language:
print(f"Updating all data types for language for {language}")
query_data(
languages=[language],
data_type=None,
output_dir=output_dir,
overwrite=overwrite,
)
print(
f"Query completed for all data types with specified language for {language}."
)
elif data_type:
print(f"Updating all languages for data type: {data_type}")
query_data(
languages=None,
data_type=[data_type],
output_dir=output_dir,
overwrite=overwrite,
)
print(
f"Query completed for all languages with specified data type for {data_type}."
)
else:
print("Updating all languages and data types ...")
query_data(
languages=None,
data_type=None,
output_dir=output_dir,
overwrite=overwrite,
)
print("Query completed for all languages and all data types.")
subprocess_result = True

# Mark: Emojis
Expand Down
3 changes: 2 additions & 1 deletion src/scribe_data/cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#!/usr/bin/env python3
import argparse
from pathlib import Path
from rich import print as rprint

from scribe_data.cli.cli_utils import validate_language_and_data_type
from scribe_data.cli.convert import convert_wrapper
Expand Down Expand Up @@ -298,7 +299,7 @@ def main() -> None:
parser.print_help()

except KeyboardInterrupt:
print("Execution was interrupted by the user.")
rprint("[bold red]Execution was interrupted by the user.[/bold red]")


if __name__ == "__main__":
Expand Down
31 changes: 28 additions & 3 deletions tests/cli/test_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,34 @@ def test_invalid_arguments(self):
# MARK: All Data

@patch("scribe_data.cli.get.query_data")
def test_get_all_data(self, mock_query_data):
get_data(all=True)
mock_query_data.assert_called_once_with(None, None, None, False)
def test_get_all_data_types_for_language(self, mock_query_data):
get_data(all=True, language="English")
mock_query_data.assert_called_once_with(
languages=["English"],
data_type=None,
output_dir="scribe_data_json_export",
overwrite=False,
)

@patch("scribe_data.cli.get.query_data")
def test_get_all_languages_for_data_type(self, mock_query_data):
get_data(all=True, data_type="nouns")
mock_query_data.assert_called_once_with(
languages=None,
data_type=["nouns"],
output_dir="scribe_data_json_export",
overwrite=False,
)

@patch("scribe_data.cli.get.query_data")
def test_get_all_languages_and_data_types(self, mock_query_data):
get_data(all=True, output_dir="./test_output")
mock_query_data.assert_called_once_with(
languages=None,
data_type=None,
output_dir="./test_output",
overwrite=False,
)

# MARK: Language and Data Type

Expand Down

0 comments on commit dde47f1

Please sign in to comment.