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
62aef881
Commit
62aef881
authored
May 04, 2015
by
Bram Schoenmakers
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
First version of the prompt CLI.
parent
791fbe2a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
78 additions
and
0 deletions
+78
-0
topydo/cli/Prompt.py
topydo/cli/Prompt.py
+78
-0
No files found.
topydo/cli/Prompt.py
0 → 100755
View file @
62aef881
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2015 Bram Schoenmakers <me@bramschoenmakers.nl>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
""" Entry file for the Python todo.txt CLI. """
import
sys
from
topydo.cli.CLIApplicationBase
import
CLIApplicationBase
,
error
from
prompt_toolkit.contrib.shortcuts
import
get_input
from
topydo.lib.Config
import
config
,
ConfigError
# First thing is to poke the configuration and check whether it's sane
# The modules below may already read in configuration upon import, so
# make sure to bail out if the configuration is invalid.
try
:
config
()
except
ConfigError
as
config_error
:
error
(
str
(
config_error
))
sys
.
exit
(
1
)
from
topydo.lib.Commands
import
get_subcommand
from
topydo.lib.SortCommand
import
SortCommand
from
topydo.lib
import
TodoFile
from
topydo.lib
import
TodoList
class
PromptApplication
(
CLIApplicationBase
):
"""
Class that represents the Command Line Interface of Topydo.
Handles input/output of the various subcommand.
"""
def
__init__
(
self
):
super
(
PromptApplication
,
self
).
__init__
()
def
run
(
self
):
""" Main entry function. """
args
=
self
.
_process_flags
()
todofile
=
TodoFile
.
TodoFile
(
self
.
path
)
self
.
todolist
=
TodoList
.
TodoList
(
todofile
.
read
())
while
True
:
try
:
user_input
=
get_input
(
'topydo> '
).
split
()
except
(
EOFError
,
KeyboardInterrupt
):
sys
.
exit
(
0
)
(
subcommand
,
args
)
=
get_subcommand
(
user_input
)
if
self
.
_execute
(
subcommand
,
args
)
!=
False
:
if
self
.
todolist
.
is_dirty
():
self
.
_archive
()
if
config
().
keep_sorted
():
self
.
_execute
(
SortCommand
,
[])
todofile
.
write
(
str
(
self
.
todolist
))
def
main
():
""" Main entry point of the CLI. """
PromptApplication
().
run
()
if
__name__
==
'__main__'
:
main
()
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