Ejemplo n.º 1
0
def main():
    """Primary Legit command dispatch."""

    if (args.get(0) in cmd_map) or (args.get(0) in short_map):
        arg = args.get(0)
        args.remove(arg)

        if arg in short_map:
            arg = short_map.get(arg)

        cmd_map.get(arg).__call__(args)
        sys.exit()

    elif args.contains(('-h', '--help')):
        display_help()
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    else:
        if settings.git_transparency:
            # Send everything to git
            git_args = list(sys.argv)
            if settings.git_transparency is True:
                settings.git_transparency = 'git'

            git_args[0] = settings.git_transparency

            sys.exit(call(' '.join(git_args), shell=True))

        else:
            display_info()
            sys.exit(1)
Ejemplo n.º 2
0
def main():
    """Primary Legit command dispatch."""

    if (args.get(0) in cmd_map) or (args.get(0) in short_map):
        arg = args.get(0)
        args.remove(arg)

        if arg in short_map:
            arg = short_map.get(arg)

        cmd_map.get(arg).__call__(args)
        sys.exit()

    elif args.contains(('-h', '--help')):
        display_help()
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    else:
        if settings.git_transparency:
            # Send everything to git
            git_args = list(sys.argv)
            if settings.git_transparency is True:
                settings.git_transparency = 'git'

            git_args[0] = settings.git_transparency

            sys.exit(call(' '.join(git_args), shell=True))

        else:
            display_info()
            sys.exit(1)
Ejemplo n.º 3
0
def main():
    """Primary Legit command dispatch."""

    command = Command.lookup(args.get(0))
    if command:
        arg = args.get(0)
        args.remove(arg)

        command.__call__(args)
        sys.exit()

    elif args.contains(('-h', '--help')):
        display_help()
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    else:
        if settings.git_transparency:
            # Send everything to git
            git_args = list(sys.argv)
            if settings.git_transparency is True:
                settings.git_transparency = os.environ.get("GIT_PYTHON_GIT_EXECUTABLE", 'git')

            git_args[0] = settings.git_transparency

            sys.exit(call(' '.join(git_args), shell=True))

        else:
            show_error(colored.red('Unknown command {0}'.format(args.get(0))))
            display_info()
            sys.exit(1)
Ejemplo n.º 4
0
def tarbell_switch(args):
    """Switch to a project"""
    with ensure_settings(args) as settings:
        projects_path = settings.config.get("projects_path")
        if not projects_path:
            show_error("{0} does not exist".format(projects_path))
            sys.exit()
        project = args.get(0)
        args.remove(project)
        project_path = os.path.join(projects_path, project)
        if os.path.isdir(project_path):
            os.chdir(project_path)
            puts("\nSwitching to {0}".format(colored.red(project)))
            puts("Edit this project's templates at {0}".format(colored.yellow(project_path)))
            puts("Running preview server...")
            tarbell_serve(args)
        else:
            show_error("{0} isn't a tarbell project".format(project_path))
Ejemplo n.º 5
0
Archivo: cli.py Proyecto: eads/tarbell
def tarbell_switch(args):
    """Switch to a project"""
    with ensure_settings(args) as settings:
        projects_path = settings.config.get("projects_path")
        if not projects_path:
            show_error("{0} does not exist".format(projects_path))
            sys.exit()
        project = args.get(0)
        args.remove(project)
        project_path = os.path.join(projects_path, project)
        if os.path.isdir(project_path):
            os.chdir(project_path)
            puts("\nSwitching to {0}".format(colored.red(project)))
            puts("Edit this project's templates at {0}".format(
                colored.yellow(project_path)))
            puts("Running preview server...")
            tarbell_serve(args)
        else:
            show_error("{0} isn't a tarbell project".format(project_path))
Ejemplo n.º 6
0
def main():
    """Primary Tarbell command dispatch."""

    command = Command.lookup(args.get(0))

    if len(args) == 0 or args.contains(('-h', '--help', 'help')):
        display_info(args)
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    elif command:
        arg = args.get(0)
        args.remove(arg)
        command.__call__(args)
        sys.exit()

    else:
        show_error(colored.red('Error! Unknown command `{0}`.\n'
                               .format(args.get(0))))
        display_info(args)
        sys.exit(1)
Ejemplo n.º 7
0
def main():
    """Primary Legit command dispatch."""

    if (args.get(0) in cmd_map) or (args.get(0) in short_map):
        arg = args.get(0)
        args.remove(arg)

        if arg in short_map:
            arg = short_map.get(arg)

        cmd_map.get(arg).__call__(args)
        sys.exit()

    elif args.contains(('-h', '--help')):
        display_help()
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    else:
        display_info()
        sys.exit(1)
Ejemplo n.º 8
0
Archivo: cli.py Proyecto: eads/tarbell
def main():
    """Primary Tarbell command dispatch."""

    command = Command.lookup(args.get(0))

    if len(args) == 0 or args.contains(('-h', '--help', 'help')):
        display_info(args)
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    elif command:
        arg = args.get(0)
        args.remove(arg)
        command.__call__(args)
        sys.exit()

    else:
        show_error(
            colored.red('Error! Unknown command `{0}`.\n'.format(args.get(0))))
        display_info(args)
        sys.exit(1)
Ejemplo n.º 9
0
def main():
    """Primary Legit command dispatch."""

    if (args.get(0) in cmd_map) or (args.get(0) in short_map):
        arg = args.get(0)
        args.remove(arg)

        if arg in short_map:
            arg = short_map.get(arg)

        cmd_map.get(arg).__call__(args)
        sys.exit()

    elif args.contains(('-h', '--help')):
        display_help()
        sys.exit(1)

    elif args.contains(('-v', '--version')):
        display_version()
        sys.exit(1)

    else:
        display_info()
        sys.exit(1)