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
ac61e8e6
Commit
ac61e8e6
authored
Nov 08, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add --force flag to delete and do commands.
parent
f8fe1f97
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
3 deletions
+23
-3
test/DeleteCommandTest.py
test/DeleteCommandTest.py
+11
-2
topydo/lib/DCommand.py
topydo/lib/DCommand.py
+12
-1
No files found.
test/DeleteCommandTest.py
View file @
ac61e8e6
...
...
@@ -64,6 +64,15 @@ class DeleteCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_del4
(
self
):
command
=
DeleteCommand
.
DeleteCommand
([
"--force"
,
"1"
],
self
.
todolist
,
self
.
out
,
self
.
error
,
lambda
p
:
"y"
)
command
.
execute
()
self
.
assertTrue
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
todolist
.
count
(),
1
)
# force won't delete subtasks
self
.
assertEquals
(
self
.
output
,
" 2 Bar p:1
\
n
Removed: Foo id:1
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_del5
(
self
):
command
=
DeleteCommand
.
DeleteCommand
([
"2"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
@@ -72,7 +81,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"Removed: Bar p:1
\
n
The following todo item(s) became active:
\
n
Foo
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_del
5
(
self
):
def
test_del
7
(
self
):
command
=
DeleteCommand
.
DeleteCommand
([
"99"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
@@ -80,7 +89,7 @@ class DeleteCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
"Invalid todo number given.
\
n
"
)
def
test_del
6
(
self
):
def
test_del
8
(
self
):
command
=
DeleteCommand
.
DeleteCommand
([
"A"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
...
...
topydo/lib/DCommand.py
View file @
ac61e8e6
...
...
@@ -30,14 +30,25 @@ class DCommand(Command):
p_prompt
=
lambda
a
:
None
):
super
(
DCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
force
=
False
self
.
process_flags
()
self
.
length
=
len
(
self
.
todolist
.
todos
())
# to determine newly activated todos
self
.
force
=
self
.
argument_shift
(
"--force"
)
or
self
.
argument_shift
(
"-f"
)
try
:
self
.
todo
=
self
.
todolist
.
todo
(
self
.
argument
(
0
))
except
(
InvalidCommandArgument
,
InvalidTodoException
):
self
.
todo
=
None
def
process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
"f"
,
[
"force"
])
for
opt
,
value
in
opts
:
if
opt
==
"-f"
or
opt
==
"--force"
:
self
.
force
=
True
self
.
args
=
args
def
_uncompleted_children
(
self
,
p_todo
):
return
sorted
([
t
for
t
in
self
.
todolist
.
children
(
p_todo
)
if
not
t
.
is_completed
()])
...
...
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