@cli.command()<EOL>@click.argument('<STR_LIT>', nargs=-<NUM_LIT:1>)<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>@click.option('<STR_LIT>', is_flag=True, help='<STR_LIT>')<EOL>def activate(paths, skip_local, skip_shared):
if not paths:<EOL><INDENT>ctx = click.get_current_context()<EOL>if cpenv.get_active_env():<EOL><INDENT>ctx.invoke(info)<EOL>return<EOL><DEDENT>click.echo(ctx.get_help())<EOL>examples = (<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>'<STR_LIT>'<EOL>)<EOL>click.echo(examples)<EOL>return<EOL><DEDENT>if skip_local:<EOL><INDENT>cpenv.module_resolvers.remove(cpenv.resolver.module_resolver)<EOL>cpenv.module_resolvers.remove(cpenv.resolver.active_env_module_resolver)<EOL><DEDENT>if skip_shared:<EOL><INDENT>cpenv.module_resolvers.remove(cpenv.resolver.modules_path_resolver)<EOL><DEDENT>try:<EOL><INDENT>r = cpenv.resolve(*paths)<EOL><DEDENT>except cpenv.ResolveError as e:<EOL><INDENT>click.echo('<STR_LIT:\n>' + str(e))<EOL>return<EOL><DEDENT>resolved = set(r.resolved)<EOL>active_modules = set()<EOL>env = cpenv.get_active_env()<EOL>if env:<EOL><INDENT>active_modules.add(env)<EOL><DEDENT>active_modules.update(cpenv.get_active_modules())<EOL>new_modules = resolved - active_modules<EOL>old_modules = active_modules & resolved<EOL>if old_modules and not new_modules:<EOL><INDENT>click.echo(<EOL>'<STR_LIT>'<EOL>+ bold('<STR_LIT:U+0020>'.join([obj.name for obj in old_modules]))<EOL>)<EOL>return<EOL><DEDENT>if env and contains_env(new_modules):<EOL><INDENT>click.echo('<STR_LIT>')<EOL>return<EOL><DEDENT>click.echo('<STR_LIT>')<EOL>click.echo(format_objects(r.resolved))<EOL>r.activate()<EOL>click.echo(blue('<STR_LIT>'))<EOL>modules = sorted(resolved | active_modules, key=_type_and_name)<EOL>prompt = '<STR_LIT::>'.join([obj.name for obj in modules])<EOL>shell.launch(prompt)<EOL>
Activate an environment