-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
executable file
·68 lines (56 loc) · 1.35 KB
/
template.php
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
#!/usr/bin/php5
<?php
$PROGNAME=basename($_SERVER["SCRIPT_NAME"]);
$VERSION="0.1.0";
$shortopts = "";
#$shortopts .= "f:"; // Required value
#$shortopts .= "v::"; // Optional value
#$shortopts .= "abc"; // These options do not accept values
$longopts = array(
#"required:", // Required value
#"optional::", // Optional value
#"option", // No value
#"opt", // No value
"debug", // No value
"version", // No value
"help", // No value
);
$options = getopt($shortopts, $longopts);
if ( array_key_exists ( "debug", $options )) {
$DEBUG=1;
}
if ( array_key_exists ( "version", $options )) {
print_version();
}
if ( array_key_exists ( "help", $options )) {
print_usage();
}
function print_version () {
global $PROGNAME;
global $VERSION;
print "$PROGNAME: version $VERSION\n";
exit;
}
function print_usage ($message="",$retval=0) {
if ( $message ) {
print "$message\n";
}
global $PROGNAME;
print "Usage: " . $PROGNAME . " [options] \n";
print <<<EOM
Options:
--debug debug output
--version print version information
--help show this message
EOM
;
exit ($retval);
}
function dprint ($string) {
#print if we have --debug flag set
global $DEBUG;
if ( $DEBUG ) {
print $string;
}
}
?>