Ejemplo n.º 1
0
Archivo: edit.py Proyecto: cpenv/cpenv
    def run(self, args):
        core.echo()
        if args.env:
            return self.run_env(args.module_or_environment)

        try:
            module_spec = api.resolve([args.module_or_environment])[0]
        except ResolveError:
            sys.exit(1)

        if not isinstance(module_spec.repo, repos.LocalRepo):
            core.echo("%s - %s" % (module_spec.qual_name, module_spec.path))
            core.echo("Error: Can only edit modules in local repositories.")
            sys.exit(1)

        editor = os.getenv("CPENV_EDITOR", os.getenv("EDITOR", "subl"))
        core.echo("Opening %s in %s." % (module_spec.path, editor))
        shell.run(editor, module_spec.path)
Ejemplo n.º 2
0
    def run(self, args):
        cli.echo()
        if args.env:
            return self.run_env(args.module_or_environment)

        try:
            module_spec = api.resolve([args.module_or_environment])[0]
        except ResolveError:
            sys.exit(1)

        if not isinstance(module_spec.repo, LocalRepo):
            cli.echo('%s - %s' % (module_spec.qual_name, module_spec.path))
            cli.echo('Error: Can only edit modules in local repositories.')
            sys.exit(1)

        editor = os.getenv('CPENV_EDITOR', os.getenv('EDITOR', 'subl'))
        cli.echo('Opening %s in %s.' % (module_spec.path, editor))
        shell.run(editor, module_spec.path)
Ejemplo n.º 3
0
    def run_env(self, environment):
        file = None
        repo = False
        found_in_remote = False
        for repo in api.get_repos():
            for env in repo.list_environments():
                if env.name == environment:
                    if isinstance(repo, LocalRepo):
                        file = env.path
                        break
                    else:
                        repo = repo
                        found_in_remote = True
            if file:
                break

        if found_in_remote:
            cli.echo('Error: Can only edit Environments in local repos.')
            cli.echo('Found %s in repo %s' % (environment, repo.name))
            sys.exit(1)

        editor = os.getenv('CPENV_EDITOR', os.getenv('EDITOR', 'subl'))
        cli.echo('Opening %s in %s.' % (file, editor))
        shell.run(editor, file)
Ejemplo n.º 4
0
    def run(self, args):

        config_path = api.get_config_path()
        editor = os.getenv("CPENV_EDITOR", os.getenv("EDITOR", "subl"))
        core.echo("Opening %s in %s." % (config_path, editor))
        shell.run(editor, config_path)