Révision | 6644df1129f8af3c78dd210008b30283e1759c09 (tree) |
---|---|
l'heure | 2005-01-25 21:47:11 |
Auteur | henoheno <henoheno> |
Commiter | henoheno |
Added untouch. Added warn() and err()
@@ -1,22 +1,28 @@ | ||
1 | 1 | #!/bin/sh |
2 | -# $Id: tdiary-demogen.sh,v 1.6 2005/01/16 03:26:14 henoheno Exp $ | |
2 | +# $Id: tdiary-demogen.sh,v 1.7 2005/01/25 12:47:11 henoheno Exp $ | |
3 | 3 | # |
4 | 4 | # tDiary demonstration generator: generates many [theme].php |
5 | 5 | # License: GPL |
6 | 6 | |
7 | +warn(){ echo "$*" 1>&2; } | |
8 | +err(){ warn "$*"; exit 1; } | |
9 | + | |
7 | 10 | usage(){ |
8 | 11 | base="`basename $0`"; |
9 | - echo " $base [-d path/to/theme-directory] list" | |
10 | - echo " $base [-d path/to/theme-directory] interwiki" | |
11 | - echo " $base [-d path/to/theme-directory] touch" | |
12 | - echo " Command:" | |
13 | - echo " lis|list - List themes" | |
14 | - echo " int|interwiki - Publish interwiki definition and setting for each theme" | |
15 | - echo " tou|touch - Generate \$theme.php that includes index.php" | |
12 | + warn " $base [-d path/to/theme-directory] list" | |
13 | + warn " $base [-d path/to/theme-directory] interwiki" | |
14 | + warn " $base [-d path/to/theme-directory] touch" | |
15 | + warn " $base [-d path/to/theme-directory] untouch" | |
16 | + warn " Command:" | |
17 | + warn " lis|list - List themes" | |
18 | + warn " int|interwiki - Publish interwiki definition and setting for each theme" | |
19 | + warn " tou|touch - Generate \$theme.php that includes index.php" | |
20 | + warn " unt|untouch - Remove \$theme.php(s) listed in theme directory" | |
21 | + exit 1 | |
16 | 22 | } |
17 | 23 | |
18 | 24 | theme_list(){ |
19 | - cd "$dir" || echo "Error: directory '$dir' not found"; | |
25 | + cd "$dir" || err "Error: directory '$dir' not found" | |
20 | 26 | ls -1 | while read theme; do |
21 | 27 | test -f "$theme/$theme.css" && echo "$theme" |
22 | 28 | done |
@@ -62,5 +68,19 @@ EOF | ||
62 | 68 | fi |
63 | 69 | done |
64 | 70 | ;; |
71 | + | |
72 | +unt|unto|untou|untouc|untouch ) | |
73 | + echo -n " Remove theme(s).php ? [y/N]: " | |
74 | + read answer | |
75 | + case "$answer" in | |
76 | + [yY] | [yY][eE][sS] ) | |
77 | + theme_list | while read theme ; do | |
78 | + test -f "$theme.php" && grep -q "define('TDIARY_THEME', '$theme');" "$theme.php" && rm -f "$theme.php" | |
79 | + done | |
80 | + ;; | |
81 | + * ) | |
82 | + echo " Stopped." | |
83 | + esac | |
84 | + ;; | |
65 | 85 | esac |
66 | 86 |