adama / src / adama / orders /

# -*- coding: utf-8 -*-

"""Create Program Order

import sys
import os
from optparse import make_option

from ..commandment import BaseOrder, OrderError
from . import get_module, get_template, get_command

class Order(BaseOrder):
    """Creates a command line program for your application that will look for orders

  module      Python module that contains or will contain the orders module

    options = BaseOrder.options + (
        make_option('-d', '--directory', action='store', type='string',
            dest='path', metavar='PATH', default=os.getcwd(),
            help='directory to save the command [Default: %default]'),

    args = "module"
    description = __doc__.split('\n')[0].lower()
    examples = ""

    def __init__(self):
        super(Order, self).__init__('adama', command='adama')

    def execute(self, *args, **options):
        if len(args) != 1:
            raise OrderError('The create_program has one required argument',

        module = get_module(args[0], options['pythonpath'])

        # Checks if entered path exists and create it
        if not os.path.isdir(options['path']):

        # Defines the command name
        command_name = get_command(options['name'], module)

        # Path to save the command
        file_path = os.path.join(options['path'], command_name)

        # Writes data coming from template to file
        with open(file_path, "w") as program:
            template = get_template('program')

        return 0
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.