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
47479b6d
Commit
47479b6d
authored
May 27, 2015
by
Jacek Sowiński
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add todos from stdin via `topydo add -f -`
Credit for idea goes to Bram Schoenmakers (@bram85).
parent
fafe392d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
6 deletions
+11
-6
topydo/commands/AddCommand.py
topydo/commands/AddCommand.py
+11
-6
No files found.
topydo/commands/AddCommand.py
View file @
47479b6d
...
...
@@ -18,6 +18,7 @@
from
datetime
import
date
import
re
from
sys
import
stdin
from
topydo.lib.Config
import
config
from
topydo.lib.Command
import
Command
...
...
@@ -34,14 +35,14 @@ class AddCommand(Command):
p_args
,
p_todolist
,
p_out
,
p_err
,
p_prompt
)
self
.
text
=
' '
.
join
(
p_args
)
self
.
todo
=
None
self
.
from_file
=
Fals
e
self
.
from_file
=
Non
e
def
_process_flags
(
self
):
opts
,
args
=
self
.
getopt
(
'f'
)
opts
,
args
=
self
.
getopt
(
'f
:
'
)
for
opt
,
value
in
opts
:
if
opt
==
'-f'
:
self
.
from_file
=
Tr
ue
self
.
from_file
=
val
ue
self
.
args
=
args
...
...
@@ -95,8 +96,12 @@ class AddCommand(Command):
self
.
todo
.
set_creation_date
(
date
.
today
())
def
get_todos_from_file
(
self
,
p_filename
):
f
=
open
(
p_filename
,
'r'
)
def
get_todos_from_file
(
self
):
if
self
.
from_file
==
'-'
:
f
=
stdin
else
:
f
=
open
(
self
.
from_file
,
'r'
)
todos
=
f
.
read
().
decode
(
'utf-8'
).
splitlines
()
return
todos
...
...
@@ -117,7 +122,7 @@ class AddCommand(Command):
self
.
_process_flags
()
if
self
.
from_file
:
new_todos
=
self
.
get_todos_from_file
(
self
.
args
[
0
]
)
new_todos
=
self
.
get_todos_from_file
()
for
todo
in
new_todos
:
self
.
_add_todo
(
todo
)
...
...
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