From 65746d541a49996703016cb0e28b939543a198fb Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 7 Jan 2017 16:27:49 +0200 Subject: Change distix set to have a list of ticket ids at end --- NEWS | 3 +++ TUTORIAL | 2 +- distixlib/plugins/set_plugin.py | 14 +++++++++----- yarns/060-set.yarn | 2 +- yarns/070-search.yarn | 2 +- yarns/900-implements.yarn | 2 +- 6 files changed, 16 insertions(+), 9 deletions(-) diff --git a/NEWS b/NEWS index 02ab1e0..de72a1b 100644 --- a/NEWS +++ b/NEWS @@ -7,6 +7,9 @@ distix, a distributed ticketing system. Version 0.8+git, not yet released --------------------------------- +* Changed the syntax of the `distix set` command to be `distix set + FOO=BAR TICKETID...` (with as many ticket ids as desired). This is + more convenient than having the ticket id first. Version 0.8, released 2017-01-01 --------------------------------- diff --git a/TUTORIAL b/TUTORIAL index 9c53d5f..6a95afc 100644 --- a/TUTORIAL +++ b/TUTORIAL @@ -93,7 +93,7 @@ Setting ticket metadata: `distix set` Each ticket has some key/value pairs. These allow distix to manage ticket metadata. You can add any pairs you like. - $ distix set 0234e10813ca44438510c37a7b61abb2 status=triaged + $ distix set status=triaged 0234e10813ca44438510c37a7b61abb2 $ distix show 0234e10813ca44438510c37a7b61abb2 0234e10813ca44438510c37a7b61abb2: distix home page is useless diff --git a/distixlib/plugins/set_plugin.py b/distixlib/plugins/set_plugin.py index 7a82e26..c840087 100644 --- a/distixlib/plugins/set_plugin.py +++ b/distixlib/plugins/set_plugin.py @@ -29,19 +29,23 @@ class SetPlugin(cliapp.Plugin): def enable(self): self.app.add_subcommand( - 'set', self.set, arg_synopsis='TICKETID KEY=VALUE...') + 'set', self.set, arg_synopsis='KEY=VALUE TICKETID ...') def set(self, args): '''Set ticket metadata.''' + key, value = self._parse_pair(args[0]) + ticket_ids = distixlib.get_ticket_ids(self.app.settings, args[1:]) + repo = distixlib.Repository('.') repo.require_clean_working_tree() - ticket_id = distixlib.get_ticket_ids(self.app.settings, [args[0]])[0] + ticket_store = repo.open_ticket_store(distixlib.tickets_dir_name) - ticket = ticket_store.get_ticket(ticket_id) - for pair in args[1:]: - key, value = self._parse_pair(pair) + + for ticket_id in ticket_ids: + ticket = ticket_store.get_ticket(ticket_id) ticket.add_metadata_key_value_pair(key, value) + filenames = ticket_store.save_changes() repo.commit_changes(filenames, self._commit_msg) diff --git a/yarns/060-set.yarn b/yarns/060-set.yarn index 4aed805..83af08f 100644 --- a/yarns/060-set.yarn +++ b/yarns/060-set.yarn @@ -12,7 +12,7 @@ This chapter contains scenarios for setting metadata for a ticket. AND user attempts to run distix new new-ticket-title --save-ticket-id=../NEW THEN attempt succeeded - WHEN user attempts to run distix set DUMMYID FOO=BAR --ticket-id-from=../NEW + WHEN user attempts to run distix set FOO=BAR DUMMYID --ticket-id-from=../NEW THEN attempt succeeded AND everything in REPO is committed to git diff --git a/yarns/070-search.yarn b/yarns/070-search.yarn index ccbe471..c55b3da 100644 --- a/yarns/070-search.yarn +++ b/yarns/070-search.yarn @@ -38,7 +38,7 @@ Set the second ticket's state to closed, and make sure `distix list` still shows both tickets. WHEN user attempts to run - ... distix set --ticket-id-from=../T2 DUMMY state=closed + ... distix set --ticket-id-from=../T2 state=closed DUMMY THEN attempt succeeded WHEN user attempts to run distix list diff --git a/yarns/900-implements.yarn b/yarns/900-implements.yarn index da62298..3aed634 100644 --- a/yarns/900-implements.yarn +++ b/yarns/900-implements.yarn @@ -74,7 +74,7 @@ b do "$SRCDIR/distix" --no-default-config --quiet \ --log "$DATADIR/distix.log" \ - set "$ticket" "$MATCH_2" + set "$MATCH_2" "$ticket" done We also need steps for inspecting the results of attempting to run -- cgit v1.2.1