~romaimperator/keryx/devel

« back to all changes in this revision

Viewing changes to keryx.py

  • Committer: Chris Oliver
  • Date: 2009-10-02 17:59:58 UTC
  • Revision ID: excid3@gmail.com-20091002175958-7fp1v3id0fi2bopy
Semifunctional interactive cli

Show diffs side-by-side

added added

removed removed

Lines of Context:
162
162
 
163
163
class KeryxCLI():
164
164
    """Keryx Interactive CLI"""
165
 
    
 
165
    help = """
 
166
Commands:
 
167
open <project name>
 
168
create - Creates the current project into database
 
169
update - Updates the current project
 
170
"""
166
171
    
167
172
    def __init__(self, name):
168
173
        """Set project for CLI usage"""
178
183
 
179
184
    def main(self):
180
185
        """Main loop for Keryx interactive CLI"""
 
186
        if os.system("clear") != 0:
 
187
            os.system("cls")
181
188
        print "\nKeryx %s Interactive Command Line Interface\n" % __version__
182
189
        
183
 
        command = ""
184
 
        while command != "exit":
185
 
            command = raw_input("%s:%s>" % (__appname__, self.name))
186
 
            if command.startswith("open"):
187
 
                name = command.split("open")[1].strip()
188
 
                self.set_project(name)
189
 
            elif command == "create":
190
 
                self.project.Create()
191
 
            elif command == "update":
192
 
                self.project.UpdateInternet()
 
190
        command = [""]
 
191
        while command[0] != "exit":
 
192
            command = raw_input("%s:%s>" % (__appname__, self.name)).strip().split()
 
193
            if command:
 
194
                if command[0] == "open":
 
195
                    if len(command) > 1:
 
196
                        name = command[1].strip()
 
197
                        self.set_project(name)
 
198
                    else:
 
199
                        print self.help
 
200
                elif command[0] == "help":
 
201
                    print self.help
 
202
                elif command[0] == "create":
 
203
                    self.project.Create()
 
204
                elif command[0] == "update":
 
205
                    self.project.UpdateInternet()
 
206
            else:
 
207
                command = [""]
193
208
 
194
209
                        
195
210