Browse Source

Add bin/wrt-help and bin/wrt-version

These display helptext and current version of the application,
respectively.

`wrt -h` and `wrt --help` still work, as do a new `wrt --version` and
`wrt -v`.  I think the subcommand forms are useful (and echo a growing
norm for this kind of interface), but the others should be discoverable
for users with traditional expectations.  Both basic help and version
info should be readily available without much thought, which I think
justifies the repetition.
Brennen Bearnes 3 months ago
parent
commit
292c0ceb62
4 changed files with 106 additions and 20 deletions
  1. 9
    19
      bin/wrt
  2. 52
    0
      bin/wrt-help
  3. 44
    0
      bin/wrt-version
  4. 1
    1
      lib/App/WRT.pm

+ 9
- 19
bin/wrt View File

@@ -41,30 +41,20 @@ Brennen Bearnes <code@p1k3.com>
41 41
 
42 42
 =cut
43 43
 
44
-print_help() {
45
-  echo "wrt - a writing tool"
46
-  echo
47
-  echo "Usage: $0 [command] [args]"
48
-  echo "    wrt init        Initialize a wrt repository"
49
-  echo "    wrt display     Print HTML for entries"
50
-  echo "    wrt render-all  Render all defined entries to filesystem"
51
-  echo "    wrt addprop     Add a property to an entry"
52
-  echo "    wrt findprop    Find entries containing certain properties"
53
-  echo "    wrt -h          Print this help message"
54
-  echo
55
-  echo "You must specify a command."
56
-  exit 1
57
-}
58
-
59 44
 if [ $# -lt 1 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
60
-  print_help
45
+  # No subcommand given or help requested:
46
+  exec wrt-help
47
+elif [ "$1" = "--version" ] || [ "$1" = "-v" ]; then
48
+  # Version info requested:
49
+  exec wrt-version
50
+else
51
+  # We should hand off to a requested subcommand:
52
+  subprog="wrt-$1"
61 53
 fi
62 54
 
63
-subprog="wrt-$1"
64
-
65 55
 # Make sure that the command we've been given exists:
66 56
 command -v "$subprog" >/dev/null 2>&1 || {
67
-  echo "wrt: '$1' is not a wrt command.  See 'wrt -h'."
57
+  echo "wrt: '$1' is not a wrt command.  See 'wrt help'."
68 58
   exit 1
69 59
 }
70 60
 

+ 52
- 0
bin/wrt-help View File

@@ -0,0 +1,52 @@
1
+#!/bin/sh
2
+
3
+: <<=cut
4
+=pod
5
+
6
+=head1 NAME
7
+
8
+wrt-help - print help for wrt, WRiting Tool
9
+
10
+=head1 SYNOPSIS
11
+
12
+    wrt help
13
+    wrt -h
14
+    wrt --help
15
+
16
+=head1 DESCRIPTION
17
+
18
+C<wrt-help> displays basic help for the wrt utility.
19
+
20
+Detailed documentation can be found in the L<App::WRT> man page or at
21
+L<https://code.p1k3.com/gitea/brennen/wrt>.
22
+
23
+=head1 LICENSE
24
+
25
+    wrt is free software; you can redistribute it and/or modify
26
+    it under the terms of the GNU General Public License as published by
27
+    the Free Software Foundation; either version 2 of the License, or
28
+    (at your option) any later version.
29
+
30
+=head1 AUTHOR
31
+
32
+Brennen Bearnes <code@p1k3.com>
33
+
34
+=cut
35
+
36
+print_help() {
37
+  echo "wrt - a writing tool"
38
+  echo
39
+  echo "Usage: $0 [command] [args]"
40
+  echo "    wrt init         Initialize a wrt repository"
41
+  echo "    wrt display      Print HTML for entries"
42
+  echo "    wrt render-all   Render all defined entries to filesystem"
43
+  echo "    wrt addprop      Add a property to an entry"
44
+  echo "    wrt findprop     Find entries containing certain properties"
45
+  echo "    wrt version, -v  Print the installed version of wrt"
46
+  echo "    wrt -h           Print this help message"
47
+  echo
48
+  echo "You must specify a command."
49
+}
50
+
51
+print_help
52
+exit 0

+ 44
- 0
bin/wrt-version View File

@@ -0,0 +1,44 @@
1
+#!/usr/bin/env perl
2
+
3
+=pod
4
+
5
+=head1 NAME
6
+
7
+wrt-version - print the installed version of wrt
8
+
9
+=head1 USAGE
10
+
11
+    wrt version
12
+    wrt --version
13
+    wrt -v
14
+
15
+=head1 DESCRIPTION
16
+
17
+C<wrt-version> displays the currently installed version of wrt.
18
+
19
+Detailed documentation for wrt can be found in the L<App::WRT> man page or at
20
+L<https://code.p1k3.com/gitea/brennen/wrt>.
21
+
22
+=head1 LICENSE
23
+
24
+    wrt is free software; you can redistribute it and/or modify
25
+    it under the terms of the GNU General Public License as published by
26
+    the Free Software Foundation; either version 2 of the License, or
27
+    (at your option) any later version.
28
+
29
+=head1 AUTHOR
30
+
31
+Brennen Bearnes <code@p1k3.com>
32
+
33
+=cut
34
+
35
+use 5.10.0;
36
+
37
+use strict;
38
+use warnings;
39
+no  warnings 'uninitialized';
40
+
41
+use App::WRT;
42
+
43
+print $App::WRT::VERSION;
44
+exit(0);

+ 1
- 1
lib/App/WRT.pm View File

@@ -1,6 +1,6 @@
1 1
 package App::WRT;
2 2
 
3
-use version; our $VERSION = version->declare("v6.0.0");
3
+use version; our $VERSION = version->declare("v6.1.0");
4 4
 
5 5
 use strict;
6 6
 use warnings;

Loading…
Cancel
Save