Skip to content

Commit 3d0e347

Browse files
committed
Prefer get_cli_parser() over get_cli_args()
Because get_cli_parser() is more flexible and allow for specifying additional arguments within an analyzer context, it is now recommended instead of get_cli_args(). With that, get_cli_args() is now deprecated and will be removed in ICA v3.
1 parent 90c34b4 commit 3d0e347

File tree

7 files changed

+12
-12
lines changed

7 files changed

+12
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def main() -> None:
127127
# Allow your program to accept all the same CLI arguments as the `ica`
128128
# command; you can skip calling this if have other means of specifying the
129129
# contact name and output format
130-
cli_args = ica.get_cli_args()
130+
cli_args = ica.get_cli_parser().parse_args()
131131
# Retrieve the dataframes corresponding to the massaged contents of the
132132
# database; dataframes include `message` and `attachment`
133133
dfs = ica.get_dataframes(

ica/analyzers/attachment_totals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def main() -> None:
1111
Generate count data by attachment type, including number of Spotify links
1212
shared, YouTube videos, Apple Music, etc.
1313
"""
14-
cli_args = ica.get_cli_args()
14+
cli_args = ica.get_cli_parser().parse_args()
1515
dfs = ica.get_dataframes(
1616
contact_name=cli_args.contact_name, timezone=cli_args.timezone
1717
)

ica/analyzers/message_totals.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def main() -> None:
7878
Generate a summary of message and reaction counts, by person and in total,
7979
as well as other insightful metrics
8080
"""
81-
cli_args = ica.get_cli_args()
81+
cli_args = ica.get_cli_parser().parse_args()
8282
dfs = ica.get_dataframes(
8383
contact_name=cli_args.contact_name, timezone=cli_args.timezone
8484
)

ica/analyzers/most_frequent_emojis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def main() -> None:
2828
Generates count data for the top 10 most frequently used emojis across the
2929
entire conversation
3030
"""
31-
cli_args = ica.get_cli_args()
31+
cli_args = ica.get_cli_parser().parse_args()
3232
dfs = ica.get_dataframes(
3333
contact_name=cli_args.contact_name, timezone=cli_args.timezone
3434
)

ica/analyzers/totals_by_day.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def main() -> None:
1313
Generates a comprehensive breakdown of message totals for every day you and
1414
the other person have been messaging in the conversation
1515
"""
16-
cli_args = ica.get_cli_args()
16+
cli_args = ica.get_cli_parser().parse_args()
1717
dfs = ica.get_dataframes(
1818
contact_name=cli_args.contact_name, timezone=cli_args.timezone
1919
)

ica/analyzers/transcript.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def main() -> None:
1717
Generates a full, unedited transcript of every message, including
1818
reactions, between you and the other person (attachment files not included)
1919
"""
20-
cli_args = ica.get_cli_args()
20+
cli_args = ica.get_cli_parser().parse_args()
2121
dfs = ica.get_dataframes(
2222
contact_name=cli_args.contact_name, timezone=cli_args.timezone
2323
)

ica/cli.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,9 @@ def get_cli_parser() -> argparse.ArgumentParser:
7171

7272
def get_cli_args() -> argparse.Namespace:
7373
"""
74-
Parse user arguments from the command line
74+
[DEPRECATED]: Parse user arguments from the command line
7575
"""
76-
# parse_known_args() is slightly different from parse_args() in that the
77-
# former returns a two-item tuple where the first item is the Namespace of
78-
# known arguments, and the second item is a list of any unknown arguments
79-
return get_cli_parser().parse_known_args()[0]
76+
return get_cli_parser().parse_args()
8077

8178

8279
def run_analyzer(analyzer: str) -> None:
@@ -111,7 +108,10 @@ def main() -> None:
111108
global did_user_invoke_cli_directly
112109
did_user_invoke_cli_directly = True
113110

114-
cli_args = get_cli_args()
111+
# parse_known_args() is slightly different from parse_args() in that the
112+
# former returns a two-item tuple where the first item is the Namespace of
113+
# known arguments, and the second item is a list of any unknown arguments
114+
cli_args = get_cli_parser().parse_known_args()[0]
115115

116116
try:
117117
run_analyzer(cli_args.analyzer)

0 commit comments

Comments
 (0)