themes: Enhance listing.

This commit is contained in:
Dylan Araps 2018-04-03 12:06:41 +10:00
parent 59b4c54086
commit 68e20cc90a
2 changed files with 8 additions and 5 deletions

View File

@ -118,12 +118,13 @@ def parse_args_exit(parser):
if args.theme == "list_themes":
themes = [theme.name.replace(".json", "")
for theme in theme.list_themes()]
print("Themes:", themes)
print("Extra: 'random' (select a random theme)")
print("\n - ".join(["\033[1;32mThemes\033[0m:", *sorted(themes)]))
print("\033[1;32mExtra\033[0m:\n - random (select a random theme)")
sys.exit(0)
if args.backend == "list_backends":
print("Backends:", colors.list_backends())
print("\n - ".join(["\033[1;32mBackends\033[0m:",
*colors.list_backends()]))
sys.exit(0)

View File

@ -12,8 +12,10 @@ from . import util
def list_themes():
"""List all installed theme files."""
return [*os.scandir(os.path.join(CONF_DIR, "colorschemes")),
*os.scandir(os.path.join(MODULE_DIR, "colorschemes"))]
themes = [*os.scandir(os.path.join(CONF_DIR, "colorschemes")),
*os.scandir(os.path.join(MODULE_DIR, "colorschemes"))]
return [t for t in themes if os.path.isfile(t)]
def terminal_sexy_to_wal(data):