summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2014-04-18 16:52:29 +0100
committerLars Wirzenius <liw@liw.fi>2014-04-18 16:52:29 +0100
commit458c92b25ed1142fd4b0bcd4530a6d96158fe76f (patch)
tree0f3de6f64e47cb5f39ff5f5fe434c9aafe6a3ad7
parent34d4fdcfb434568f9133854536ef672e8a2e298f (diff)
downloaddistix-458c92b25ed1142fd4b0bcd4530a6d96158fe76f.tar.gz
Add dummy show implemenation
This is a silly implementation that doesn't really do anything yet, but it's as good as I can test it. The rest becomes usability testing.
-rw-r--r--distixlib/plugins/new_plugin.py12
-rw-r--r--distixlib/plugins/show_plugin.py60
-rw-r--r--without-tests1
-rw-r--r--yarns/050-show.yarn17
-rw-r--r--yarns/900-implements.yarn1
5 files changed, 91 insertions, 0 deletions
diff --git a/distixlib/plugins/new_plugin.py b/distixlib/plugins/new_plugin.py
index e00c877..2aaf7cd 100644
--- a/distixlib/plugins/new_plugin.py
+++ b/distixlib/plugins/new_plugin.py
@@ -30,6 +30,11 @@ class NewTicketPlugin(cliapp.Plugin):
self.app.add_subcommand(
'new', self.new_ticket, arg_synopsis='TITLE')
+ self.app.settings.string(
+ ['save-ticket-id'],
+ 'after creating the ticket, write its id to FILE',
+ metavar='FILE')
+
def disable(self):
pass
@@ -41,6 +46,9 @@ class NewTicketPlugin(cliapp.Plugin):
filenames = self._create_ticket(ticket_id, title)
self._commit_changes(filenames)
+ if self.app.settings['save-ticket-id']:
+ self._save_ticket_id(ticket_id, self.app.settings['save-ticket-id'])
+
def _invent_ticket_id(self):
return uuid.uuid4().hex
@@ -64,3 +72,7 @@ class NewTicketPlugin(cliapp.Plugin):
def _commit_changes(self, filenames):
cliapp.runcmd(['git', 'add'] + filenames, stdout=None, stderr=None)
cliapp.runcmd(['git', 'commit', '-m', 'distix new ticket'])
+
+ def _save_ticket_id(self, ticket_id, filename):
+ with open(filename, 'w') as f:
+ f.write(ticket_id)
diff --git a/distixlib/plugins/show_plugin.py b/distixlib/plugins/show_plugin.py
new file mode 100644
index 0000000..b049fa0
--- /dev/null
+++ b/distixlib/plugins/show_plugin.py
@@ -0,0 +1,60 @@
+# Copyright 2014 Lars Wirzenius
+#
+# 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, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY 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/>.
+#
+# =*= License: GPL-3+ =*=
+
+
+import os
+import uuid
+
+import cliapp
+
+import distixlib
+
+
+class ShowTicketPlugin(cliapp.Plugin):
+
+ def enable(self):
+ self.app.add_subcommand(
+ 'show', self.show_ticket, arg_synopsis='TICKETID...')
+
+ self.app.settings.string(
+ ['ticket-id-from'],
+ 'read ticket id(s) from FILE, one per line, instead of command line',
+ metavar='FILE')
+
+ def disable(self):
+ pass
+
+ def show_ticket(self, args):
+ '''Show existing tickets.'''
+
+ ticket_ids = self._get_ticket_ids(args)
+ for ticket_id in ticket_ids:
+ self._show_ticket_id(ticket_id)
+
+ def _get_ticket_ids(self, args):
+ if self.app.settings['ticket-id-from']:
+ return self._read_ticket_ids_from_file(
+ self.app.settings['ticket-id-from'])
+ else:
+ return args
+
+ def _read_ticket_ids_from_file(self, filename):
+ with open(filename) as f:
+ return [line.strip() for line in f.readlines()]
+
+ def _show_ticket_id(self, ticket_id):
+ self.app.output.write('%s\n' % ticket_id)
diff --git a/without-tests b/without-tests
index e918d15..f8e1175 100644
--- a/without-tests
+++ b/without-tests
@@ -5,3 +5,4 @@ distixlib/plugins/init_plugin.py
distixlib/plugins/list_plugin.py
distixlib/plugins/metadata_manipulation_plugin.py
distixlib/plugins/new_plugin.py
+distixlib/plugins/show_plugin.py
diff --git a/yarns/050-show.yarn b/yarns/050-show.yarn
new file mode 100644
index 0000000..c07f4b5
--- /dev/null
+++ b/yarns/050-show.yarn
@@ -0,0 +1,17 @@
+Show tickets
+============
+
+This chapter has scenarios for showing individual tickets.
+
+ SCENARIO show ticket
+
+ WHEN user attempts to run distix init REPO
+ THEN attempt succeeded
+
+ WHEN user changes working directory to REPO
+ AND user attempts to run distix new new-ticket-title --save-ticket-id=NEW
+ THEN attempt succeeded
+
+ WHEN user attempts to run distix show --ticket-id-from=NEW
+ THEN attempt succeeded
+ AND output matches "."
diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn
index c483214..e47bfe5 100644
--- a/yarns/900-implements.yarn
+++ b/yarns/900-implements.yarn
@@ -69,6 +69,7 @@ distix.
cat "$DATADIR/attempt.stderr"
grep -e "$MATCH_1" "$DATADIR/attempt.stderr"
+
File creation
-------------