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
a1846f14
Commit
a1846f14
authored
Nov 20, 2014
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add option to automatically sort the file after an operation.
parent
50eea969
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
6 deletions
+17
-6
bin/topydo.conf
bin/topydo.conf
+1
-0
topydo/cli/Main.py
topydo/cli/Main.py
+9
-6
topydo/lib/Config.py
topydo/lib/Config.py
+7
-0
No files found.
bin/topydo.conf
View file @
a1846f14
...
...
@@ -17,6 +17,7 @@ tag_due = due
tag_star
=
star
[
sort
]
keep_sorted
=
0
sort_string
=
desc
:
importance
,
due
,
desc
:
priority
;
For
calculating
importance
...
...
topydo/cli/Main.py
View file @
a1846f14
...
...
@@ -106,6 +106,10 @@ class CLIApplication(object):
if
archive
.
is_dirty
():
archive_file
.
write
(
str
(
archive
))
def
execute
(
self
,
p_command
,
p_args
):
command
=
p_command
(
p_args
,
self
.
todolist
,
lambda
o
:
write
(
sys
.
stdout
,
o
),
error
,
raw_input
)
return
False
if
command
.
execute
()
==
False
else
True
def
run
(
self
):
""" Main entry function. """
todofile
=
TodoFile
.
TodoFile
(
config
().
todotxt
())
...
...
@@ -145,16 +149,15 @@ class CLIApplication(object):
subcommand
=
config
().
default_command
()
args
=
arguments
(
1
)
command
=
subcommand_map
[
subcommand
](
args
,
self
.
todolist
,
lambda
o
:
write
(
sys
.
stdout
,
o
),
error
,
raw_input
)
if
command
.
execute
()
==
False
:
if
self
.
execute
(
subcommand_map
[
subcommand
],
args
)
==
False
:
exit
(
1
)
if
self
.
todolist
.
is_dirty
():
self
.
archive
()
if
config
().
keep_sorted
():
self
.
execute
(
SortCommand
,
[])
todofile
.
write
(
str
(
self
.
todolist
))
if
__name__
==
'__main__'
:
...
...
topydo/lib/Config.py
View file @
a1846f14
...
...
@@ -47,6 +47,7 @@ class _Config:
'tag_star'
:
'star'
,
# sort
'keep_sorted'
:
'0'
,
'sort_string'
:
'desc:importance,due,desc:priority'
,
'ignore_weekends'
:
'1'
,
}
...
...
@@ -104,6 +105,12 @@ class _Config:
except
ValueError
:
return
int
(
self
.
defaults
[
'indent'
])
def
keep_sorted
(
self
):
try
:
return
self
.
cp
.
getboolean
(
'sort'
,
'keep_sorted'
)
except
ValueError
:
return
self
.
defaults
[
'keep_sorted'
]
==
'1'
def
sort_string
(
self
):
return
self
.
cp
.
get
(
'sort'
,
'sort_string'
)
...
...
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