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
91dcd57b
Commit
91dcd57b
authored
Sep 27, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass arguments to the command.
parent
cb26e769
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
9 deletions
+24
-9
AddCommand.py
AddCommand.py
+5
-3
Command.py
Command.py
+3
-2
Main.py
Main.py
+16
-4
No files found.
AddCommand.py
View file @
91dcd57b
...
...
@@ -6,9 +6,9 @@ import Command
from
RelativeDate
import
relative_date_to_date
class
AddCommand
(
Command
.
Command
):
def
__init__
(
self
,
p_
text
,
p_todolist
):
super
(
AddCommand
,
self
).
__init__
(
p_todolist
)
self
.
text
=
p_text
def
__init__
(
self
,
p_
args
,
p_todolist
):
super
(
AddCommand
,
self
).
__init__
(
p_
args
,
p_
todolist
)
self
.
text
=
' '
.
join
(
p_args
)
def
_preprocess_input_todo
(
self
):
"""
...
...
@@ -62,3 +62,5 @@ class AddCommand(Command.Command):
self
.
todo
=
self
.
todolist
.
add
(
self
.
text
)
self
.
_postprocess_input_todo
()
return
True
Command.py
View file @
91dcd57b
class
Command
(
object
):
def
__init__
(
self
,
p_todolist
):
def
__init__
(
self
,
p_args
,
p_todolist
):
self
.
args
=
p_args
self
.
todolist
=
p_todolist
def
execute
(
self
):
""" The command to execute. """
pass
return
False
Main.py
View file @
91dcd57b
...
...
@@ -39,6 +39,18 @@ def argument(p_number):
return
value
def
arguments
():
"""
Retrieves all values from the argument list starting from the given
position.
"""
try
:
values
=
sys
.
argv
[
2
:]
# strip off subcommand at position 1
except
IndexError
:
usage
()
return
values
def
convert_number
(
p_number
):
""" Converts a string number to an integer. """
try
:
...
...
@@ -60,10 +72,10 @@ class Application(object): # TODO: rename to CLIApplication
print
printed
[
0
]
def
add
(
self
):
command
=
AddCommand
(
argument
(
2
),
self
.
todolist
)
command
.
execute
()
self
.
print_todo
(
self
.
todolist
.
count
())
self
.
dirty
=
True
command
=
AddCommand
(
argument
s
(
),
self
.
todolist
)
if
command
.
execute
():
self
.
print_todo
(
self
.
todolist
.
count
())
self
.
dirty
=
True
def
append
(
self
):
""" Appends a text to a todo item. """
...
...
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