Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CLI output spacing if a frame has not tags #179

Merged
merged 1 commit into from
Dec 11, 2017

Conversation

MinchinWeb
Copy link
Contributor

If a frame has no tags, sometimes the CLI output formating will output spaces that aren't needed. This fixes that.

Broken off of #176.

@willdurand willdurand requested a review from jmaupetit December 9, 2017 21:42
@MinchinWeb MinchinWeb mentioned this pull request Dec 9, 2017
Copy link
Contributor

@SpotlightKid SpotlightKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And please rebase on master.

watson/cli.py Outdated
delta=format_timedelta(frame.stop - frame.start),
project=style('project',
'{:>{}}'.format(frame.project, longest_project)),
pad=longest_project,
tags_spacer=" " if frame.tags else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is much simpler:

        lines.append("\n".join(
            "\t{id}  {start} to {stop}  {delta:>11}  {project}{tags}".format(
                delta=format_timedelta(frame.stop - frame.start),
                project=style('project',
                              '{:>{}}'.format(frame.project, longest_project)),
                pad=longest_project,
                tags=("  " if frame.tags else "") + style('tags', frame.tags),
                ....

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me 👍

watson/cli.py Outdated
delta=format_timedelta(stop - start) if stop else '-',
project=style('project', project),
tags_spacer=" " if tags else "",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likewise:

    click.echo(
        "Edited frame for project {project}{tags}, from {start} "
        "to {stop} ({delta})".format(
            delta=format_timedelta(stop - start) if stop else '-',
            project=style('project', project),
            tags=(" " if tags else "") + style('tags', tags),
            ...

watson/cli.py Outdated
project=style('project', frame.project),
tags_spacer=" " if tags else "",
Copy link
Contributor

@SpotlightKid SpotlightKid Dec 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And lastly:

        click.confirm(
            "You are about to remove frame {project}{tags} from "
            "{start} to {stop}, continue?".format(
                project=style('project', frame.project),
                tags=(" " if frame.tags else "") + style('tags', frame.tags),
                ...

Also respect 79 char line limit and use double quotes
@MinchinWeb MinchinWeb force-pushed the no-spaces-with-no-tags branch from 903e75f to f355a4d Compare December 11, 2017 17:46
@MinchinWeb
Copy link
Contributor Author

Rebased onto Master and updated as suggested.

Copy link
Contributor

@SpotlightKid SpotlightKid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now.

watson/cli.py Outdated
@@ -826,9 +829,10 @@ def remove(watson, id, force):

if not force:
click.confirm(
"You are about to remove frame "
"{project} {tags} from {start} to {stop}, continue?".format(
"You are about to remove frame {project}{tags_spacer}{tags} from "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's one space too many in front of {project}.

@SpotlightKid SpotlightKid merged commit d10b57f into jazzband:master Dec 11, 2017
@MinchinWeb MinchinWeb deleted the no-spaces-with-no-tags branch December 11, 2017 18:13
@jmaupetit
Copy link
Contributor

Thanks @MinchinWeb !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants