--- a/t.py Sat Apr 11 11:34:13 2020 -0400
+++ b/t.py Sat Apr 11 11:39:16 2020 -0400
@@ -172,13 +172,17 @@
else:
raise AmbiguousPrefix(prefix)
- def add_task(self, text):
+ def add_task(self, text, verbose, quiet):
"""Add a new, unfinished task with the given summary text."""
task_id = _hash(text)
self.tasks[task_id] = {'id': task_id, 'text': text}
- prefixes = _prefixes(self.tasks)
- print(prefixes[task_id])
+ if not quiet:
+ if verbose:
+ print(task_id)
+ else:
+ prefixes = _prefixes(self.tasks)
+ print(prefixes[task_id])
def edit_task(self, prefix, text):
"""Edit the task with the given prefix.
@@ -321,7 +325,7 @@
td.edit_task(options.edit, text)
td.write(options.delete)
elif text:
- td.add_task(text)
+ td.add_task(text, verbose=options.verbose, quiet=options.quiet)
td.write(options.delete)
else:
kind = 'tasks' if not options.done else 'done'
--- a/tests/basic.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/basic.t Sat Apr 11 11:39:16 2020 -0400
@@ -6,13 +6,16 @@
$ xt
$ xt Sample one.
+ 3
$ xt
3 - Sample one.
$ xt Sample two.
+ 7
$ xt
3 - Sample one.
7 - Sample two.
$ xt 'this | that'
+ 4
$ xt
3 - Sample one.
4 - this | that
@@ -30,3 +33,10 @@
$ xt -f 4
$ xt
+Output when adding in various modes:
+
+ $ xt foo
+ 0
+ $ xt -v bar
+ 62cdb7020ff920e5aa642c3d4066950dd1f01f4d
+ $ xt -q baz
--- a/tests/collisions.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/collisions.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,19 +5,33 @@
Make some tasks that collide in their first letter:
$ xt 1
+ 3
$ xt 2
+ d
$ xt 3
+ 7
$ xt 4
+ 1
$ xt 5
+ a
$ xt 6
+ c
$ xt 7
+ 9
$ xt 8
+ f
$ xt 9
+ 0
$ xt 10
+ b
$ xt 11
+ 17
$ xt 12
+ 7b
$ xt 13
+ bd
$ xt 14
+ fa
$ xt
0 - 9
17 - 11
@@ -37,19 +51,33 @@
Even more ambiguity:
$ xt 1test
+ e
$ xt 2test
+ 5
$ xt 3test
+ 95
$ xt 4test
+ 36
$ xt 5test
+ 2
$ xt 6test
+ 14
$ xt 7test
+ a1
$ xt 8test
+ 07
$ xt 9test
+ 0e
$ xt 10test
+ b10
$ xt 11test
+ 6
$ xt 12test
+ 8
$ xt 13test
+ c7
$ xt 14test
+ ef
$ xt
07 - 8test
0a - 9
--- a/tests/editing.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/editing.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,12 +5,14 @@
Replace a task's text (preserving the ID):
$ xt Sample.
+ a
$ xt
a - Sample.
$ xt -e a New sample.
$ xt
d - New sample.
$ xt 'this | that'
+ 4
$ xt
4 - this | that
d - New sample.
--- a/tests/errors.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/errors.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,7 +5,9 @@
Add some test tasks:
$ xt Sample one.
+ 3
$ xt Sample two.
+ 7
Bad prefix:
@@ -22,19 +24,33 @@
Ambiguous identifiers:
$ xt 1
+ 35
$ xt 2
+ d
$ xt 3
+ 77
$ xt 4
+ 1
$ xt 5
+ a
$ xt 6
+ c
$ xt 7
+ 9
$ xt 8
+ f
$ xt 9
+ 0
$ xt 10
+ b
$ xt 11
+ 17
$ xt 12
+ 7b
$ xt 13
+ bd
$ xt 14
+ fa
$ xt -f 1
error: the ID "1" matches more than one task
[1]
@@ -62,19 +78,33 @@
Even more ambiguity:
$ xt 1test
+ e
$ xt 2test
+ 5
$ xt 3test
+ 95
$ xt 4test
+ 36
$ xt 5test
+ 2
$ xt 6test
+ 14
$ xt 7test
+ a1
$ xt 8test
+ 07
$ xt 9test
+ 0e
$ xt 10test
+ b10
$ xt 11test
+ 6
$ xt 12test
+ 8
$ xt 13test
+ c7
$ xt 14test
+ ef
$ xt
07 - 8test
0a - 9
--- a/tests/filehandling.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/filehandling.t Sat Apr 11 11:39:16 2020 -0400
@@ -12,6 +12,7 @@
.
..
$ xt Sample.
+ a
$ ls -a
.
..
@@ -30,6 +31,7 @@
Finish a task with deleting:
$ xt Another.
+ c
$ xt --delete-if-empty -f c
$ ls -a
.
--- a/tests/finished.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/finished.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,10 +5,15 @@
Add some tasks:
$ xt Sample one.
+ 3
$ xt Sample two.
+ 7
$ xt Sample three.
+ 9
$ xt Sample four.
+ 1
$ xt 'this | that'
+ 4
Finish and test .test.done:
--- a/tests/padding.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/padding.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,7 +5,9 @@
Add tasks of varying width:
$ xt Short.
+ 5
$ xt Longcat is long.
+ 4
Test paddings:
--- a/tests/taskdirs.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/taskdirs.t Sat Apr 11 11:39:16 2020 -0400
@@ -7,7 +7,9 @@
$ mkdir beer
$ mkdir books
$ xt --task-dir beer Dogfish Head 120 minute IPA
+ 7
$ xt --task-dir books Your Inner Fish
+ 0
$ xt --task-dir beer
7 - Dogfish Head 120 minute IPA
$ xt --task-dir books
--- a/tests/tasklists.t Sat Apr 11 11:34:13 2020 -0400
+++ b/tests/tasklists.t Sat Apr 11 11:39:16 2020 -0400
@@ -5,7 +5,9 @@
Initialize multiple task lists:
$ xt --list beer Dogfish Head 120 minute IPA
+ 7
$ xt --list books Your Inner Fish
+ 0
$ xt --list beer
7 - Dogfish Head 120 minute IPA
$ xt --list books