Skip to content

Commit

Permalink
Merge pull request #472 from OmarAI2003/list-command-formatting
Browse files Browse the repository at this point in the history
List command formatting
  • Loading branch information
andrewtavis authored Oct 23, 2024
2 parents 703f70b + 4c7a83e commit bee4776
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
19 changes: 7 additions & 12 deletions docs/source/scribe_data/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,12 @@ Example output:
$ scribe-data list
Language ISO QID
-----------------------
==========================
English en Q1860
...
-----------------------
Available data types: All languages
-----------------------------------
===================================
adjectives
adverbs
emoji-keywords
Expand All @@ -72,7 +71,7 @@ Example output:
prepositions
proper-nouns
verbs
-----------------------------------
Expand All @@ -81,18 +80,17 @@ Example output:
$scribe-data list --language
Language ISO QID
-----------------------
==========================
English en Q1860
...
-----------------------
.. code-block:: text
$scribe-data list -dt
Available data types: All languages
-----------------------------------
===================================
adjectives
adverbs
emoji-keywords
Expand All @@ -102,21 +100,19 @@ Example output:
prepositions
proper-nouns
verbs
-----------------------------------
.. code-block:: text
$scribe-data list -a
Language ISO QID
-----------------------
==========================
English en Q1860
...
-----------------------
Available data types: All languages
-----------------------------------
===================================
adjectives
adverbs
emoji-keywords
Expand All @@ -126,7 +122,6 @@ Example output:
prepositions
proper-nouns
verbs
-----------------------------------
Get Command
~~~~~~~~~~~
Expand Down
9 changes: 3 additions & 6 deletions src/scribe_data/cli/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,13 @@ def list_languages() -> None:
print(
f"{'Language':<{language_col_width}} {'ISO':<{iso_col_width}} {'QID':<{qid_col_width}}"
)
print("-" * table_line_length)
print("=" * table_line_length)

for lang in languages:
print(
f"{lang.capitalize():<{language_col_width}} {get_language_iso(lang):<{iso_col_width}} {get_language_qid(lang):<{qid_col_width}}"
)

print("-" * table_line_length)
print()


Expand Down Expand Up @@ -121,13 +120,12 @@ def list_data_types(language: str = None) -> None:

print()
print(table_header)
print("-" * table_line_length)
print("=" * table_line_length)

data_types = sorted(data_types)
for dt in data_types:
print(dt.replace("_", "-"))

print("-" * table_line_length)
print()


Expand Down Expand Up @@ -163,15 +161,14 @@ def list_languages_for_data_type(data_type: str) -> None:
print(
f"{'Language':<{language_col_width}} {'ISO':<{iso_col_width}} {'QID':<{qid_col_width}}"
)
print("-" * table_line_length)
print("=" * table_line_length)

# Iterate through the list of languages and format each row.
for lang in all_languages:
print(
f"{lang['name'].capitalize():<{language_col_width}} {lang['iso']:<{iso_col_width}} {lang['qid']:<{qid_col_width}}"
)

print("-" * table_line_length)
print()


Expand Down

0 comments on commit bee4776

Please sign in to comment.