Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
T
topydo
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
topydo
Commits
f05da0e2
Commit
f05da0e2
authored
Oct 19, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --force flag to 'do' subcommand.
parent
a4f7ee71
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
DoCommand.py
DoCommand.py
+10
-5
test/DoCommandTest.py
test/DoCommandTest.py
+26
-0
No files found.
DoCommand.py
View file @
f05da0e2
...
...
@@ -30,6 +30,7 @@ class DoCommand(Command):
super
(
DoCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
number
=
None
self
.
force
=
self
.
argumentShift
(
"--force"
)
or
self
.
argumentShift
(
"-f"
)
try
:
self
.
number
=
convert_todo_number
(
self
.
argument
(
0
))
...
...
@@ -42,9 +43,10 @@ class DoCommand(Command):
if
children
:
self
.
out
(
"
\
n
"
.
join
(
pretty_print_list
(
children
,
[
self
.
todolist
.
pp_number
()])))
confirmation
=
self
.
prompt
(
"Also mark subtasks as done? [n] "
)
if
not
self
.
force
:
confirmation
=
self
.
prompt
(
"Also mark subtasks as done? [n] "
)
if
re
.
match
(
'^y(es)?$'
,
confirmation
,
re
.
I
):
if
not
self
.
force
and
re
.
match
(
'^y(es)?$'
,
confirmation
,
re
.
I
):
for
child
in
children
:
self
.
todolist
.
set_todo_completed
(
child
)
self
.
out
(
pretty_print
(
child
))
...
...
@@ -72,11 +74,14 @@ class DoCommand(Command):
self
.
error
(
"Todo has already been completed."
)
def
usage
(
self
):
return
"""Synopsis: do <NUMBER>"""
return
"""Synopsis: do
[--force]
<NUMBER>"""
def
help
(
self
):
return
""" Marks the todo with given number as complete. In case the todo has subitems,
they may optionally be completed too.
return
"""Marks the todo with given number as complete.
In case the todo has subitems, a question is asked whether the subitems should
be marked as completed as well. When --force is given, no interaction is
required and the subitems are not marked completed.
In case the completed todo is recurring, a new todo will be added to the list,
while the given todo item is marked as complete."""
test/DoCommandTest.py
View file @
f05da0e2
...
...
@@ -75,6 +75,32 @@ class DoCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
result
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_do_children_force1
(
self
):
prompt_shown
=
False
def
prompt
(
p_prompt
):
prompt_shown
=
True
command
=
DoCommand
.
DoCommand
([
"-f"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
prompt
)
command
.
execute
()
self
.
assertFalse
(
prompt_shown
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertFalse
(
self
.
todolist
.
todo
(
2
).
is_completed
())
def
test_do_children_force2
(
self
):
prompt_shown
=
False
def
prompt
(
p_prompt
):
prompt_shown
=
True
command
=
DoCommand
.
DoCommand
([
"--force"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
prompt
)
command
.
execute
()
self
.
assertFalse
(
prompt_shown
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertFalse
(
self
.
todolist
.
todo
(
2
).
is_completed
())
def
test_recurrence
(
self
):
today
=
date
.
today
()
tomorrow
=
today
+
timedelta
(
1
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment