Esempio n. 1
0
    def start(argv, util, parser):

        cd = False
        opts, args = parser(argv)
        for opt, arg in opts:
            if opt in ('-h','--help'):
                util.usage()
            elif opt in ('-c', '--cd'):
                cd = True

        if len(args) < 1:
            log('start requires a project_name')
            util.usage(error_codes['option'])

        next = ''
        if cd:
            project_name, next = parse_project(' '.join(args))
        else:
            project_name = ' '.join(args)

        proj = load_project(project_name)
        cmd = proj['start_cmd']
        root = proj['root']

        sworklib.popproj()
        sworklib.restore_env()
        output('export SW_PROJECT_ROOT=%s' % (root))
        output('cd %s' % (root))
        output('%s' % (cmd))
        output('cd %s' % (CWD))
        sworklib.pushproj(project_name)
        if cd:
            output("cd %s" % os.path.join(root, next))
Esempio n. 2
0
    def restore(argv, util, parser):
        '''restores the shell to its original state.'''

        opts, args = parser(argv)
        for opt, arg in opts:
            if opt in ('-h','--help',):
                util.usage()

        sworklib.popproj()
        sworklib.restore_env()
        output('cd %s' % (CWD))