Skip to content

Commit

Permalink
Add a feature that lists itself and all the other features (keywords)…
Browse files Browse the repository at this point in the history
… for the user.
  • Loading branch information
johndoknjas committed May 3, 2024
1 parent f7022f7 commit b0392f7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 7 additions & 3 deletions hypickle/Args.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ def __init__(self, args: list[str]):
'pitpercent', 'pit%', 'pitplot', 'nwplot', 'bwplot', 'contains',
'trackargs', 'argsonline', 'newest', 'oldest',
'debugapi', 'showjsondiff', 'showjsonupdates',
'norecentgame', 'norecentgames', 'list', 'copyable')
'norecentgame', 'norecentgames', 'list', 'copyable',
'help', 'features')
# These keywords are possible options the user can specify for using the program. All of these are
# 'non-positional'; i.e., it doesn't matter where they appear in the user's command line argument list.
# For 'positional' arguments, there are fewer (e.g., '-', 'friendedwhen', 'intersect').
Expand Down Expand Up @@ -141,11 +142,14 @@ def comma_sep_list(self) -> bool:
by the igns after that."""
return 'list' in self._ARGS or 'copyable' in self._ARGS

def list_features(self) -> bool:
return 'help' in self._ARGS or 'features' in self._ARGS

def do_mini_program(self) -> bool:
mini_programs = (self.update_aliases(), self.add_uuid_aliases(), self.print_aliases(),
self.contains_substr(), self.add_additional_friends(), self.get_player_json(),
self.pit_percent(), self.pit_plot(), self.network_plot(), self.bedwars_plot(),
self.comma_sep_list())
self.comma_sep_list(), self.list_features())
assert (bool_sum := sum(1 for x in mini_programs if x)) <= 1
return bool_sum == 1

Expand All @@ -158,7 +162,7 @@ def _validation_checks(self) -> None:
assert not self.get_newest_friends() and not self.get_oldest_friends()
assert not (self.sort_by_pit_rank() and self.sort_by_star())
if any((self.update_aliases(), self.print_aliases(), self.pit_plot(), self.network_plot(),
self.bedwars_plot())):
self.bedwars_plot(), self.list_features())):
assert not self.get_args(True) and len(self.get_args(False)) == 1
if self.add_additional_friends():
assert len(self.get_args(True)) == 1 and len(self.get_args(False)) == 2
Expand Down
2 changes: 2 additions & 0 deletions hypickle/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ def do_mini_program() -> None:
for friend in player.friends():
print(f"{friend.name()}, ", end='', flush=True)
print('\n')
elif args().list_features():
print(*sorted(args().get_keywords()), sep='\n')
else:
assert False

Expand Down

0 comments on commit b0392f7

Please sign in to comment.