mirror of
https://github.com/1j01/textual-paint.git
synced 2024-11-28 10:03:29 +03:00
Add --theme option to CLI
This commit is contained in:
parent
650584d4b2
commit
a02431d19e
@ -65,7 +65,7 @@ textual-paint
|
||||
|
||||
```
|
||||
$ python3 paint.py --help
|
||||
usage: paint.py [-h] [--ascii-only-icons] [--clear-screen] [filename]
|
||||
usage: paint.py [-h] [--theme THEME] [--ascii-only-icons] [--clear-screen] [filename]
|
||||
|
||||
Paint in the terminal.
|
||||
|
||||
@ -74,6 +74,7 @@ positional arguments:
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
--theme THEME Theme to use, either "light" or "dark"
|
||||
--ascii-only-icons Use only ASCII characters for tool icons
|
||||
--clear-screen Clear the screen before starting; useful for development, to avoid seeing fixed errors
|
||||
```
|
||||
|
7
paint.py
7
paint.py
@ -1136,7 +1136,10 @@ class PaintApp(App):
|
||||
# and it would create a new app instance, and all arguments would be ignored.
|
||||
app = PaintApp()
|
||||
|
||||
# Command line arguments
|
||||
# Please keep in sync with the README
|
||||
parser = argparse.ArgumentParser(description='Paint in the terminal.')
|
||||
parser.add_argument('--theme', default='light', help='Theme to use, either "light" or "dark"')
|
||||
parser.add_argument('--ascii-only-icons', action='store_true', help='Use only ASCII characters for tool icons')
|
||||
# This flag is for development, because it's very confusing
|
||||
# to see the error message from the previous run,
|
||||
@ -1168,6 +1171,10 @@ if args.filename:
|
||||
app.filename = args.filename
|
||||
if args.clear_screen:
|
||||
os.system("cls||clear")
|
||||
if args.theme not in ["light", "dark"]:
|
||||
print("Invalid theme. Must be either 'light' or 'dark'.")
|
||||
sys.exit(1)
|
||||
app.dark = args.theme == "dark"
|
||||
|
||||
if __name__ == "__main__":
|
||||
app.run()
|
||||
|
Loading…
Reference in New Issue
Block a user