Commit 0c711a24 authored by Bram Schoenmakers's avatar Bram Schoenmakers

Merge branch 'mruwek-prompt-command' into prompt

parents e3b461e9 1af86643
......@@ -17,7 +17,7 @@ setup(
'edit-cmd-tests': ['mock'],
},
entry_points= {
'console_scripts': ['topydo = topydo.cli.CLI:main'],
'console_scripts': ['topydo = topydo.cli.UILoader:main'],
},
classifiers = [
"Development Status :: 4 - Beta",
......
......@@ -36,9 +36,7 @@ from topydo.lib import TodoList
class CLIApplication(CLIApplicationBase):
"""
Class that represents the Command Line Interface of Topydo.
Handles input/output of the various subcommands.
Class that represents the (original) Command Line Interface of Topydo.
"""
def __init__(self):
super(CLIApplication, self).__init__()
......
......@@ -14,13 +14,18 @@
# 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. """
"""
Contains a base class for a CLI implementation of topydo and functions for the
I/O on the command-line.
"""
import getopt
import sys
from six import PY2
from six.moves import input
MAIN_OPTS = "c:d:ht:v"
def usage():
""" Prints the command-line usage of topydo. """
......@@ -100,7 +105,8 @@ from topydo.lib.Utils import escape_ansi
class CLIApplicationBase(object):
"""
Base class for Command Line Interfaces (CLI) for topydo.
Base class for a Command Line Interfaces (CLI) for topydo. Examples are the
original CLI and the Prompt interface.
Handles input/output of the various subcommands.
"""
......@@ -124,7 +130,7 @@ class CLIApplicationBase(object):
args = [arg.decode('utf-8') for arg in args]
try:
opts, args = getopt.getopt(args, "c:d:ht:v")
opts, args = getopt.getopt(args, MAIN_OPTS)
except getopt.GetoptError as e:
error(str(e))
sys.exit(1)
......
......@@ -14,7 +14,7 @@
# 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. """
""" Entry file for the topydo Prompt interface (CLI). """
import sys
......@@ -41,9 +41,8 @@ from topydo.lib import TodoList
class PromptApplication(CLIApplicationBase):
"""
Class that represents the Command Line Interface of Topydo.
Handles input/output of the various subcommand.
This class implements a variant of topydo's CLI showing a shell and
offering auto-completion thanks to the prompt toolkit.
"""
def __init__(self):
super(PromptApplication, self).__init__()
......
# Topydo - A todo.txt client written in Python.
# Copyright (C) 2014 - 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
import getopt
from topydo.cli.CLIApplicationBase import MAIN_OPTS
from topydo.cli.CLI import CLIApplication
from topydo.cli.Prompt import PromptApplication
def main():
""" Main entry point of the CLI. """
try:
args = sys.argv[1:]
try:
opts, args = getopt.getopt(args, MAIN_OPTS)
except getopt.GetoptError as e:
error(str(e))
sys.exit(1)
if args[0] == 'prompt':
PromptApplication().run()
else:
CLIApplication().run()
except IndexError:
CLIApplication().run()
if __name__ == '__main__':
main()
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment