From fd834ce34953c2f34ae4ef548fc6b9ced0bb4309 Mon Sep 17 00:00:00 2001 From: Steven Bakker Date: Thu, 30 Nov 2017 16:09:47 +0100 Subject: [PATCH] Show a demo of a theme. --- show_theme.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100755 show_theme.sh diff --git a/show_theme.sh b/show_theme.sh new file mode 100755 index 0000000..ffb5e24 --- /dev/null +++ b/show_theme.sh @@ -0,0 +1,57 @@ +#!/bin/bash -e +# +# Show theme. +# +# Copyright (c) 2014-2017 Steven Bakker; All rights reserved. +# +# This program is free software; you can redistribute it and/or modify +# it under the same terms as Perl itself. See "perldoc perlartistic". +# +# This software is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +dir=${0%/*} +prog=${0##*/} + +die() { + echo "$@" >&2 + exit 1 +} + +case $# in + 1) theme=$1 ;; + *) die "usage: $prog theme" ;; +esac + +is_yaml=false +theme_arg='' + +if [[ $theme =~ \.y[a]?ml$ && -f $theme ]]; then + is_yaml=true + theme_arg=$theme +else + if [[ -d $theme ]]; then + if [[ -f $theme/colors.yaml ]]; then + is_yaml=true + theme_arg="$theme/colors.yaml" + elif [[ -f $theme/palette ]]; then + is_yaml=false + theme_arg="$theme" + fi + elif [[ -f colors/$theme/colors.yaml ]]; then + is_yaml=true + theme_arg="colors/$theme/colors.yaml" + elif [[ -f colors/$theme/palette ]]; then + is_yaml=false + theme_arg="colors/$theme" + fi +fi + +[[ -n $theme_arg ]] || die "$prog: $theme is not a valid theme file/directory" + +if $is_yaml; then + $dir/src/parse_yaml_theme.pl "$theme_arg" show +else + $dir/src/theme_to_yaml.pl --show "$theme_arg" +fi