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
a2e13324
Commit
a2e13324
authored
Oct 19, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add help texts and introduce the global 'help' subsubcommand.
parent
f0c4d9a9
Changes
17
Show whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
168 additions
and
5 deletions
+168
-5
AddCommand.py
AddCommand.py
+20
-0
AppendCommand.py
AppendCommand.py
+8
-0
Command.py
Command.py
+11
-5
DepCommand.py
DepCommand.py
+15
-0
DoCommand.py
DoCommand.py
+13
-0
ListCommand.py
ListCommand.py
+19
-0
ListContextCommand.py
ListContextCommand.py
+9
-0
ListProjectCommand.py
ListProjectCommand.py
+9
-0
PriorityCommand.py
PriorityCommand.py
+9
-0
test/AddCommandTest.py
test/AddCommandTest.py
+7
-0
test/AppendCommandTest.py
test/AppendCommandTest.py
+7
-0
test/DepCommandTest.py
test/DepCommandTest.py
+6
-0
test/DoCommandTest.py
test/DoCommandTest.py
+7
-0
test/ListCommandTest.py
test/ListCommandTest.py
+7
-0
test/ListContextCommandTest.py
test/ListContextCommandTest.py
+7
-0
test/ListProjectCommandTest.py
test/ListProjectCommandTest.py
+7
-0
test/PriorityCommandTest.py
test/PriorityCommandTest.py
+7
-0
No files found.
AddCommand.py
View file @
a2e13324
...
@@ -86,6 +86,9 @@ class AddCommand(Command.Command):
...
@@ -86,6 +86,9 @@ class AddCommand(Command.Command):
def
execute
(
self
):
def
execute
(
self
):
""" Adds a todo item to the list. """
""" Adds a todo item to the list. """
if
not
super
(
AddCommand
,
self
).
execute
():
return
False
if
self
.
text
:
if
self
.
text
:
self
.
_preprocess_input_todo
()
self
.
_preprocess_input_todo
()
self
.
todo
=
self
.
todolist
.
add
(
self
.
text
)
self
.
todo
=
self
.
todolist
.
add
(
self
.
text
)
...
@@ -94,3 +97,20 @@ class AddCommand(Command.Command):
...
@@ -94,3 +97,20 @@ class AddCommand(Command.Command):
self
.
out
(
pretty_print
(
self
.
todo
,
[
self
.
todolist
.
pp_number
()]))
self
.
out
(
pretty_print
(
self
.
todo
,
[
self
.
todolist
.
pp_number
()]))
else
:
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
def
usage
(
self
):
return
"""Synopsis: add <text>"""
def
help
(
self
):
return
"""This subcommand automatically adds the creation date to the added item.
<text> may contain:
* Priorities mid-sentence. Example: add "Water flowers (C)"
* Dependencies using before, after and partof tags. They are translated to the
corresponding 'id' and 'p' tags. The values of these tags correspond to the
todo number (not the dependency number).
Example: add "Subtask partof:1"
"""
AppendCommand.py
View file @
a2e13324
...
@@ -27,6 +27,9 @@ class AppendCommand(Command):
...
@@ -27,6 +27,9 @@ class AppendCommand(Command):
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
super
(
AppendCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
=
lambda
a
:
None
)
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
AppendCommand
,
self
).
execute
():
return
False
try
:
try
:
number
=
convert_todo_number
(
self
.
argument
(
0
))
number
=
convert_todo_number
(
self
.
argument
(
0
))
text
=
" "
.
join
(
self
.
args
[
1
:])
text
=
" "
.
join
(
self
.
args
[
1
:])
...
@@ -42,3 +45,8 @@ class AppendCommand(Command):
...
@@ -42,3 +45,8 @@ class AppendCommand(Command):
except
TodoList
.
InvalidTodoException
:
except
TodoList
.
InvalidTodoException
:
self
.
error
(
"Invalid todo number given."
)
self
.
error
(
"Invalid todo number given."
)
def
usage
(
self
):
return
"""Synopsis: append <number> <text>"""
def
help
(
self
):
return
"""Adds the given <text> to the end of the todo indicated by <number>."""
Command.py
View file @
a2e13324
...
@@ -50,12 +50,15 @@ class Command(object):
...
@@ -50,12 +50,15 @@ class Command(object):
def
execute
(
self
):
def
execute
(
self
):
"""
"""
Execute the command.
Execute the command. Intercepts the help subsubcommand to show the help
text.
Returns True when the command succeeded or False on failure.
"""
"""
if
self
.
argumentShift
(
"help"
):
self
.
error
(
self
.
usage
()
+
"
\
n
\
n
"
+
self
.
help
())
return
False
return
False
return
True
def
argument
(
self
,
p_number
):
def
argument
(
self
,
p_number
):
""" Retrieves a value from the argument list at the given position. """
""" Retrieves a value from the argument list at the given position. """
value
=
None
value
=
None
...
@@ -77,5 +80,8 @@ class Command(object):
...
@@ -77,5 +80,8 @@ class Command(object):
return
False
return
False
def
usage
(
self
):
def
usage
(
self
):
return
"No usage text defined for this command."
return
"No usage text available for this command."
def
help
(
self
):
return
"No help text available for this command."
DepCommand.py
View file @
a2e13324
...
@@ -99,6 +99,9 @@ class DepCommand(Command):
...
@@ -99,6 +99,9 @@ class DepCommand(Command):
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
DepCommand
,
self
).
execute
():
return
False
dispatch
=
{
dispatch
=
{
'add'
:
self
.
_handle_add
,
'add'
:
self
.
_handle_add
,
'rm'
:
self
.
_handle_rm
,
'rm'
:
self
.
_handle_rm
,
...
@@ -113,3 +116,15 @@ class DepCommand(Command):
...
@@ -113,3 +116,15 @@ class DepCommand(Command):
else
:
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
def
usage
(
self
):
return
"""Synopsis:
dep <add|rm> <NUMBER> [to] <NUMBER>
dep ls <NUMBER> to
dep ls to <NUMBER>
dep clean"""
def
help
(
self
):
return
"""* add: Adds a dependency.
* rm (alias: del): Removes a dependency.
* ls: Lists all dependencies to or from a certain todo.
* clean (alias: gc): Removes redundant id or p tags."""
DoCommand.py
View file @
a2e13324
...
@@ -56,6 +56,9 @@ class DoCommand(Command):
...
@@ -56,6 +56,9 @@ class DoCommand(Command):
self
.
out
(
pretty_print
(
new_todo
,
[
self
.
todolist
.
pp_number
()]))
self
.
out
(
pretty_print
(
new_todo
,
[
self
.
todolist
.
pp_number
()]))
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
DoCommand
,
self
).
execute
():
return
False
if
not
self
.
number
:
if
not
self
.
number
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
elif
self
.
todo
and
not
self
.
todo
.
is_completed
():
elif
self
.
todo
and
not
self
.
todo
.
is_completed
():
...
@@ -67,3 +70,13 @@ class DoCommand(Command):
...
@@ -67,3 +70,13 @@ class DoCommand(Command):
self
.
error
(
"Invalid todo number given."
)
self
.
error
(
"Invalid todo number given."
)
else
:
else
:
self
.
error
(
"Todo has already been completed."
)
self
.
error
(
"Todo has already been completed."
)
def
usage
(
self
):
return
"""Synopsis: do <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.
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."""
ListCommand.py
View file @
a2e13324
...
@@ -27,6 +27,9 @@ class ListCommand(Command.Command):
...
@@ -27,6 +27,9 @@ class ListCommand(Command.Command):
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
ListCommand
,
self
).
execute
():
return
False
show_all
=
self
.
argumentShift
(
"-x"
)
show_all
=
self
.
argumentShift
(
"-x"
)
sorter
=
Sorter
.
Sorter
(
Config
.
SORT_STRING
)
sorter
=
Sorter
.
Sorter
(
Config
.
SORT_STRING
)
...
@@ -36,3 +39,19 @@ class ListCommand(Command.Command):
...
@@ -36,3 +39,19 @@ class ListCommand(Command.Command):
filters
.
append
(
Filter
.
GrepFilter
(
self
.
argument
(
0
)))
filters
.
append
(
Filter
.
GrepFilter
(
self
.
argument
(
0
)))
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
self
.
out
(
self
.
todolist
.
view
(
sorter
,
filters
).
pretty_print
())
def
usage
(
self
):
return
"""Synopsis: ls [-x] [expression]
Use "ls help" for more info."""
def
help
(
self
):
return
"""Lists all relevant todos. A todo is relevant when:
* has not been completed yet;
* the start date (if present) has passed;
* there are no subitems that need to be completed.
When an expression is given, only the todos matching that expression are shown.
-x : Show all todos (i.e. do not filter on dependencies or relevance)."""
ListContextCommand.py
View file @
a2e13324
...
@@ -24,5 +24,14 @@ class ListContextCommand(Command.Command):
...
@@ -24,5 +24,14 @@ class ListContextCommand(Command.Command):
super
(
ListContextCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListContextCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
ListContextCommand
,
self
).
execute
():
return
False
for
context
in
sorted
(
self
.
todolist
.
contexts
(),
key
=
str
.
lower
):
for
context
in
sorted
(
self
.
todolist
.
contexts
(),
key
=
str
.
lower
):
self
.
out
(
context
)
self
.
out
(
context
)
def
usage
(
self
):
return
"""Synopsis: lscon"""
def
help
(
self
):
return
"""Lists all contexts in the todo list."""
ListProjectCommand.py
View file @
a2e13324
...
@@ -24,5 +24,14 @@ class ListProjectCommand(Command.Command):
...
@@ -24,5 +24,14 @@ class ListProjectCommand(Command.Command):
super
(
ListProjectCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
ListProjectCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
ListProjectCommand
,
self
).
execute
():
return
False
for
project
in
sorted
(
self
.
todolist
.
projects
(),
key
=
str
.
lower
):
for
project
in
sorted
(
self
.
todolist
.
projects
(),
key
=
str
.
lower
):
self
.
out
(
project
)
self
.
out
(
project
)
def
usage
(
self
):
return
"""Synopsis: lscon"""
def
help
(
self
):
return
"""Lists all projects in the todo list."""
PriorityCommand.py
View file @
a2e13324
...
@@ -27,6 +27,9 @@ class PriorityCommand(Command):
...
@@ -27,6 +27,9 @@ class PriorityCommand(Command):
super
(
PriorityCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
super
(
PriorityCommand
,
self
).
__init__
(
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
def
execute
(
self
):
def
execute
(
self
):
if
not
super
(
PriorityCommand
,
self
).
execute
():
return
False
number
=
None
number
=
None
priority
=
None
priority
=
None
try
:
try
:
...
@@ -53,3 +56,9 @@ class PriorityCommand(Command):
...
@@ -53,3 +56,9 @@ class PriorityCommand(Command):
self
.
error
(
"Invalid todo number given."
)
self
.
error
(
"Invalid todo number given."
)
else
:
else
:
self
.
error
(
self
.
usage
())
self
.
error
(
self
.
usage
())
def
usage
(
self
):
return
"""Synopsis: pri <NUMBER> <PRIORITY>"""
def
help
(
self
):
return
"""Sets the priority of todo the given number to the given priority."""
test/AddCommandTest.py
View file @
a2e13324
...
@@ -177,3 +177,10 @@ class AddCommandTest(CommandTest.CommandTest):
...
@@ -177,3 +177,10 @@ class AddCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_help
(
self
):
command
=
AddCommand
.
AddCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/AppendCommandTest.py
View file @
a2e13324
...
@@ -71,3 +71,10 @@ class AppendCommandTest(CommandTest.CommandTest):
...
@@ -71,3 +71,10 @@ class AppendCommandTest(CommandTest.CommandTest):
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
output
,
""
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_help
(
self
):
command
=
AppendCommand
.
AppendCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/DepCommandTest.py
View file @
a2e13324
...
@@ -202,3 +202,9 @@ class DepCommandTest(CommandTest.CommandTest):
...
@@ -202,3 +202,9 @@ class DepCommandTest(CommandTest.CommandTest):
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEqual
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
def
test_help
(
self
):
command
=
DepCommand
.
DepCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/DoCommandTest.py
View file @
a2e13324
...
@@ -128,3 +128,10 @@ class DoCommandTest(CommandTest.CommandTest):
...
@@ -128,3 +128,10 @@ class DoCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_help
(
self
):
command
=
DoCommand
.
DoCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/ListCommandTest.py
View file @
a2e13324
...
@@ -61,3 +61,10 @@ class ListCommandTest(CommandTest.CommandTest):
...
@@ -61,3 +61,10 @@ class ListCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
self
.
assertEquals
(
self
.
errors
,
""
)
def
test_help
(
self
):
command
=
ListCommand
.
ListCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/ListContextCommandTest.py
View file @
a2e13324
...
@@ -34,3 +34,10 @@ class ListContextCommandTest(CommandTest.CommandTest):
...
@@ -34,3 +34,10 @@ class ListContextCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"Context1
\
n
Context2
\
n
"
)
self
.
assertEquals
(
self
.
output
,
"Context1
\
n
Context2
\
n
"
)
self
.
assertFalse
(
self
.
errors
)
self
.
assertFalse
(
self
.
errors
)
def
test_help
(
self
):
command
=
ListContextCommand
.
ListContextCommand
([
"help"
],
None
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/ListProjectCommandTest.py
View file @
a2e13324
...
@@ -34,3 +34,10 @@ class ListProjectCommandTest(CommandTest.CommandTest):
...
@@ -34,3 +34,10 @@ class ListProjectCommandTest(CommandTest.CommandTest):
self
.
assertEquals
(
self
.
output
,
"Project1
\
n
Project2
\
n
"
)
self
.
assertEquals
(
self
.
output
,
"Project1
\
n
Project2
\
n
"
)
self
.
assertFalse
(
self
.
errors
)
self
.
assertFalse
(
self
.
errors
)
def
test_help
(
self
):
command
=
ListProjectCommand
.
ListProjectCommand
([
"help"
],
None
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
test/PriorityCommandTest.py
View file @
a2e13324
...
@@ -82,3 +82,10 @@ class PriorityCommandTest(CommandTest.CommandTest):
...
@@ -82,3 +82,10 @@ class PriorityCommandTest(CommandTest.CommandTest):
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
todolist
.
is_dirty
())
self
.
assertFalse
(
self
.
output
)
self
.
assertFalse
(
self
.
output
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
"
)
def
test_help
(
self
):
command
=
PriorityCommand
.
PriorityCommand
([
"help"
],
self
.
todolist
,
self
.
out
,
self
.
error
)
command
.
execute
()
self
.
assertEquals
(
self
.
output
,
""
)
self
.
assertEquals
(
self
.
errors
,
command
.
usage
()
+
"
\
n
\
n
"
+
command
.
help
()
+
"
\
n
"
)
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