File: blaze.sh

package info (click to toggle)
blazeblogger 1.2.0-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid, trixie
  • size: 748 kB
  • sloc: perl: 2,929; makefile: 122; sh: 80
file content (123 lines) | stat: -rwxr-xr-x 4,131 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#!/bin/sh

# blaze, a command wrapper for BlazeBlogger
# Copyright (C) 2009-2011 Jaromir Hradilek

# This program is  free software:  you can redistribute it and/or modify it
# under  the terms  of the  GNU General Public License  as published by the
# Free Software Foundation, version 3 of the License.
#
# This program  is  distributed  in the hope  that it will  be useful,  but
# WITHOUT  ANY WARRANTY;  without  even the implied  warranty of MERCHANTA-
# BILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
# License for more details.
#
# You should have received a copy of the  GNU General Public License  along
# with this program. If not, see <http://www.gnu.org/licenses/>.

# General script information:
NAME=${0##*/}
VERSION='1.2.0'

# Get the command if any, and shift command line options:
COMMAND=$1
shift

# Substitute aliases:
case "$COMMAND" in
  "ed")         COMMAND="edit";;
  "in")         COMMAND="init";;
  "ls")         COMMAND="list";;
  "mk")         COMMAND="make";;
  "rm" | "del") COMMAND="remove";;
  "cf" | "cfg") COMMAND="config";;
  "vs" | "ver") COMMAND="version";;
esac

# Parse the command and perform an appropriate action:
case "$COMMAND" in
  "add" | "log" | "edit" | "init" | "list" | "make" | "config" | "remove")
    # Run the selected utility:
    exec blaze-$COMMAND "$@"
    ;;
  "-h" | "--help" | "help")
    # Get the command, if any:
    COMMAND=$1

    # Parse the command, and display its usage:
    case "$COMMAND" in
      "add" | "log" | "edit" | "init" | "list" | "make" | "config" | "remove")
        # Display the utility usage information:
        exec blaze-$COMMAND --help
        ;;
      *)
        # Display the list of available commands:
        echo "Usage: $NAME COMMAND [OPTION...]"
        echo
        echo "Basic commands:"
        echo "  init     create or recover a BlazeBlogger repository"
        echo "  config   display or set BlazeBlogger configuration options"
        echo "  add      add a blog post or page to a BlazeBlogger repository"
        echo "  edit     edit a blog post or page in a BlazeBlogger repository"
        echo "  remove   remove a blog post or page from a BlazeBlogger repository"
        echo "  list     list blog posts or pages in a BlazeBlogger repository"
        echo "  make     generate a blog from a BlazeBlogger repository"
        echo "  log      display a BlazeBlogger repository log"
        echo
        echo "Additional commands:"
        echo "  help [COMMAND]  display usage information on the selected command"
        echo "  man [COMMAND]   display a manual page for the selected command"
        echo "  version         display version information"
        echo
        echo "Command aliases:"
        echo "  in       init"
        echo "  ed       edit"
        echo "  ls       list"
        echo "  mk       make"
        echo "  cf, cfg  config"
        echo "  rm, del  remove"
        echo "  vs, ver  version"

        # Return success:
        exit 0
        ;;
    esac
    ;;
  "man")
    # Get the command, if any:
    COMMAND=$1

    # Parse the command, and display its manual page:
    case "$COMMAND" in
      "add" | "log" | "edit" | "init" | "list" | "make" | "config" | "remove")
        # Display the utility usage information:
        exec man blaze-$COMMAND
        ;;
      *)
        # Display a general manual page:
        exec man blaze
        ;;
    esac
    ;;
  "-v" | "--version" | "version")
    # Display version information:
    echo "BlazeBlogger $VERSION"
    echo
    echo "Copyright (C) 2008-2011 Jaromir Hradilek"
    echo "This program is free software; see the source for copying conditions. It is"
    echo "distributed in the hope  that it will be useful,  but WITHOUT ANY WARRANTY;"
    echo "without even the implied warranty of  MERCHANTABILITY or FITNESS FOR A PAR-"
    echo "TICULAR PURPOSE."

    # Return success:
    exit 0
    ;;
  *)
    # Respond to a wrong or missing command:
    echo "Usage: $NAME COMMAND [OPTION...]" >&2
    echo "Try \`$NAME help' for more information." >&2

    # Return failure:
    exit 22
    ;;
esac