コード例 #1
0
ファイル: repo.py プロジェクト: muraig/asyncclick
def commit(repo, files, message):
    """Commits outstanding changes.

    Commit changes to the given files into the repository.  You will need to
    "repo push" to push up your changes to other repositories.

    If a list of files is omitted, all changes reported by "repo status"
    will be committed.
    """
    if not message:
        marker = "# Files to be committed:"
        hint = ["", "", marker, "#"]
        for file in files:
            hint.append("#   U {}".format(file))
        message = click.edit("\n".join(hint))
        if message is None:
            click.echo("Aborted!")
            return
        msg = message.split(marker)[0].rstrip()
        if not msg:
            click.echo("Aborted! Empty commit message")
            return
    else:
        msg = "\n".join(message)
    click.echo("Files to be committed: {}".format(files))
    click.echo("Commit message:\n{}".format(msg))
コード例 #2
0
ファイル: repo.py プロジェクト: makkus/asyncclick
def commit(repo, files, message):
    """Commits outstanding changes.

    Commit changes to the given files into the repository.  You will need to
    "repo push" to push up your changes to other repositories.

    If a list of files is omitted, all changes reported by "repo status"
    will be committed.
    """
    if not message:
        marker = '# Files to be committed:'
        hint = ['', '', marker, '#']
        for file in files:
            hint.append('#   U %s' % file)
        message = click.edit('\n'.join(hint))
        if message is None:
            click.echo('Aborted!')
            return
        msg = message.split(marker)[0].rstrip()
        if not msg:
            click.echo('Aborted! Empty commit message')
            return
    else:
        msg = '\n'.join(message)
    click.echo('Files to be committed: %s' % (files,))
    click.echo('Commit message:\n' + msg)
コード例 #3
0
ファイル: termui.py プロジェクト: makkus/asyncclick
def edit():
    """Opens an editor with some text in it."""
    MARKER = '# Everything below is ignored\n'
    message = click.edit('\n\n' + MARKER)
    if message is not None:
        msg = message.split(MARKER, 1)[0].rstrip('\n')
        if not msg:
            click.echo('Empty message!')
        else:
            click.echo('Message:\n' + msg)
    else:
        click.echo('You did not enter anything!')
コード例 #4
0
def edit():
    """Opens an editor with some text in it."""
    MARKER = "# Everything below is ignored\n"
    message = click.edit(f"\n\n{MARKER}")
    if message is not None:
        msg = message.split(MARKER, 1)[0].rstrip("\n")
        if not msg:
            click.echo("Empty message!")
        else:
            click.echo(f"Message:\n{msg}")
    else:
        click.echo("You did not enter anything!")
コード例 #5
0
ファイル: differ.py プロジェクト: makkus/bring
async def differ(ctx, path):
    """Clear the bring cache dir in the relevant locaiont (e.g. '~/.cache/bring' on Linux)."""

    si = SmartInput(path)
    content = await si.content_async()

    yaml = YAML()
    dict_content_orig = list(yaml.load_all(content))

    print(dict_content_orig)
    new_content = click.edit(content)

    dict_content_new = list(yaml.load_all(new_content))

    dict_diff = diff(dict_content_orig, dict_content_new)
    dict_diff = list(dict_diff)
    print(dict_diff)
コード例 #6
0
def test_fast_edit(runner):
    result = click.edit("a\nb", editor="sed -i~ 's/$/Test/'")
    assert result == "aTest\nbTest\n"