[Bps-public-commit] SD - A distributed issue tracker branch, master, updated. b92a8441e6b92dbfad6cf24928622e634c47022a

spang at bestpractical.com spang at bestpractical.com
Fri Jan 30 09:53:16 EST 2009


The branch, master has been updated
       via  b92a8441e6b92dbfad6cf24928622e634c47022a (commit)
       via  4a26b1a59502204a2da0e56643e712aade2d4148 (commit)
       via  56ecb5720aa95e2367a0ec58887769c817d534ed (commit)
       via  14afa33ae93d67ac60e40fb076938dc38577db26 (commit)
       via  e2e5411c72e06f7eb38952cc93c188e32e093783 (commit)
       via  8c0b42d54abbfc41716066e12bf7fc2ddd069932 (commit)
       via  b75ef71af6dd9a578d555aa9c94bd2e5577fba9a (commit)
       via  66bd09fa805b76e2c179fa718c7de17ac55e8cd9 (commit)
       via  fe284d709650dc93f0a6d20b93597a7100eefa1a (commit)
      from  f5722661c233e5c6bab7bb07939d9cffebc6189d (commit)

Summary of changes:
 lib/App/SD/CLI/Command/Help.pm                     |   35 ++++----
 lib/App/SD/CLI/Command/Help/About.pm               |    6 +-
 lib/App/SD/CLI/Command/Help/Aliases.pm             |   49 ++++++++++
 lib/App/SD/CLI/Command/Help/Attachments.pm         |   15 ++--
 lib/App/SD/CLI/Command/Help/Authors.pm             |    2 +-
 lib/App/SD/CLI/Command/Help/Comments.pm            |   20 +++--
 lib/App/SD/CLI/Command/Help/Config.pm              |    9 ++-
 lib/App/SD/CLI/Command/Help/Environment.pm         |    8 +-
 lib/App/SD/CLI/Command/Help/History.pm             |   21 +++--
 lib/App/SD/CLI/Command/Help/Intro.pm               |   12 ++--
 lib/App/SD/CLI/Command/Help/Search.pm              |   45 +++++++---
 lib/App/SD/CLI/Command/Help/Settings.pm            |    8 +-
 lib/App/SD/CLI/Command/Help/Sync.pm                |   34 +++++---
 lib/App/SD/CLI/Command/Help/Tickets.pm             |   38 +++++---
 lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm |    4 +-
 lib/App/SD/CLI/Command/Ticket/Comment/Create.pm    |    2 +
 lib/App/SD/CLI/Command/Ticket/Create.pm            |    2 +
 lib/App/SD/CLI/Command/Ticket/Search.pm            |    2 +
 lib/App/SD/CLI/Command/Ticket/Show.pm              |    2 +
 lib/App/SD/CLI/Command/Ticket/Update.pm            |    1 +
 lib/App/SD/CLI/Dispatcher.pm                       |    1 +
 t/data/sd-ticket-create-verbose.tmpl               |    6 +-
 t/data/sd-ticket-create.tmpl                       |    6 +-
 t/data/sd-ticket-update-all-props.tmpl             |   14 ++--
 t/data/sd-ticket-update-verbose-all-props.tmpl     |   14 ++--
 t/data/sd-ticket-update-verbose.tmpl               |   16 ++--
 t/data/sd-ticket-update.tmpl                       |   16 ++--
 t/scripts/SDTestsEditor.pm                         |   95 +++++++++++++++++++
 t/scripts/settings-editor.pl                       |   88 +++++++++----------
 t/scripts/ticket-create-editor.pl                  |   63 ++++++--------
 t/scripts/ticket-update-editor.pl                  |   96 +++++++++-----------
 t/sd-settings.t                                    |    9 ++-
 32 files changed, 468 insertions(+), 271 deletions(-)
 create mode 100644 lib/App/SD/CLI/Command/Help/Aliases.pm
 create mode 100755 t/scripts/SDTestsEditor.pm

- Log -----------------------------------------------------------------
commit fe284d709650dc93f0a6d20b93597a7100eefa1a
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Jan 29 12:57:37 2009 +0200

    mention the sqlite backend

diff --git a/lib/App/SD/CLI/Command/Help/Environment.pm b/lib/App/SD/CLI/Command/Help/Environment.pm
index 6b9a627..8b9b327 100644
--- a/lib/App/SD/CLI/Command/Help/Environment.pm
+++ b/lib/App/SD/CLI/Command/Help/Environment.pm
@@ -24,8 +24,8 @@ configuration. Example syntax is for bash-like shells.
       tickets.
 
     export PROPHET_REPLICA_TYPE=prophet
-      Use the prophet native replica type. In the future other backend
-      replica types may be available.
+      Use the prophet native replica type. Other backend replica
+      types are: sqlite.
 
     export SD_REPO=/path/to/sd/replica
       Specify where the ticket database SD is using should reside.

commit 66bd09fa805b76e2c179fa718c7de17ac55e8cd9
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Jan 29 12:58:24 2009 +0200

    might as well tell people to use the sugar

diff --git a/lib/App/SD/CLI/Command/Help/Intro.pm b/lib/App/SD/CLI/Command/Help/Intro.pm
index 9c0a925..033d1d7 100644
--- a/lib/App/SD/CLI/Command/Help/Intro.pm
+++ b/lib/App/SD/CLI/Command/Help/Intro.pm
@@ -22,7 +22,7 @@ environment variable.
 
 To clone a ticket database:
 
-    $cmd clone --from http://example.com/path/to/sd
+    $cmd clone http://example.com/path/to/sd
 
 To start a new ticket database:
 
@@ -34,7 +34,7 @@ To create a ticket, run:
 
 To publish your database:
 
-    $cmd publish --to joeuser\@myhost.example.com:public_html/mydb
+    $cmd publish joeuser\@myhost.example.com:public_html/mydb
 
 To learn a bit more about what you can do with SD:
 
