Skip to content

Commit d25b2cb

Browse files
authored
🔀 Merge pull request #74 from davep/cli-theme
Allow setting the theme via the command line
2 parents 51204fe + 8a1490f commit d25b2cb

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

ChangeLog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
# Hike ChangeLog
22

3+
## Unreleased
4+
5+
**Released: WiP**
6+
7+
- Added `--theme` as a command line switch; which lets the user configure
8+
the theme via the command line.
9+
([#74](https://github.com/davep/hike/pull/74))
10+
311
## v0.9.0
412

513
**Released: 2025-04-01**

src/hike/__main__.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ def get_args() -> Namespace:
5252
action="store_true",
5353
)
5454

55+
# Add --theme
56+
parser.add_argument(
57+
"-t",
58+
"--theme",
59+
help="Set the theme for the application (set to ? to list available themes)",
60+
)
61+
5562
# The remainder is going to be the initial command.
5663
parser.add_argument(
5764
"command",
@@ -82,6 +89,14 @@ def show_bindable_commands() -> None:
8289
)
8390

8491

92+
##############################################################################
93+
def show_themes() -> None:
94+
"""Show the available themes."""
95+
for theme in sorted(Hike(Namespace(theme=None)).available_themes):
96+
if theme != "textual-ansi":
97+
print(theme)
98+
99+
85100
##############################################################################
86101
def main() -> None:
87102
"""The main entry point."""
@@ -90,6 +105,8 @@ def main() -> None:
90105
print(cleandoc(Hike.HELP_LICENSE))
91106
elif args.bindings:
92107
show_bindable_commands()
108+
elif args.theme == "?":
109+
show_themes()
93110
else:
94111
Hike(args).run()
95112

src/hike/hike.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def __init__(self, arguments: Namespace) -> None:
6464
configuration = load_configuration()
6565
if configuration.theme is not None:
6666
try:
67-
self.theme = configuration.theme
67+
self.theme = arguments.theme or configuration.theme
6868
except InvalidThemeError:
6969
pass
7070
self.update_keymap(configuration.bindings)

0 commit comments

Comments
 (0)