Skip to content

Commit

Permalink
feat(cli): unified the display format of description in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
yeyong.yu committed Jul 14, 2021
1 parent 58fcf1d commit 2ffdbde
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
2 changes: 1 addition & 1 deletion tensorbay/cli/commit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from .tbrn import TBRN, TBRNType
from .utility import edit_message, error, format_hint, get_dataset_client, get_gas

_COMMIT_HINT = """
_COMMIT_HINT = """{}{}
# Please enter the commit message for your changes.
# The Default commit message is set as the draft title.
# Lines starting with '#' will be ignored.
Expand Down
5 changes: 3 additions & 2 deletions tensorbay/cli/draft.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .tbrn import TBRN, TBRNType
from .utility import edit_message, error, format_hint, get_dataset_client, get_gas

_DRAFT_HINT = """
_DRAFT_HINT = """{}{}
# Please enter the message for your draft.
# Lines starting with '#' will be ignored.
# And an empty draft message aborts the creation.
Expand Down Expand Up @@ -46,7 +46,7 @@ def _create_draft(dataset_client: DatasetClientType, info: TBRN, message: Tuple[
if info.is_draft:
error(f'Create a draft in draft status "{info}" is not permitted')

title, description = edit_message(message, _DRAFT_HINT)
title, description = edit_message(message, _DRAFT_HINT.format("", ""))
if not title:
error("Aborting creating draft due to empty draft message")

Expand Down Expand Up @@ -94,6 +94,7 @@ def _echo_draft(
title = "<no title>"
click.echo(f"\n {title}\n")
if description:
description = description.replace("\n", "\n ")
click.echo(f" {description}\n")


Expand Down
12 changes: 6 additions & 6 deletions tensorbay/cli/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,7 @@
Author: {}
Date: {}
{}
{}
{}{}
"""


Expand All @@ -45,10 +42,13 @@ def _get_oneline_log(commit: Commit) -> str:


def _get_full_log(commit: Commit) -> str:
description = commit.description
if description:
description = "\n".join(("", " " + description.replace("\n", "\n "), ""))
return _FULL_LOG.format(
commit.commit_id,
commit.committer.name,
datetime.fromtimestamp(commit.committer.date).strftime("%a %b %d %H:%M:%S %y"),
commit.title,
commit.description,
commit.title + "\n",
description,
)
6 changes: 2 additions & 4 deletions tensorbay/cli/utility.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,9 @@ def format_hint(title: str, description: str, original_hint: str) -> str:
The complete hint message.
"""
hint: Tuple[str, ...] = (title,)
if description:
hint += ("", description)
hint += (original_hint,)
return "\n".join(hint)
description = "\n".join(("", description, ""))
return original_hint.format(title + "\n", description)


def edit_message(message: Tuple[str, ...], hint_message: str) -> Tuple[str, str]:
Expand Down

0 comments on commit 2ffdbde

Please sign in to comment.