diff --git a/lib/App/SD/CLI/Command/Help/Sync.pm b/lib/App/SD/CLI/Command/Help/Sync.pm
index 39e24e7..279aa1a 100644
--- a/lib/App/SD/CLI/Command/Help/Sync.pm
+++ b/lib/App/SD/CLI/Command/Help/Sync.pm
@@ -9,11 +9,11 @@ sub run {
 
 print <<EOF
 
-    $cmd clone --from http://example.com/path/to/sd
+    $cmd clone http://example.com/path/to/sd
       Create a new copy (replica) of a published SD replica from an
       http, ftp or file URL.
 
-    $cmd pull --from http://example.com/path/to/sd
+    $cmd pull http://example.com/path/to/sd
       Integrate changes from a published SD replica over http, ftp or 
       file URL.
 
@@ -23,9 +23,9 @@ print <<EOF
 
     $cmd pull --local
       Integrate changes from all replicas currently announcing themselves
-      on the local network using Bonjour
+      on the local network using Bonjour.
 
-    $cmd publish --to jesse\@server:path/to/destination
+    $cmd publish jesse\@server:path/to/destination
       Publish a copy of this replica to a remote server using rsync.
 
     $cmd publish --html --replica --to jesse\@server:path/to/destination
@@ -49,11 +49,11 @@ replica types for RT (http://bestpractical.com/rt) and Hiveminder
 your bug tracker, you should get in touch with SD's developers (see
 http://syncwith.us/contact).
 
-    $cmd push --to rt:http://rt3.fsck.com|rt3|Owner='jesse'
+    $cmd push rt:http://rt3.fsck.com|rt3|Owner='jesse'
       Push changes to the given foreign replica. Foreign replica
       schemas will vary based on the replica type.
 
-    $cmd pull --from rt:http://rt3.fsck.com|rt3|Owner='jesse'
+    $cmd pull rt:http://rt3.fsck.com|rt3|Owner='jesse'
       Pull changes from a foreign replica to be merged into the
       local replica.
 EOF

commit b75ef71af6dd9a578d555aa9c94bd2e5577fba9a
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Jan 29 13:47:54 2009 +0200

    make settings --set help not wrong

diff --git a/lib/App/SD/CLI/Command/Help/Settings.pm b/lib/App/SD/CLI/Command/Help/Settings.pm
index f55e763..119e08c 100644
--- a/lib/App/SD/CLI/Command/Help/Settings.pm
+++ b/lib/App/SD/CLI/Command/Help/Settings.pm
@@ -21,7 +21,7 @@ The following arguments are supported:
       Don't present an editor window, just print the current
       settings to STDOUT.
 
-    --set common_ticket_props '["id", "summary", "original_replica"]'
+    --set -- common_ticket_props '["id", "summary", "original_replica"]'
       Update the setting common_ticket_props to the given value.
 
 Settings are not the same as local configuration variables. For

commit 8c0b42d54abbfc41716066e12bf7fc2ddd069932
Author: Christine Spang <spang at bestpractical.com>
Date:   Thu Jan 29 22:29:40 2009 +0200

    add in arg shortcuts

diff --git a/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm b/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
index 96cddf1..c269bf8 100644
--- a/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Attachment/Create.pm
@@ -1,8 +1,10 @@
 package App::SD::CLI::Command::Ticket::Attachment::Create;
 use Moose;
 extends 'App::SD::CLI::Command::Attachment::Create';
-# override args to feed in that ticket's uuid as an argument to the comment
 
+__PACKAGE__->register_arg_translations( f => 'file' );
+
+# override args to feed in that ticket's uuid as an argument to the comment
 before run => sub {
     my $self = shift;
     $self->require_uuid;
diff --git a/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm b/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
index 0b9490d..4a39af5 100644
--- a/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Comment/Create.pm
@@ -5,6 +5,8 @@ extends 'Prophet::CLI::Command::Create';
 with 'App::SD::CLI::Model::TicketComment';
 with 'App::SD::CLI::Command';
 
+__PACKAGE__->register_arg_translations( f => 'file', m => 'content' );
+
 # override args to feed in that ticket's uuid as an argument to the comment
 before run => sub {
     my $self = shift;
diff --git a/lib/App/SD/CLI/Command/Ticket/Create.pm b/lib/App/SD/CLI/Command/Ticket/Create.pm
index 9ff341f..6164266 100644
--- a/lib/App/SD/CLI/Command/Ticket/Create.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Create.pm
@@ -7,6 +7,8 @@ with 'App::SD::CLI::Model::Ticket';
 with 'App::SD::CLI::Command';
 with 'Prophet::CLI::TextEditorCommand';
 
+__PACKAGE__->register_arg_translations( e => 'edit' );
+
 # we want to launch an $EDITOR window to grab props and a comment if no
 # props are specified on the commandline
 
diff --git a/lib/App/SD/CLI/Command/Ticket/Search.pm b/lib/App/SD/CLI/Command/Ticket/Search.pm
index 2bfd898..ee49df3 100644
--- a/lib/App/SD/CLI/Command/Ticket/Search.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Search.pm
@@ -3,6 +3,8 @@ use Moose;
 extends 'Prophet::CLI::Command::Search';
 with 'App::SD::CLI::Command';
 
+__PACKAGE__->register_arg_translations( s => 'sort', g => 'group' );
+
 # frob the sort routine before running prophet's search command
 before run => sub {
     my $self = shift;
diff --git a/lib/App/SD/CLI/Command/Ticket/Show.pm b/lib/App/SD/CLI/Command/Ticket/Show.pm
index ecbce0a..35a3652 100644
--- a/lib/App/SD/CLI/Command/Ticket/Show.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Show.pm
@@ -4,6 +4,8 @@ extends 'Prophet::CLI::Command::Show';
 with 'App::SD::CLI::Command';
 with 'App::SD::CLI::Model::Ticket';
 
+__PACKAGE__->register_arg_translations( a => 'all-props', s => 'skip-history',
+                                        h => 'with-history', b => 'batch' );
 
 sub by_creation_date { $a->prop('created') cmp $b->prop('created') };
 
diff --git a/lib/App/SD/CLI/Command/Ticket/Update.pm b/lib/App/SD/CLI/Command/Ticket/Update.pm
index 0b7ddd3..c1bcb59 100644
--- a/lib/App/SD/CLI/Command/Ticket/Update.pm
+++ b/lib/App/SD/CLI/Command/Ticket/Update.pm
@@ -7,6 +7,7 @@ with 'App::SD::CLI::Model::Ticket';
 with 'App::SD::CLI::Command';
 with 'Prophet::CLI::TextEditorCommand';
 
+__PACKAGE__->register_arg_translations( a => 'all-props' );
 
 # use an editor to edit if no props are specified on the commandline,
 # allowing the creation of a new comment in the process

commit e2e5411c72e06f7eb38952cc93c188e32e093783
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 30 10:41:59 2009 +0200

    doc shortcuts

diff --git a/lib/App/SD/CLI/Command/Help/Attachments.pm b/lib/App/SD/CLI/Command/Help/Attachments.pm
index 2db9b48..4c29a2f 100644
--- a/lib/App/SD/CLI/Command/Help/Attachments.pm
+++ b/lib/App/SD/CLI/Command/Help/Attachments.pm
@@ -12,6 +12,9 @@ print <<EOF
     $cmd ticket attachment create 456 --file bugfix.patch
       Create a new attachment on this ticket from the file 'bugfix.patch'.
 
+    $cmd ticket attachment create 456 -f bugfix.patch
+      -f is a shortcut for --file for this command.
+
     $cmd ticket attachment list 456
       Show all attachemnts on ticket 456.
 
diff --git a/lib/App/SD/CLI/Command/Help/Comments.pm b/lib/App/SD/CLI/Command/Help/Comments.pm
index ba121e4..2f66336 100644
--- a/lib/App/SD/CLI/Command/Help/Comments.pm
+++ b/lib/App/SD/CLI/Command/Help/Comments.pm
@@ -15,10 +15,16 @@ print <<EOF
     $cmd ticket comment 456 --file=myfile
       Add a comment to the ticket with id 456, using the content of 'myfile'.
 
+    $cmd ticket comment 456 -f myfile
+      -f is a shortcut for --file for this command.
+
     $cmd ticket comment 456 --content="The text of the comment."
       Add a comment to the ticket with id 456, specifying its content on
       the commandline.
 
+    $cmd ticket comment 456 -m "The text of the comment."
+      -m is a shortcut for --content for this command.
+
     $cmd ticket comment list
       List all ticket comments.
 
diff --git a/lib/App/SD/CLI/Command/Help/Config.pm b/lib/App/SD/CLI/Command/Help/Config.pm
index c6b77c7..6caafc3 100644
--- a/lib/App/SD/CLI/Command/Help/Config.pm
+++ b/lib/App/SD/CLI/Command/Help/Config.pm
@@ -12,6 +12,9 @@ SD supports both a user-wide configuration file (\$HOME/.sdrc and
 per-database configuration file (/path/to/repo/sdrc). If both configuration
 files are present, the database-specific config file will be used.
 
+You can use the '$cmd config' command to view what configuration file
+SD is loading and what it contains.
+
 Currently, the following configuration variables are available:
 
     email_address = foo\@bar.com
diff --git a/lib/App/SD/CLI/Command/Help/History.pm b/lib/App/SD/CLI/Command/Help/History.pm
index 5cfb70f..35b17c1 100644
--- a/lib/App/SD/CLI/Command/Help/History.pm
+++ b/lib/App/SD/CLI/Command/Help/History.pm
@@ -17,6 +17,9 @@ command. It can be run in the following ways:
     $cmd log --all
       Shows the entire history from start to end.
 
+    $cmd log -a
+      -a is a shortcut for --all.
+
     $cmd log <since>..<until>
       Shows the range of history starting at <since> and ending at
       <until>. Ranges can be specified using either sequence numbers
diff --git a/lib/App/SD/CLI/Command/Help/Search.pm b/lib/App/SD/CLI/Command/Help/Search.pm
index 0ab6e28..88a39a2 100644
--- a/lib/App/SD/CLI/Command/Help/Search.pm
+++ b/lib/App/SD/CLI/Command/Help/Search.pm
@@ -25,6 +25,16 @@ print <<EOF
        List all tickets with a status that does not match 'closed', 
        grouped by owner.
 
+    $cmd ticket search -g owner
+      -g is a shortcut for --group for this command.
+
+    $cmd ticket search --sort due
+       List all tickets with a status that does not match 'closed',
+       sorted by due date.
+
+    $cmd ticket search -s due
+      -s is a shortcut for --sort for this command.
+
     $cmd ticket basics 1234
       Show basic information (metadata only) for the ticket with local id 1234.
 
@@ -37,15 +47,24 @@ print <<EOF
       the database setting common_ticket_props (or local configuration
       variable 'common_ticket_props' if it exists).
 
+    $cmd ticket show 1234 -a
+      -a is a shortcut for --all-props for this command.
+
     $cmd ticket show 1234 --skip-history
       Show only metadata and comments for the ticket 1234 (but not
       history).
 
+    $cmd ticket show 1234 -s
+      -s is a shortcut for --skip-history for this command.
+
     $cmd ticket show 1234 --with-history
       Override the disable_ticket_show_history_by_default config option
       if it is set for this database. (See '$cmd help config' for
       more info.)
 
+    $cmd ticket show 1234 -h
+      -h is a shortcut for --with-history for this command.
+
     $cmd ticket history 1234
       Show history for the ticket with local id 1234.
 
diff --git a/lib/App/SD/CLI/Command/Help/Settings.pm b/lib/App/SD/CLI/Command/Help/Settings.pm
index 119e08c..e996eff 100644
--- a/lib/App/SD/CLI/Command/Help/Settings.pm
+++ b/lib/App/SD/CLI/Command/Help/Settings.pm
@@ -17,7 +17,7 @@ must be valid JSON data structures.
 
 The following arguments are supported:
 
-    --show
+    --show (or -s)
       Don't present an editor window, just print the current
       settings to STDOUT.
 
diff --git a/lib/App/SD/CLI/Command/Help/Sync.pm b/lib/App/SD/CLI/Command/Help/Sync.pm
index 279aa1a..71027fe 100644
--- a/lib/App/SD/CLI/Command/Help/Sync.pm
+++ b/lib/App/SD/CLI/Command/Help/Sync.pm
@@ -21,10 +21,16 @@ print <<EOF
       Integrate changes from all replicas this replica has pulled from
       before.
 
+    $cmd pull -a
+      -a is a shortcut for --all for this command.
+
     $cmd pull --local
       Integrate changes from all replicas currently announcing themselves
       on the local network using Bonjour.
 
+    $cmd pull -l
+      -l is a shortcut for --local for this command.
+
     $cmd publish jesse\@server:path/to/destination
       Publish a copy of this replica to a remote server using rsync.
 
@@ -43,6 +49,10 @@ print <<EOF
       replica modifiable, browsable and pullable by ANYONE with remote
       access to your computer.
 
+    $cmd server -w -p 9876
+      -w is a shortcut for --writable and -p is a shortcut for --port
+      for this command.
+
 SD can sync to external systems as well as itself. Currently, there are foreign
 replica types for RT (http://bestpractical.com/rt) and Hiveminder
 (http://hiveminder.com/). If you're interested in building a replica type for
diff --git a/lib/App/SD/CLI/Command/Help/Tickets.pm b/lib/App/SD/CLI/Command/Help/Tickets.pm
index 46c584a..ee5c8d0 100644
--- a/lib/App/SD/CLI/Command/Help/Tickets.pm
+++ b/lib/App/SD/CLI/Command/Help/Tickets.pm
@@ -17,6 +17,9 @@ print <<EOF
       and also shows descriptions and valid values for
       properties.
 
+    $cmd ticket create -v
+      -v is a shortcut for --verbose for this command.
+
     $cmd ticket create -- summary="This is a summary" status=open
       Create a new ticket non-interactively.
 
@@ -32,12 +35,18 @@ print <<EOF
       Interactively update the ticket with local id 123 in a text
       editor and show descriptions and valid values for props.
 
+    $cmd ticket update 123 -v
+      -v is a shortcut for --verbose for this command.
+
     $cmd ticket update 123 --all-props
       Interactively update the ticket with local id 123 in a text
       editor, presenting all the props of the record for editing instead of
       just those specified by the database setting 'common_ticket_props'
       (or local configuration variable 'common_ticket_props' if it exists).
 
+    $cmd ticket update 123 -a
+      -a is a shortcut for --all-props for this command.
+
     $cmd ticket update fad5849a-67f1-11dd-bde1-5b33d3ff2799 -- status=closed
       Sets the status of the ticket with uuid
       fad5849a-67f1-11dd-bde1-5b33d3ff2799 to closed.
@@ -58,6 +67,9 @@ print <<EOF
       Sets the status of the ticket with local id 123 to closed,
       allowing you to edit any properties in an editor and
       optionally add a comment in the process.
+
+    $cmd ticket resolve 123 -e
+      -e is a shortcut for --edit for this command.
 EOF
 
 }

commit 14afa33ae93d67ac60e40fb076938dc38577db26
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 30 11:10:28 2009 +0200

    doc aliases

diff --git a/lib/App/SD/CLI/Command/Help.pm b/lib/App/SD/CLI/Command/Help.pm
index e3b1c0e..2dd311c 100644
--- a/lib/App/SD/CLI/Command/Help.pm
+++ b/lib/App/SD/CLI/Command/Help.pm
@@ -53,6 +53,7 @@ $cmd help history     -  Viewing repository history
 $cmd help environment -  Environment variables which affect sd
 $cmd help config      -  Local configuration variables
 $cmd help summary_format_ticket  -  Details of this config variable
+$cmd help aliases     -  Command aliases
 $cmd help settings    -  Database configuration variables
 
 Running '$cmd help' on a specific command should also redirect you
diff --git a/lib/App/SD/CLI/Command/Help/Aliases.pm b/lib/App/SD/CLI/Command/Help/Aliases.pm
new file mode 100644
index 0000000..1921c33
--- /dev/null
+++ b/lib/App/SD/CLI/Command/Help/Aliases.pm
@@ -0,0 +1,49 @@
+package App::SD::CLI::Command::Help::Aliases;
+use Moose;
+extends 'App::SD::CLI::Command::Help';
+
+sub run {
+    my $self = shift;
+    $self->print_header('Command Aliases');
+    my $cmd = $self->_get_cmd_name;
+
+print <<EOF
+
+You can create custom command aliases in your local configuration file.
+The format is as follows:
+
+    alias command to type = command to translate it to
+
+As an example, you could create an alias to show all tickets assigned
+to you with the alias 'mine':
+
+    alias mine = ticket list -- owner=you\@domain.com status !~closed|rejected
+
+SD also provides a command for managing aliases: '$cmd aliases'. If
+given no arguments, the aliases command will present you with an editor
+window in which aliases can be modified. Aliases will be saved to your
+local configuration file when editing is done.
+
+The following arguments are supported:
+
+    --show (or -s)
+      Don't present an editor window, just print the current aliases
+      to STDOUT.
+
+    --add (or -a) 'command to type = command to translate to'
+      Add a new alias from the command line.
+
+    --delete (or -d) 'command to type'
+      Delete an existing alias from the command line.
+
+For more information on local configuration files, see '$cmd help config'.
+
+EOF
+
+}
+
+__PACKAGE__->meta->make_immutable;
+no Moose;
+
+1;
+
diff --git a/lib/App/SD/CLI/Dispatcher.pm b/lib/App/SD/CLI/Dispatcher.pm
index 67ca194..7ddf76c 100644
--- a/lib/App/SD/CLI/Dispatcher.pm
+++ b/lib/App/SD/CLI/Dispatcher.pm
@@ -26,6 +26,7 @@ under help => sub {
     on [ ['comment', 'comments'] ]       => run_command('Help::Comments');
     on [ ['setting', 'settings'] ]       => run_command('Help::Settings');
     on [ ['history', 'log'] ]            => run_command('Help::History');
+    on [ ['alias', 'aliases'] ]          => run_command('Help::Aliases');
 
     on [
         ['ticket', 'attachment', 'comment'],

commit 56ecb5720aa95e2367a0ec58887769c817d534ed
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 30 12:07:55 2009 +0200

    make a slight change to _get_cmd_name so we can eliminate the stray space that appears in help entries from the sd shell

diff --git a/lib/App/SD/CLI/Command/Help.pm b/lib/App/SD/CLI/Command/Help.pm
index 2dd311c..2191194 100644
--- a/lib/App/SD/CLI/Command/Help.pm
+++ b/lib/App/SD/CLI/Command/Help.pm
@@ -11,9 +11,9 @@ sub title {
 sub _get_cmd_name {
     my $self = shift;
     return '' if $self->cli->interactive_shell;
-    my $cmd = $0;
-    $cmd =~ s{^(.*)/}{}g;
-    return $cmd;
+    my ${cmd}= $0;
+    ${cmd}=~ s{^(.*)/}{}g;
+    return $cmd.' ';
 }
 
 sub version {
@@ -36,27 +36,27 @@ sub print_header {
 
 sub run {
     my $self = shift;
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
     $self->print_header("Help Index");
 
 
 print <<EOF
 
-$cmd help intro       -  Getting started with SD
-$cmd help search      -  Searching for and displaying tickets
-$cmd help tickets     -  Working with tickets
-$cmd help comments    -  Working with ticket comments
-$cmd help attachments -  Working with ticket attachments
-$cmd help sync        -  Publishing and importing ticket databases
-$cmd help history     -  Viewing repository history
-$cmd help environment -  Environment variables which affect sd
-$cmd help config      -  Local configuration variables
-$cmd help summary_format_ticket  -  Details of this config variable
-$cmd help aliases     -  Command aliases
-$cmd help settings    -  Database configuration variables
-
-Running '$cmd help' on a specific command should also redirect you
+${cmd}help intro       -  Getting started with SD
+${cmd}help search      -  Searching for and displaying tickets
+${cmd}help tickets     -  Working with tickets
+${cmd}help comments    -  Working with ticket comments
+${cmd}help attachments -  Working with ticket attachments
+${cmd}help sync        -  Publishing and importing ticket databases
+${cmd}help history     -  Viewing repository history
+${cmd}help environment -  Environment variables which affect sd
+${cmd}help config      -  Local configuration variables
+${cmd}help summary_format_ticket  -  Details of this config variable
+${cmd}help aliases     -  Command aliases
+${cmd}help settings    -  Database configuration variables
+
+Running '${cmd}help' on a specific command should also redirect you
 to the proper help file.
 
 EOF
diff --git a/lib/App/SD/CLI/Command/Help/About.pm b/lib/App/SD/CLI/Command/Help/About.pm
index c41db22..d320343 100644
--- a/lib/App/SD/CLI/Command/Help/About.pm
+++ b/lib/App/SD/CLI/Command/Help/About.pm
@@ -4,7 +4,7 @@ extends 'App::SD::CLI::Command::Help';
 
 sub run {
     my $self = shift;
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
     $self->print_header('About SD');
 
 print <<EOF
@@ -17,7 +17,7 @@ sd was originally conceived and designed by Jesse Vincent and Chia-liang
 Kao at Best Practical Solutions. Many others have contributed to sd.
 For a full author list, type:
 
-    $cmd help authors
+    ${cmd}help authors
 
 sd is open-source software, distributed under the terms of the MIT
 license. You are free to use this software, modify it and redistribute
@@ -26,7 +26,7 @@ to this software, however, the authors would appreciate it if you
 would contribute improvements so that they may be shared with the
 community. For license details, type:
 
-    $cmd help copying
+    ${cmd}help copying
 EOF
 
 }
diff --git a/lib/App/SD/CLI/Command/Help/Aliases.pm b/lib/App/SD/CLI/Command/Help/Aliases.pm
index 1921c33..78ee444 100644
--- a/lib/App/SD/CLI/Command/Help/Aliases.pm
+++ b/lib/App/SD/CLI/Command/Help/Aliases.pm
@@ -5,7 +5,7 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Command Aliases');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
@@ -19,7 +19,7 @@ to you with the alias 'mine':
 
     alias mine = ticket list -- owner=you\@domain.com status !~closed|rejected
 
-SD also provides a command for managing aliases: '$cmd aliases'. If
+SD also provides a command for managing aliases: '${cmd}aliases'. If
 given no arguments, the aliases command will present you with an editor
 window in which aliases can be modified. Aliases will be saved to your
 local configuration file when editing is done.
@@ -36,7 +36,7 @@ The following arguments are supported:
     --delete (or -d) 'command to type'
       Delete an existing alias from the command line.
 
-For more information on local configuration files, see '$cmd help config'.
+For more information on local configuration files, see '${cmd}help config'.
 
 EOF
 
diff --git a/lib/App/SD/CLI/Command/Help/Attachments.pm b/lib/App/SD/CLI/Command/Help/Attachments.pm
index 4c29a2f..9b8c39c 100644
--- a/lib/App/SD/CLI/Command/Help/Attachments.pm
+++ b/lib/App/SD/CLI/Command/Help/Attachments.pm
@@ -5,26 +5,26 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Working with ticket attachments');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
-    $cmd ticket attachment create 456 --file bugfix.patch
+    ${cmd}ticket attachment create 456 --file bugfix.patch
       Create a new attachment on this ticket from the file 'bugfix.patch'.
 
-    $cmd ticket attachment create 456 -f bugfix.patch
+    ${cmd}ticket attachment create 456 -f bugfix.patch
       -f is a shortcut for --file for this command.
 
-    $cmd ticket attachment list 456
+    ${cmd}ticket attachment list 456
       Show all attachemnts on ticket 456.
 
-    $cmd ticket attachment show 567
+    ${cmd}ticket attachment show 567
       Show the properties of attachment 567 (including the content).
 
-    $cmd ticket attachment content 567
+    ${cmd}ticket attachment content 567
       Send the content of attachment 567 to STDOUT.
 
-    $cmd ticket attachment content 567 > to_apply.patch
+    ${cmd}ticket attachment content 567 > to_apply.patch
       Save the contents of attachment 567 to a file so the patch
       can be applied.
 EOF
diff --git a/lib/App/SD/CLI/Command/Help/Authors.pm b/lib/App/SD/CLI/Command/Help/Authors.pm
index 03ae288..78e6818 100644
--- a/lib/App/SD/CLI/Command/Help/Authors.pm
+++ b/lib/App/SD/CLI/Command/Help/Authors.pm
@@ -4,7 +4,7 @@ extends 'App::SD::CLI::Command::Help';
 
 sub run {
     my $self = shift;
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
     $self->print_header("Authors");
 
 print <<EOF
diff --git a/lib/App/SD/CLI/Command/Help/Comments.pm b/lib/App/SD/CLI/Command/Help/Comments.pm
index 2f66336..bb5a9c4 100644
--- a/lib/App/SD/CLI/Command/Help/Comments.pm
+++ b/lib/App/SD/CLI/Command/Help/Comments.pm
@@ -5,33 +5,33 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Working with ticket comments');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
-    $cmd ticket comment 456
+    ${cmd}ticket comment 456
       Add a comment to the ticket with id 456, popping up a text editor.
 
-    $cmd ticket comment 456 --file=myfile
+    ${cmd}ticket comment 456 --file=myfile
       Add a comment to the ticket with id 456, using the content of 'myfile'.
 
-    $cmd ticket comment 456 -f myfile
+    ${cmd}ticket comment 456 -f myfile
       -f is a shortcut for --file for this command.
 
-    $cmd ticket comment 456 --content="The text of the comment."
+    ${cmd}ticket comment 456 --content="The text of the comment."
       Add a comment to the ticket with id 456, specifying its content on
       the commandline.
 
-    $cmd ticket comment 456 -m "The text of the comment."
+    ${cmd}ticket comment 456 -m "The text of the comment."
       -m is a shortcut for --content for this command.
 
-    $cmd ticket comment list
+    ${cmd}ticket comment list
       List all ticket comments.
 
-    $cmd ticket comment show 4
+    ${cmd}ticket comment show 4
       Show ticket comment 4 and all metadata.
 
-    $cmd ticket comments 9
+    ${cmd}ticket comments 9
       Show all comments belonging to the ticket with id 9.
 EOF
 
diff --git a/lib/App/SD/CLI/Command/Help/Config.pm b/lib/App/SD/CLI/Command/Help/Config.pm
index 6caafc3..cc1f80f 100644
--- a/lib/App/SD/CLI/Command/Help/Config.pm
+++ b/lib/App/SD/CLI/Command/Help/Config.pm
@@ -5,14 +5,14 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Configuration Options');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 SD supports both a user-wide configuration file (\$HOME/.sdrc and
 per-database configuration file (/path/to/repo/sdrc). If both configuration
 files are present, the database-specific config file will be used.
 
-You can use the '$cmd config' command to view what configuration file
+You can use the '${cmd}config' command to view what configuration file
 SD is loading and what it contains.
 
 Currently, the following configuration variables are available:
@@ -35,7 +35,7 @@ Currently, the following configuration variables are available:
       property.)
 
     disable_ticket_show_history_by_default = 1
-      Don't display ticket history when running '$cmd ticket show'. Can
+      Don't display ticket history when running '${cmd}ticket show'. Can
       be overridden by passing the '--with-history' arg to the
       command.
 
@@ -47,7 +47,7 @@ Currently, the following configuration variables are available:
       setting of the same name.)
 
 For information on environmental variables that can affect SD, see
-'$cmd help environment'.
+'${cmd}help environment'.
 EOF
 
 }
diff --git a/lib/App/SD/CLI/Command/Help/Environment.pm b/lib/App/SD/CLI/Command/Help/Environment.pm
index 8b9b327..0d804b6 100644
--- a/lib/App/SD/CLI/Command/Help/Environment.pm
+++ b/lib/App/SD/CLI/Command/Help/Environment.pm
@@ -5,7 +5,7 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Environment variables');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
@@ -39,7 +39,7 @@ configuration. Example syntax is for bash-like shells.
     export PROPHET_HISTLENGTH=100
       Specify how much history the interactive shell should store.
 
-For information on SD database configuration files, see '$cmd help config'.
+For information on SD database configuration files, see '${cmd}help config'.
 EOF
 
 }
diff --git a/lib/App/SD/CLI/Command/Help/History.pm b/lib/App/SD/CLI/Command/Help/History.pm
index 35b17c1..3dac839 100644
--- a/lib/App/SD/CLI/Command/Help/History.pm
+++ b/lib/App/SD/CLI/Command/Help/History.pm
@@ -5,22 +5,22 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Viewing Database History');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 You can view a history of all changes to the database using the 'log'
 command. It can be run in the following ways:
 
-    $cmd log
+    ${cmd}log
       Shows the last 20 changes.
 
-    $cmd log --all
+    ${cmd}log --all
       Shows the entire history from start to end.
 
-    $cmd log -a
+    ${cmd}log -a
       -a is a shortcut for --all.
 
-    $cmd log <since>..<until>
+    ${cmd}log <since>..<until>
       Shows the range of history starting at <since> and ending at
       <until>. Ranges can be specified using either sequence numbers
       or an offset from the most recent change, designated by
@@ -28,20 +28,20 @@ command. It can be run in the following ways:
 
 Examples:
 
-    $cmd log 0..5
+    ${cmd}log 0..5
       Shows changes 0 through 5.
 
-    $cmd log LATEST
+    ${cmd}log LATEST
       Shows the most recent change.
 
-    $cmd log LATEST~4
+    ${cmd}log LATEST~4
       Shows changes from 4 before the most recent change up to the most
       recent change.
 
-    $cmd log 2..LATEST~5
+    ${cmd}log 2..LATEST~5
       Shows the second change up through 5 before the latest.
 
-    $cmd log LATEST~10..LATEST~5
+    ${cmd}log LATEST~10..LATEST~5
       Shows changes from 10 before the latest to 5 before the latest.
 EOF
 
diff --git a/lib/App/SD/CLI/Command/Help/Intro.pm b/lib/App/SD/CLI/Command/Help/Intro.pm
index 033d1d7..55ee645 100644
--- a/lib/App/SD/CLI/Command/Help/Intro.pm
+++ b/lib/App/SD/CLI/Command/Help/Intro.pm
@@ -5,7 +5,7 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Getting started with SD');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 SD is a peer to peer ticket tracking system built on the Prophet 
@@ -22,23 +22,23 @@ environment variable.
 
 To clone a ticket database:
 
-    $cmd clone http://example.com/path/to/sd
+    ${cmd}clone http://example.com/path/to/sd
 
 To start a new ticket database:
 
-    $cmd init
+    ${cmd}init
 
 To create a ticket, run:
 
-    $cmd ticket create
+    ${cmd}ticket create
 
 To publish your database:
 
-    $cmd publish joeuser\@myhost.example.com:public_html/mydb
+    ${cmd}publish joeuser\@myhost.example.com:public_html/mydb
 
 To learn a bit more about what you can do with SD:
 
-    $cmd help
+    ${cmd}help
 EOF
 
 }
diff --git a/lib/App/SD/CLI/Command/Help/Search.pm b/lib/App/SD/CLI/Command/Help/Search.pm
index 88a39a2..9007f98 100644
--- a/lib/App/SD/CLI/Command/Help/Search.pm
+++ b/lib/App/SD/CLI/Command/Help/Search.pm
@@ -5,70 +5,70 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Searching for and displaying tickets');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
-    $cmd ticket search
+    ${cmd}ticket search
       List all tickets with a status that does not match 'closed'.
       Note that 'list' is an alias for 'search'.
 
-    $cmd ticket search --regex abc
+    ${cmd}ticket search --regex abc
       List all tickets with content matching 'abc'. Regular
       expressions are Perl regexes.
 
-    $cmd ticket search -- status!=closed summary =~ http 
+    ${cmd}ticket search -- status!=closed summary =~ http 
       List all tickets with a status that does match closed
       and a summary matching 'http'.
 
-    $cmd ticket search --group owner
+    ${cmd}ticket search --group owner
        List all tickets with a status that does not match 'closed', 
        grouped by owner.
 
-    $cmd ticket search -g owner
+    ${cmd}ticket search -g owner
       -g is a shortcut for --group for this command.
 
-    $cmd ticket search --sort due
+    ${cmd}ticket search --sort due
        List all tickets with a status that does not match 'closed',
        sorted by due date.
 
-    $cmd ticket search -s due
+    ${cmd}ticket search -s due
       -s is a shortcut for --sort for this command.
 
-    $cmd ticket basics 1234
+    ${cmd}ticket basics 1234
       Show basic information (metadata only) for the ticket with local id 1234.
 
-    $cmd ticket show 1234
+    ${cmd}ticket show 1234
       Show basic information, comments, and history for the ticket with local
       id 1234.  ('details' is an alias for 'show')
 
-    $cmd ticket show 1234 --all-props
+    ${cmd}ticket show 1234 --all-props
       Show all properties of the given ticket, even if they aren't in
       the database setting common_ticket_props (or local configuration
       variable 'common_ticket_props' if it exists).
 
-    $cmd ticket show 1234 -a
+    ${cmd}ticket show 1234 -a
       -a is a shortcut for --all-props for this command.
 
-    $cmd ticket show 1234 --skip-history
+    ${cmd}ticket show 1234 --skip-history
       Show only metadata and comments for the ticket 1234 (but not
       history).
 
-    $cmd ticket show 1234 -s
+    ${cmd}ticket show 1234 -s
       -s is a shortcut for --skip-history for this command.
 
-    $cmd ticket show 1234 --with-history
+    ${cmd}ticket show 1234 --with-history
       Override the disable_ticket_show_history_by_default config option
-      if it is set for this database. (See '$cmd help config' for
+      if it is set for this database. (See '${cmd}help config' for
       more info.)
 
-    $cmd ticket show 1234 -h
+    ${cmd}ticket show 1234 -h
       -h is a shortcut for --with-history for this command.
 
-    $cmd ticket history 1234
+    ${cmd}ticket history 1234
       Show history for the ticket with local id 1234.
 
-    $cmd ticket delete 1234
+    ${cmd}ticket delete 1234
       Delete ticket with local id 1234.
 EOF
 
diff --git a/lib/App/SD/CLI/Command/Help/Settings.pm b/lib/App/SD/CLI/Command/Help/Settings.pm
index e996eff..a84cc4b 100644
--- a/lib/App/SD/CLI/Command/Help/Settings.pm
+++ b/lib/App/SD/CLI/Command/Help/Settings.pm
@@ -5,7 +5,7 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Database Settings');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 The 'settings' command allows you to modify configuration variables
@@ -25,7 +25,7 @@ The following arguments are supported:
       Update the setting common_ticket_props to the given value.
 
 Settings are not the same as local configuration variables. For
-more information on local configuration, see '$cmd help config'.
+more information on local configuration, see '${cmd}help config'.
 
 EOF
 
diff --git a/lib/App/SD/CLI/Command/Help/Sync.pm b/lib/App/SD/CLI/Command/Help/Sync.pm
index 71027fe..5d0a4cb 100644
--- a/lib/App/SD/CLI/Command/Help/Sync.pm
+++ b/lib/App/SD/CLI/Command/Help/Sync.pm
@@ -5,51 +5,51 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Sharing ticket databases');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
 
-    $cmd clone http://example.com/path/to/sd
+    ${cmd}clone http://example.com/path/to/sd
       Create a new copy (replica) of a published SD replica from an
       http, ftp or file URL.
 
-    $cmd pull http://example.com/path/to/sd
+    ${cmd}pull http://example.com/path/to/sd
       Integrate changes from a published SD replica over http, ftp or 
       file URL.
 
-    $cmd pull --all
+    ${cmd}pull --all
       Integrate changes from all replicas this replica has pulled from
       before.
 
-    $cmd pull -a
+    ${cmd}pull -a
       -a is a shortcut for --all for this command.
 
-    $cmd pull --local
+    ${cmd}pull --local
       Integrate changes from all replicas currently announcing themselves
       on the local network using Bonjour.
 
-    $cmd pull -l
+    ${cmd}pull -l
       -l is a shortcut for --local for this command.
 
-    $cmd publish jesse\@server:path/to/destination
+    ${cmd}publish jesse\@server:path/to/destination
       Publish a copy of this replica to a remote server using rsync.
 
-    $cmd publish --html --replica --to jesse\@server:path/to/destination
+    ${cmd}publish --html --replica --to jesse\@server:path/to/destination
       Publish a copy of this replica, including a static html representation,
       to a remote server using rsync.
 
-    $cmd server --port 9876
+    ${cmd}server --port 9876
       Start an sd replica server on port 9876. This command will make your 
       replica browsable and pullable by anyone with remote access to your 
       computer.
 
-    $cmd server --writable --port 9876
+    ${cmd}server --writable --port 9876
       Start an sd replica server on port 9876, with UNAUTHENTICATED,
       PUBLIC WRITE ACCESS via HTTP POST.  This command will make your
       replica modifiable, browsable and pullable by ANYONE with remote
       access to your computer.
 
-    $cmd server -w -p 9876
+    ${cmd}server -w -p 9876
       -w is a shortcut for --writable and -p is a shortcut for --port
       for this command.
 
@@ -59,11 +59,11 @@ replica types for RT (http://bestpractical.com/rt) and Hiveminder
 your bug tracker, you should get in touch with SD's developers (see
 http://syncwith.us/contact).
 
-    $cmd push rt:http://rt3.fsck.com|rt3|Owner='jesse'
+    ${cmd}push rt:http://rt3.fsck.com|rt3|Owner='jesse'
       Push changes to the given foreign replica. Foreign replica
       schemas will vary based on the replica type.
 
-    $cmd pull rt:http://rt3.fsck.com|rt3|Owner='jesse'
+    ${cmd}pull rt:http://rt3.fsck.com|rt3|Owner='jesse'
       Pull changes from a foreign replica to be merged into the
       local replica.
 EOF
diff --git a/lib/App/SD/CLI/Command/Help/Tickets.pm b/lib/App/SD/CLI/Command/Help/Tickets.pm
index ee5c8d0..dc04f65 100644
--- a/lib/App/SD/CLI/Command/Help/Tickets.pm
+++ b/lib/App/SD/CLI/Command/Help/Tickets.pm
@@ -5,70 +5,70 @@ extends 'App::SD::CLI::Command::Help';
 sub run {
     my $self = shift;
     $self->print_header('Creating and Updating tickets');
-    my $cmd = $self->_get_cmd_name;
+    my ${cmd}= $self->_get_cmd_name;
 
 print <<EOF
-    $cmd ticket create
+    ${cmd}ticket create
       Invokes a text editor with a ticket creation template.
       Note that 'new' is an alias for 'create'.
 
-    $cmd ticket create --verbose
+    ${cmd}ticket create --verbose
       Invokes a text editor with a ticket creation template
       and also shows descriptions and valid values for
       properties.
 
-    $cmd ticket create -v
+    ${cmd}ticket create -v
       -v is a shortcut for --verbose for this command.
 
-    $cmd ticket create -- summary="This is a summary" status=open
+    ${cmd}ticket create -- summary="This is a summary" status=open
       Create a new ticket non-interactively.
 
-    $cmd ticket update 123 -- status=closed
+    ${cmd}ticket update 123 -- status=closed
       Sets the status of the ticket with local id 123 to closed.
       Note that 'edit' is an alias for 'update'.
 
-    $cmd ticket update 123
+    ${cmd}ticket update 123
       Interactively update the ticket with local id 123 in a text
       editor.
 
-    $cmd ticket update 123 --verbose
+    ${cmd}ticket update 123 --verbose
       Interactively update the ticket with local id 123 in a text
       editor and show descriptions and valid values for props.
 
-    $cmd ticket update 123 -v
+    ${cmd}ticket update 123 -v
       -v is a shortcut for --verbose for this command.
 
-    $cmd ticket update 123 --all-props
+    ${cmd}ticket update 123 --all-props
       Interactively update the ticket with local id 123 in a text
       editor, presenting all the props of the record for editing instead of
       just those specified by the database setting 'common_ticket_props'
       (or local configuration variable 'common_ticket_props' if it exists).
 
-    $cmd ticket update 123 -a
+    ${cmd}ticket update 123 -a
       -a is a shortcut for --all-props for this command.
 
-    $cmd ticket update fad5849a-67f1-11dd-bde1-5b33d3ff2799 -- status=closed
+    ${cmd}ticket update fad5849a-67f1-11dd-bde1-5b33d3ff2799 -- status=closed
       Sets the status of the ticket with uuid
       fad5849a-67f1-11dd-bde1-5b33d3ff2799 to closed.
 
-    $cmd ticket take 123
+    ${cmd}ticket take 123
       Sets the owner of ticket 123 to you (your email address is taken
       from either the 'email_address' local config variable or the
       EMAIL environmental variable). An alias of 'take' is 'claim'.
 
-    $cmd ticket give 123 nobody\@example.com
+    ${cmd}ticket give 123 nobody\@example.com
       Sets the owner of ticket 123 to nobody\@example.com.
       An alias of 'give' is 'assign'.
 
-    $cmd ticket resolve 123
+    ${cmd}ticket resolve 123
       Sets the status of the ticket with local id 123 to closed.
 
-    $cmd ticket resolve 123 --edit
+    ${cmd}ticket resolve 123 --edit
       Sets the status of the ticket with local id 123 to closed,
       allowing you to edit any properties in an editor and
       optionally add a comment in the process.
 
-    $cmd ticket resolve 123 -e
+    ${cmd}ticket resolve 123 -e
       -e is a shortcut for --edit for this command.
 EOF
 

commit 4a26b1a59502204a2da0e56643e712aade2d4148
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 30 16:44:48 2009 +0200

    major cleanup for tests that use templates: make them all
    use the same method of template specification and comparison (and
    compare line-by-line for easier debugging), and split
    out the shared code into SDTestsEditor.pm.

diff --git a/t/data/sd-ticket-create-verbose.tmpl b/t/data/sd-ticket-create-verbose.tmpl
index 3839a29..37378a6 100644
--- a/t/data/sd-ticket-create-verbose.tmpl
+++ b/t/data/sd-ticket-create-verbose.tmpl
@@ -1,7 +1,7 @@
 === required ticket metadata (changes here will not be saved) ===
 
-creator: USER
-original_replica: REPLICA
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
@@ -18,6 +18,6 @@ owner:
 # when this ticket must be finished by (ISO 8601 format)
 due: 
 # the email address of the person who reported this ticket
-reporter: EMAIL
+qr/reporter: $ENV{EMAIL}/
 
 === add new ticket comment below ===
diff --git a/t/data/sd-ticket-create.tmpl b/t/data/sd-ticket-create.tmpl
index 2ab8e53..847bd68 100644
--- a/t/data/sd-ticket-create.tmpl
+++ b/t/data/sd-ticket-create.tmpl
@@ -1,7 +1,7 @@
 === required ticket metadata (changes here will not be saved) ===
 
-creator: USER
-original_replica: REPLICA
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
@@ -11,6 +11,6 @@ milestone: alpha
 component: core
 owner: 
 due: 
-reporter: EMAIL
+qr/reporter: $ENV{EMAIL}/
 
 === add new ticket comment below ===
diff --git a/t/data/sd-ticket-update-all-props.tmpl b/t/data/sd-ticket-update-all-props.tmpl
index 7e9173d..47572e6 100644
--- a/t/data/sd-ticket-update-all-props.tmpl
+++ b/t/data/sd-ticket-update-all-props.tmpl
@@ -1,9 +1,9 @@
-qr/=== required ticket metadata \(changes here will not be saved\) ===
+=== required ticket metadata (changes here will not be saved) ===
 
-id: \d+ \($ticket_uuid\)
-created: \d{4}-\d{2}-\d{2}.+
-creator: $ENV{USER}
-original_replica: $replica_uuid
+qr/id: \d+ \($ticket_uuid\)/
+qr/created: \d{4}-\d{2}-\d{2}.+/
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
@@ -12,7 +12,7 @@ status: new
 milestone: alpha
 owner: 
 due: 2050-01-25 23:11:42
-reporter: $ENV{EMAIL}
+qr/reporter: $ENV{EMAIL}/
 component: core
 
-=== add new ticket comment below ===/
+=== add new ticket comment below ===
diff --git a/t/data/sd-ticket-update-verbose-all-props.tmpl b/t/data/sd-ticket-update-verbose-all-props.tmpl
index 1e9bd46..0c85af1 100644
--- a/t/data/sd-ticket-update-verbose-all-props.tmpl
+++ b/t/data/sd-ticket-update-verbose-all-props.tmpl
@@ -1,9 +1,9 @@
-qr/=== required ticket metadata \(changes here will not be saved\) ===
+=== required ticket metadata (changes here will not be saved) ===
 
-id: \d+ \($ticket_uuid\)
-created: \d{4}-\d{2}-\d{2}.+
-creator: $ENV{USER}
-original_replica: $replica_uuid
+qr/id: \d+ \($ticket_uuid\)/
+qr/created: \d{4}-\d{2}-\d{2}.+/
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
@@ -18,8 +18,8 @@ owner:
 # when this ticket must be finished by \(ISO 8601 format\)
 due: 2050-01-31 19:14:09
 # the email address of the person who reported this ticket
-reporter: $ENV{EMAIL}
+qr/reporter: $ENV{EMAIL}/
 # valid values for component: core, ui, docs, tests
 component: core
 
-=== add new ticket comment below ===/
+=== add new ticket comment below ===
diff --git a/t/data/sd-ticket-update-verbose.tmpl b/t/data/sd-ticket-update-verbose.tmpl
index ae8ed39..c846abb 100644
--- a/t/data/sd-ticket-update-verbose.tmpl
+++ b/t/data/sd-ticket-update-verbose.tmpl
@@ -1,9 +1,9 @@
-qr/=== required ticket metadata \(changes here will not be saved\) ===
+=== required ticket metadata (changes here will not be saved) ===
 
-id: \d+ \($ticket_uuid\)
-created: \d{4}-\d{2}-\d{2}.+
-creator: $ENV{USER}
-original_replica: $replica_uuid
+qr/id: \d+ \($ticket_uuid\)/
+qr/created: \d{4}-\d{2}-\d{2}.+/
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
@@ -14,10 +14,10 @@ status: new
 # valid values for milestone: alpha, beta, 1.0
 milestone: alpha
 # the email address of the person who is responsible for this ticket
-owner: $ENV{EMAIL}
+qr/owner: $ENV{EMAIL}/
 # when this ticket must be finished by \(ISO 8601 format\)
 due: 
 # the email address of the person who reported this ticket
-reporter: $ENV{EMAIL}
+qr/reporter: $ENV{EMAIL}/
 
-=== add new ticket comment below ===/
+=== add new ticket comment below ===
diff --git a/t/data/sd-ticket-update.tmpl b/t/data/sd-ticket-update.tmpl
index 6dc3bfd..721c4e4 100644
--- a/t/data/sd-ticket-update.tmpl
+++ b/t/data/sd-ticket-update.tmpl
@@ -1,17 +1,17 @@
-qr/=== required ticket metadata \(changes here will not be saved\) ===
+=== required ticket metadata (changes here will not be saved) ===
 
-id: \d+ \($ticket_uuid\)
-created: \d{4}-\d{2}-\d{2}.+
-creator: $ENV{USER}
-original_replica: $replica_uuid
+qr/id: \d+ \($ticket_uuid\)/
+qr/created: \d{4}-\d{2}-\d{2}.+/
+qr/creator: $ENV{USER}/
+qr/original_replica: $replica_uuid/
 
 === edit ticket details below ===
 
 summary: zomg!
 status: new
 milestone: alpha
-owner: foo\@bar.com
+owner: foo at bar.com
 due: 
-reporter: $ENV{EMAIL}
+qr/reporter: $ENV{EMAIL}/
 
-=== add new ticket comment below ===/
+=== add new ticket comment below ===
diff --git a/t/scripts/SDTestsEditor.pm b/t/scripts/SDTestsEditor.pm
new file mode 100755
index 0000000..550a92d
--- /dev/null
+++ b/t/scripts/SDTestsEditor.pm
@@ -0,0 +1,95 @@
+package SDTestsEditor;
+use strict;
+use warnings;
+
+use Prophet::Util;
+use Params::Validate;
+use File::Spec;
+
+=head2 edit( tmpl_files => $tmpl_files, edit_callback => sub {}, verify_callback => sub {} )
+
+Expects @ARGV to contain at least an option and a file to be edited. It
+can also contain a replica uuid, a ticket uuid, and a status file. The last
+item must always be the file to be edited. The others, if they appear, must
+be in that order after the option. The status file must contain the
+string 'status' in its filename.
+
+edit_callback is called on each line of the file being edited. It should make
+any edits to the lines it receives and then print what it wants to be saved to
+the file.
+
+verify_callback is called after editing is done. If you need to write
+whether the template was correct to a status file, for example, this
+should be done here.
+
+=cut
+
+sub edit {
+    my %args = @_;
+    validate( @_, { edit_callback => 1,
+                    verify_callback => 1,
+                    tmpl_files  => 1,
+                   }
+             );
+
+    my $option = shift @ARGV;
+    my $tmpl_file = $args{tmpl_files}->{$option};
+
+    chomp ( my @valid_template =
+        Prophet::Util->slurp("t/data/$tmpl_file") );
+
+    my $status_file = $ARGV[-2] =~ /status/ ? delete $ARGV[-2] : undef;
+    # a bit of a hack to dermine whether the last arg is a filename
+    my $replica_uuid = File::Spec->file_name_is_absolute($ARGV[0]) ? undef : shift @ARGV;
+    my $ticket_uuid = File::Spec->file_name_is_absolute($ARGV[0]) ? undef : shift @ARGV;
+
+    my @template = ();
+    while (<>) {
+        chomp( my $line = $_ );
+        push @template, $line;
+
+        $args{edit_callback}( option => $option, template => \@template,
+            valid_template => \@valid_template,
+            replica_uuid => $replica_uuid,
+            ticket_uuid => $ticket_uuid );
+    }
+
+    $args{verify_callback}( template => \@template,
+        valid_template => \@valid_template, status_file => $status_file );
+}
+
+=head2 check_template_by_line($template, $valid_template, $errors)
+
+$template is a reference to an array containing the template to check,
+split into lines. $valid_template is the same for the template to
+check against. Lines in these arrays should not have trailing newlines.
+$errors is a reference to an array where error messages will be stored.
+
+Lines in $valid_template should consist of either plain strings, or strings
+beginning with 'qr/' (to delimit a regexp object).
+
+Returns true if the templates match and false otherwise.
+
+=cut
+
+sub check_template_by_line {
+    my @template = @{ shift @_ };
+    my @valid_template = @{ shift @_ };
+    my $replica_uuid = shift;
+    my $ticket_uuid = shift;
+    my $errors = shift;
+
+    for my $valid_line (@valid_template) {
+        my $line = shift @template;
+
+        push @$errors, "got nothing, expected [$valid_line]" if !defined($line);
+
+        push @$errors, "[$line] doesn't match [$valid_line]"
+            if ($valid_line =~ /^qr\//) ? $line !~ eval($valid_line)
+            : $line eq $valid_line;
+    }
+
+    return !(@$errors == 0);
+}
+
+1;
diff --git a/t/scripts/settings-editor.pl b/t/scripts/settings-editor.pl
index 8d796b6..45f20d1 100755
--- a/t/scripts/settings-editor.pl
+++ b/t/scripts/settings-editor.pl
@@ -1,8 +1,8 @@
 #!/usr/bin/perl -i
 use strict;
 use warnings;
-
-use Prophet::Util;
+use lib 't/scripts';
+use SDTestsEditor;
 
 # perl script to trick Proc::InvokeEditor with for the settings command
 
@@ -10,48 +10,44 @@ my %tmpl_files = ( '--first' => 'sd-settings-first.tmpl',
                    '--second' => 'sd-settings-second.tmpl',
                  );
 
-my $option = shift @ARGV;
-my $tmpl_file = $tmpl_files{$option};
-
-# the test script passes in a temp file for us to write whether the
-# template is ok or not to
-my $status_tmp_file = shift;
-
-my @valid_template =
-    Prophet::Util->slurp("t/data/$tmpl_file");
-
-my @template = ();
-
-while (<>) {
-    push @template, $_;
-
-    if ($option eq '--first') {
-        s/(?<=^default_status: \[")new(?="\])/open/; # valid json change
-        s/^default_milestone(?=: \["alpha"\])$/invalid_setting/; # changes setting name
-        s/(?<=uuid: B)A(?=B613BD)/F/; # changes a UUID to an invalid one
-        s/^project_name//; # deletes setting
-    } elsif ($option eq '--second') {
-        s/(?<=^default_component: \[")core(?="\])/ui/; # valid json change
-        s/(?<=^default_milestone: \["alpha")]$//; # invalid json
+SDTestsEditor::edit( tmpl_files => { '--first' => 'sd-settings-first.tmpl',
+                   '--second' => 'sd-settings-second.tmpl',
+               },
+    edit_callback => sub {
+        my %args = @_;
+        my $option = $args{option};
+
+        if ($option eq '--first') {
+            s/(?<=^default_status: \[")new(?="\])/open/; # valid json change
+            s/^default_milestone(?=: \["alpha"\])$/invalid_setting/; # changes setting name
+            s/(?<=uuid: B)A(?=B613BD)/F/; # changes a UUID to an invalid one
+            s/^project_name//; # deletes setting
+        } elsif ($option eq '--second') {
+            s/(?<=^default_component: \[")core(?="\])/ui/; # valid json change
+            s/(?<=^default_milestone: \["alpha")]$//; # invalid json
+        }
+        print;
+    },
+    verify_callback => sub {
+        my %args = @_;
+
+        my $ok = 1;
+
+        my %seen;     # lookup table
+        my @vonly;    # answer
+
+        # build lookup table
+        @seen{@{$args{template}}} = ( );
+
+        for my $line (@{$args{valid_template}}) {
+            push(@vonly, $line) unless exists $seen{$line};
+        }
+
+        # if anything is only in the valid template, we don't match
+        $ok = 0 if scalar @vonly;
+
+        open STATUSFILE, '>', $args{status_file};
+        $ok ? print STATUSFILE "ok!" : print STATUSFILE "not ok!";
+        close STATUSFILE;
     }
-    print;
-}
-
-my $ok = 1;
-
-my %seen;     # lookup table
-my @vonly;    # answer
-
-# build lookup table
- at seen{@template} = ( );
-
-for my $line (@valid_template) {
-    push(@vonly, $line) unless exists $seen{$line};
-}
-
-# if anything is only in the valid template, we don't match
-$ok = 0 if scalar @vonly;
-
-open STATUSFILE, '>', $status_tmp_file;
-$ok ? print STATUSFILE "ok!" : print STATUSFILE "not ok!";
-close STATUSFILE;
+);
diff --git a/t/scripts/ticket-create-editor.pl b/t/scripts/ticket-create-editor.pl
index 70e6933..340b86b 100755
--- a/t/scripts/ticket-create-editor.pl
+++ b/t/scripts/ticket-create-editor.pl
@@ -1,46 +1,37 @@
 #!/usr/bin/perl -i
 use strict;
 use warnings;
-
-use Prophet::Util;
-use File::Spec;
+use lib 't/scripts';
+use SDTestsEditor;
 
 # perl script to trick Proc::InvokeEditor with for the ticket create command
 
-my $template = '';
 
-my %tmpl_files = ( '--no-args' => 'sd-ticket-create.tmpl',
+SDTestsEditor::edit( tmpl_files => { '--no-args' => 'sd-ticket-create.tmpl',
                    '--all-props' => 'sd-ticket-create.tmpl',
                    '--verbose' => 'sd-ticket-create-verbose.tmpl',
                    '--verbose-and-all' => 'sd-ticket-create-verbose.tmpl',
-                 );
-
-my $tmpl_file = $tmpl_files{shift @ARGV};
-
-my $valid_template =
-    Prophet::Util->slurp("t/data/$tmpl_file");
-
-my $replica_uuid = shift @ARGV;
-
-$valid_template =~ s/USER/$ENV{USER}/g;
-$valid_template =~ s/REPLICA/$replica_uuid/g;
-$valid_template =~ s/EMAIL/$ENV{EMAIL}/g;
-
-# open DEBUG, '>', '/home/spang/tmp/got.txt';
-# open DEBUG2, '>', '/home/spang/tmp/wanted.txt';
-
-while (<>) {
-     $template .= $_;
-
-     s/(?<=^summary: ).*$/we are testing sd ticket create/;
-     print;
-
-    if ( /^=== add new ticket comment below ===$/ &&
-        $template eq $valid_template ) {
-        print "template ok!\n";
-    } elsif ( /^=== add new ticket comment below ===$/ ) {
-        print "template not ok!\n";
-        # print DEBUG $template;
-        # print DEBUG2 $valid_template;
-    }
-}
+                 },
+    edit_callback => sub {
+        my %args = @_;
+
+        s/(?<=^summary: ).*$/we are testing sd ticket create/;
+        print;
+
+        if ( /^=== add new ticket comment below ===$/) {
+            my $errors = [];
+            my $template_ok =
+                SDTestsEditor::check_template_by_line($args{template},
+                $args{valid_template}, $args{replica_uuid},
+                $args{ticket_uuid}, $errors);
+            if ($template_ok) {
+                print "template ok!\n";
+            } else {
+                print "template not ok! errors were:\n";
+                map { print $_ . "\n" } @$errors;
+            }
+        }
+
+      },
+    verify_callback => sub {},
+  );
diff --git a/t/scripts/ticket-update-editor.pl b/t/scripts/ticket-update-editor.pl
index 7f02e72..136de3e 100755
--- a/t/scripts/ticket-update-editor.pl
+++ b/t/scripts/ticket-update-editor.pl
@@ -1,59 +1,53 @@
 #!/usr/bin/perl -i
 use strict;
 use warnings;
-
-use Prophet::Util;
+use lib 't/scripts';
+use SDTestsEditor;
 
 # perl script to trick Proc::InvokeEditor with for the ticket update command
 
-my $template = '';
-
-my %tmpl_files = ( '--no-args' => 'sd-ticket-update.tmpl',
+SDTestsEditor::edit( tmpl_files => { '--no-args' => 'sd-ticket-update.tmpl',
                    '--all-props' => 'sd-ticket-update-all-props.tmpl',
                    '--verbose' => 'sd-ticket-update-verbose.tmpl',
-                   '--verbose-and-all' => 'sd-ticket-update-verbose-all-props.tmpl',
-                 );
-
-my $option = shift @ARGV;
-my $tmpl_file = $tmpl_files{$option};
-
-my $valid_template =
-    Prophet::Util->slurp("t/data/$tmpl_file");
-
-my $replica_uuid = shift @ARGV;
-my $ticket_uuid = shift @ARGV;
-
-# open DEBUG, '>', '/home/spang/tmp/got.txt';
-# open DEBUG2, '>', '/home/spang/tmp/wanted.txt';
-
-while (<>) {
-    $template .= $_;
-
-    if ($option eq '--no-args') {
-        s/(?<=^summary: ).*$/summary changed/;
-        s/^owner:.*$//;               # deleting a prop
-        s/(?<=^due: ).*$/2050-01-25 23:11:42/; # adding a prop
-    } elsif ($option eq '--all-props') {
-        s/(?<=summary: ).*$/now we are checking --all-props/;
-        s/^due:.*//;              # deleting a prop
-        s/(?<=^owner: ).*$/$ENV{EMAIL}/; # adding a prop
-    } elsif ($option eq '--verbose') {
-        s/(?<=^summary: ).*$/now we are checking --verbose/;
-        s/^owner:.*//;               # deleting a prop
-        s/(?<=^due: ).*$/2050-01-31 19:14:09/; # adding a prop
-    } elsif ($option eq '--verbose-and-all') {
-        s/(?<=^summary: ).*$/now we are checking --verbose --all-props/;
-        s/^due.*//;              # deleting a prop
-        s/(?<=^owner: ).*$/$ENV{EMAIL}/; # adding a prop
-    }
-    print;
-
-    if ( /^=== add new ticket comment below ===$/ &&
-        $template =~ eval($valid_template) ) {
-        print "template ok!\n";
-    } elsif ( /^=== add new ticket comment below ===$/ ) {
-        print "template not ok!\n";
-        # print DEBUG $template;
-        # print DEBUG2 eval($valid_template);
-    }
-}
+                   '--verbose-and-all' =>
+                        'sd-ticket-update-verbose-all-props.tmpl',
+               },
+    edit_callback => sub {
+        my %args = @_;
+        my $option = $args{option};
+
+        if ($option eq '--no-args') {
+            s/(?<=^summary: ).*$/summary changed/;
+            s/^owner:.*$//;               # deleting a prop
+            s/(?<=^due: ).*$/2050-01-25 23:11:42/; # adding a prop
+        } elsif ($option eq '--all-props') {
+            s/(?<=summary: ).*$/now we are checking --all-props/;
+            s/^due:.*//;              # deleting a prop
+            s/(?<=^owner: ).*$/$ENV{EMAIL}/; # adding a prop
+        } elsif ($option eq '--verbose') {
+            s/(?<=^summary: ).*$/now we are checking --verbose/;
+            s/^owner:.*//;               # deleting a prop
+            s/(?<=^due: ).*$/2050-01-31 19:14:09/; # adding a prop
+        } elsif ($option eq '--verbose-and-all') {
+            s/(?<=^summary: ).*$/now we are checking --verbose --all-props/;
+            s/^due.*//;              # deleting a prop
+            s/(?<=^owner: ).*$/$ENV{EMAIL}/; # adding a prop
+        }
+        print;
+
+        if ( /^=== add new ticket comment below ===$/) {
+            my $errors = [];
+            my $template_ok =
+                SDTestsEditor::check_template_by_line($args{template},
+                $args{valid_template}, $args{replica_uuid},
+                $args{ticket_uuid}, $errors);
+            if ($template_ok) {
+                print "template ok!\n";
+            } else {
+                print "template not ok! errors were:\n";
+                map { print $_ . "\n" } @$errors;
+            }
+        }
+    },
+    verify_callback => sub {},
+);
diff --git a/t/sd-settings.t b/t/sd-settings.t
index 1c7cdd1..0d5f73b 100644
--- a/t/sd-settings.t
+++ b/t/sd-settings.t
@@ -5,7 +5,8 @@ use strict;
 use Prophet::Test tests => 8;
 use App::SD::Test;
 use Prophet::Util;
-use File::Temp qw(tempfile);
+use File::Temp qw(tempdir);
+use File::Spec;
 no warnings 'once';
 
 # test the CLI and interactive UIs for showing and updating settings
@@ -43,7 +44,8 @@ run_output_matches(
 
 # test sd settings (interactive editing)
 
-(undef, my $filename) = tempfile();
+my $filename = File::Temp->new(
+    TEMPLATE => File::Spec->catfile(File::Spec->tmpdir(), '/statusXXXXX') )->filename;
 diag ("interactive template status will be found in $filename");
 # first set the editor to an editor script
 App::SD::Test->set_editor("settings-editor.pl --first $filename");
@@ -70,7 +72,8 @@ run_output_matches(
 );
 
 # test setting to invalid json
-(undef, my $second_filename) = tempfile();
+my $second_filename = File::Temp->new(
+    TEMPLATE => File::Spec->catfile(File::Spec->tmpdir(), '/statusXXXXX') )->filename;
 diag ("interactive template status will be found in $second_filename");
 App::SD::Test->set_editor("settings-editor.pl --second $second_filename");
 run_output_matches( 'sd', [ 'settings' ],

commit b92a8441e6b92dbfad6cf24928622e634c47022a
Merge: 4a26b1a... f572266...
Author: Christine Spang <spang at bestpractical.com>
Date:   Fri Jan 30 16:53:06 2009 +0200

    Merge branch 'master' of code.bestpractical.com:/git/sd


-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list