Clean code
[irreco.git] / script / theme.sh
blob74120de6b08edfc2ef8d9706eea17105428e73a8
1 #!/bin/bash
2 cd `dirname "$0"`
3 source variables.sh
4 scratchbox_need
7 # Script for automating theme testing.
10 theme_main()
12 THEME="$1"
13 COMMAND="$2"
14 ARGS=("$@")
16 find_theme_dir
18 if [[ "$THEME" == "all" ]]; then
19 cd "$THEME_DIR"
20 { while read THEME; do
21 if [ -d "$THEME" ]; then
22 "$SCRIPT_DIR/$SCRIPT_NAME" \
23 "$THEME" "$COMMAND" "${ARGS[@]:2}"
24 check_exit_code "$?"
26 done } < <( ls -1 )
27 exit 0
30 case "$COMMAND" in
31 --install|install|inst) theme_install "${ARGS[@]:2}";;
32 *) echo "Error: Unknown command \"$COMMAND\"";
33 theme_usage;
34 exit 1;;
35 esac
38 theme_usage()
40 echo ""
41 echo "Usage: $SCRIPT_NAME THEME COMMAND [ options ]"
42 echo " $SCRIPT_NAME all COMMAND [ options ]"
43 echo ""
44 echo "Commands:"
45 echo " --install | install | inst"
46 echo " Install themes to \"$INSTALL_DIR\"."
47 echo ""
50 theme_install()
52 theme_print_title "INSTALL"
53 "$THEME_DIR"/theme-conf-gen.sh --generate "$THEME_DIR"/"$THEME" "$INSTALL_DIR"
54 check_exit_code "$?"
57 theme_print_title()
59 print_title `echo "$THEME" | tr a-z A-Z `" $1"
62 theme_main "$@"