@project.command(short_help="<STR_LIT>")<EOL>@click.option('<STR_LIT>', '<STR_LIT>', help="<STR_LIT>")<EOL>@click.argument('<STR_LIT>', nargs=-<NUM_LIT:1>)<EOL>@click.pass_context<EOL>def alias(ctx, search, backend):
projects = ctx.obj['<STR_LIT>'].search(search, active_only=True)<EOL>projects = sorted(projects, key=lambda project: project.name)<EOL>if len(projects) == <NUM_LIT:0>:<EOL><INDENT>ctx.obj['<STR_LIT>'].msg(<EOL>"<STR_LIT>" %<EOL>'<STR_LIT>'.join(search)<EOL>)<EOL>return<EOL><DEDENT>ctx.obj['<STR_LIT>'].projects_list(projects, True)<EOL>try:<EOL><INDENT>number = ctx.obj['<STR_LIT>'].select_project(projects)<EOL><DEDENT>except CancelException:<EOL><INDENT>return<EOL><DEDENT>project = projects[number]<EOL>ctx.obj['<STR_LIT>'].project_with_activities(project, numbered_activities=True)<EOL>try:<EOL><INDENT>number = ctx.obj['<STR_LIT>'].select_activity(project.activities)<EOL><DEDENT>except CancelException:<EOL><INDENT>return<EOL><DEDENT>retry = True<EOL>while retry:<EOL><INDENT>try:<EOL><INDENT>alias = ctx.obj['<STR_LIT>'].select_alias()<EOL><DEDENT>except CancelException:<EOL><INDENT>return<EOL><DEDENT>if alias in aliases_database:<EOL><INDENT>mapping = aliases_database[alias]<EOL>overwrite = ctx.obj['<STR_LIT>'].overwrite_alias(alias, mapping)<EOL>if not overwrite:<EOL><INDENT>return<EOL><DEDENT>elif overwrite:<EOL><INDENT>retry = False<EOL><DEDENT>else:<EOL><INDENT>retry = True<EOL><DEDENT><DEDENT>else:<EOL><INDENT>retry = False<EOL><DEDENT><DEDENT>activity = project.activities[number]<EOL>mapping = Mapping(mapping=(project.id, activity.id),<EOL>backend=project.backend)<EOL>ctx.obj['<STR_LIT>'].add_alias(alias, mapping)<EOL>ctx.obj['<STR_LIT>'].write_config()<EOL>ctx.obj['<STR_LIT>'].alias_added(alias, (project.id, activity.id))<EOL>
Searches for the given project and interactively add an alias for it.