Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add url command.

  • Loading branch information...
commit 3c10e46e7c622bd9da2f4b0dacfcc018445afce8 1 parent 7d94e08
soulplant authored

Showing 2 changed files with 30 additions and 0 deletions. Show diff stats Hide diff stats

  1. 26  main.py
  2. 4  model.py
26  main.py
@@ -262,6 +262,31 @@ def execute(self):
262 262
         for l in self.task.logs:
263 263
             l.show()
264 264
 
  265
+class UrlCommand(Command):
  266
+    name = "url"
  267
+
  268
+    def __init__(self, args):
  269
+        Command.__init__(self)
  270
+        self.args = args
  271
+        self.url = self.has_arg('a', 'add', True)
  272
+        self.task = self.get_named_task()
  273
+
  274
+    def execute(self):
  275
+        if not self.task:
  276
+            self.no_active_tasks()
  277
+            return
  278
+        if self.url:
  279
+            self.task.add_url(self.url)
  280
+            print "Added URL."
  281
+            session.commit()
  282
+            return
  283
+        if len(self.task.urls) == 0:
  284
+            print "No urls."
  285
+            return
  286
+        for url in self.task.urls:
  287
+            url.show()
  288
+
  289
+
265 290
 Commands = [
266 291
     ListTasksCommand,
267 292
     AddTaskCommand,
@@ -274,6 +299,7 @@ def execute(self):
274 299
     ReorderCommand,
275 300
     PickCommand,
276 301
     LogCommand,
  302
+    UrlCommand,
277 303
 ]
278 304
 
279 305
 def lookup_command(name):
4  model.py
@@ -92,6 +92,10 @@ def __init__(self, url, name=None):
92 92
         self.url = url
93 93
         self.name = name
94 94
 
  95
+    # TODO Change show_* methods into string returning functions.
  96
+    def show(self):
  97
+        print self.url
  98
+
95 99
 class LogEntry(Base):
96 100
     __tablename__ = 'log_entries'
97 101
 

0 notes on commit 3c10e46

Please sign in to comment.
Something went wrong with that request. Please try again.