Update of /cvsroot/todo-manager/todo-manager
In directory usw-pr-cvs1:/tmp/cvs-serv15000
Modified Files:
Tag: dev-bronze
main.py
Log Message:
Command-line arguments. That's it.
Index: main.py
===================================================================
RCS file: /cvsroot/todo-manager/todo-manager/main.py,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -u -d -r1.1.2.18 -r1.1.2.19
--- main.py 9 Jun 2002 04:34:21 -0000 1.1.2.18
+++ main.py 9 Jun 2002 05:22:06 -0000 1.1.2.19
@@ -27,6 +27,7 @@
# Config variables
_new_file = FALSE
_load_file = None
+_load_config = TRUE
# Get the current working directory
dirname = os.path.dirname(__file__)
@@ -58,10 +59,14 @@
self.__file_modified = FALSE
self.__options = {}
- parse_args(sys.argv[1:])
+ # See if the program should continue executing after the args have been read
+ if not parse_args(sys.argv[1:]):
+ sys.exit(0)
# init stuff goes here (load prefs blah, blah...)
- self.__load_config()
+ if _load_config:
+ self.__load_config()
+
plugin.load_all_plugins()
if _load_file:
@@ -488,29 +493,45 @@
#-------------------------------------------------------------------------------
+_help_text = """ToDo Manager
+usage: python todo-manager.py [options] [filename]
+OPTIONS:
+ -N\t\t\t:Startup with a new blank file.
+ -I\t\t\t:Don't load the configuration file.
+ --help, -h\t\t:Display this text and exit.
+ --version, -v\t\t:Display the version number and exit.
+"""
+
# The wheels on the bus go round and round
def parse_args(args):
# Parsing the command arguments
- global _load_file, _new_file
+ global _load_file, _load_config, _new_file
for arg in args:
if arg == "--help":
- pass
+ print _help_text
+ return FALSE
elif arg == "--version":
- pass
+ print "%s - %s" %(appname, version)
+ return FALSE
elif arg[0] == "-":
# Check for command switches
for a in arg[1:]:
if a == "h":
- pass
+ print _help_text
+ return FALSE
elif a == "v":
- pass
- elif a == "N": _new_file = TRUE
- elif a == "I": pass
+ print "%s - %s" %(appname, version)
+ return FALSE
+ elif a == "N": _new_file = not _new_file
+ elif a == "I": _load_config = not _load_config
elif os.path.isfile(arg):
- _load_file = arg
+ arg = os.path.join(os.getcwd(), arg)
+ if arg != default_file:
+ _load_file = arg
else:
print "%s does not exist." %arg
+ return FALSE
return TRUE
|