Commits

Arnaud Grausem  committed be8aa2d

Orders

  • Participants
  • Parent commits 7078af6

Comments (0)

Files changed (1)

 
 Welcome to the Adama documentation ! Adama is a light and simple command line tool and API to create **commands** for your Python applications and also subcommands named **orders**
 
-
 === Creating commands ===
 
 Imagine a little library that handles todo list. You named it pytodo and want a command that will handle the **add** order and the **done** order. Adama can brievely makes it work !
 [...]
 }}}
 \\
+Now you need to implement the logic of your script. The only code you need to write is the **execute(self, args, options)** method of the Order class. In fact, your **add.py** file looks like this :
+{{{
+#!python
+# -*- coding: utf-8 -*-
 
+"""
+"""
+
+from optparse import make_option
+
+from adama.commandment import BaseOrder, OrderError
+
+
+class Order(BaseOrder):
+    """ 
+    """
+
+    options = BaseOrder.options + ( 
+        # options for order come here
+        # use make_option
+        # see http://docs.python.org/library/optparse.html#populating-the-parser
+    )   
+
+    # this constructs a pretty help for the order
+    args = 'args of the order (ex: arg1 arg2)'
+    description = 'help for the order (ex: __doc__)'
+    examples = 'put examples here'
+
+    def __init__(self, command, module):
+        super(Order, self).__init__(command, module)
+
+    def execute(self, args, options):
+        # the logic of the order comes here
+        return 0
+}}}
+\\
 === Customizations on command ===
 
 You can easily customize your command as :