Skip to content

Commit fc8be64

Browse files
Make subcommand output text consistent
Signed-off-by: Jacob Stopak <jacob@initialcommit.io>
1 parent 77b2274 commit fc8be64

15 files changed

+33
-18
lines changed

git_sim/git_sim_add.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ def __init__(self, files: list[str]):
2929
sys.exit()
3030

3131
def construct(self):
32-
print(Settings.INFO_STRING + "add " + " ".join(self.files))
32+
print(
33+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {' '.join(self.files)}"
34+
)
3335

3436
self.show_intro()
3537
self.get_commits()

git_sim/git_sim_base_command.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ def init_repo(self):
4242
print("git-sim error: No Git repository found at current path.")
4343
sys.exit(1)
4444

45-
def execute(self):
46-
print("Simulating: git " + Settings.subcommand)
45+
def construct(self):
46+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()}")
4747
self.show_intro()
4848
self.get_commits()
4949
self.fadeout()

git_sim/git_sim_branch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, name: str):
1212
self.name = name
1313

1414
def construct(self):
15-
print(f"{Settings.INFO_STRING} branch {self.name}")
15+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.name}")
1616

1717
self.show_intro()
1818
self.get_commits()

git_sim/git_sim_cherrypick.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ def __init__(self, commit: str, edit: str):
3434
pass
3535

3636
def construct(self):
37-
substring = ""
38-
if self.edit:
39-
substring = f' -e "{self.edit}"'
40-
print(f"{Settings.INFO_STRING} cherrypick {self.commit}{substring}")
37+
print(
38+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.commit}"
39+
+ ((' -e "' + self.edit + '"') if self.edit else "")
40+
)
4141

4242
if self.repo.active_branch.name in self.repo.git.branch(
4343
"--contains", self.commit

git_sim/git_sim_commit.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import manim as m
55
import typer
66
from git_sim.animations import handle_animations
7+
from git_sim.settings import Settings
78

89
from git_sim.git_sim_base_command import GitSimBaseCommand
910

@@ -31,7 +32,10 @@ def __init__(self, message: str, amend: bool):
3132

3233
def construct(self):
3334
print(
34-
f"Simulating: git commit {' --amend' if self.amend else ''} -m '{self.message}'"
35+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {'--amend ' if self.amend else ''}"
36+
+ '-m "'
37+
+ self.message
38+
+ '"'
3539
)
3640

3741
self.show_intro()

git_sim/git_sim_log.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def __init__(self, commits: int):
1616
pass
1717

1818
def construct(self):
19-
print(Settings.INFO_STRING + type(self).__name__)
19+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()}")
2020
self.show_intro()
2121
self.get_commits()
2222
self.parse_commits(self.commits[0])

git_sim/git_sim_merge.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ def __init__(self, branch: str, no_ff: bool):
3737
pass
3838

3939
def construct(self):
40-
print(Settings.INFO_STRING + "merge " + self.branch)
40+
print(
41+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.branch} {'--no-ff' if self.no_ff else ''}"
42+
)
4143

4244
if self.repo.active_branch.name in self.repo.git.branch(
4345
"--contains", self.branch

git_sim/git_sim_rebase.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def __init__(self, branch: str):
3434
pass
3535

3636
def construct(self):
37-
print(Settings.INFO_STRING + "rebase " + self.branch)
37+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.branch}")
3838

3939
if self.branch in self.repo.git.branch(
4040
"--contains", self.repo.active_branch.name

git_sim/git_sim_reset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def __init__(
5050

5151
def construct(self):
5252
print(
53-
f"{Settings.INFO_STRING} reset {' --' + self.mode.value if self.mode != ResetMode.DEFAULT else ''} {self.commit}",
53+
f"{Settings.INFO_STRING} {type(self).__name__.lower()}{' --' + self.mode.value if self.mode != ResetMode.DEFAULT else ''} {self.commit}",
5454
)
5555

5656
self.show_intro()

git_sim/git_sim_restore.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ def __init__(self, files: list[str]):
2727
sys.exit()
2828

2929
def construct(self):
30-
print(Settings.INFO_STRING + "restore " + " ".join(self.files))
30+
print(
31+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {' '.join(self.files)}"
32+
)
3133

3234
self.show_intro()
3335
self.get_commits()

git_sim/git_sim_revert.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(self, commit: str):
3636
pass
3737

3838
def construct(self):
39-
print(Settings.INFO_STRING + "revert " + self.commit)
39+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.commit}")
4040

4141
self.show_intro()
4242
self.get_commits()

git_sim/git_sim_stash.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55

66
from git_sim.animations import handle_animations
77
from git_sim.git_sim_base_command import GitSimBaseCommand
8+
from git_sim.settings import Settings
89

910

1011
class Stash(GitSimBaseCommand):
1112
def __init__(self, files: list[str]):
1213
super().__init__()
1314
self.hide_first_tag = True
1415
self.files = files
16+
self.no_files = True if not self.files else False
1517

1618
try:
1719
self.selected_branches.append(self.repo.active_branch.name)
@@ -31,7 +33,9 @@ def __init__(self, files: list[str]):
3133
]
3234

3335
def construct(self):
34-
print("Simulating: git stash " + " ".join(self.files))
36+
print(
37+
f"{Settings.INFO_STRING} {type(self).__name__.lower()} {' '.join(self.files) if not self.no_files else ''}"
38+
)
3539

3640
self.show_intro()
3741
self.get_commits()

git_sim/git_sim_status.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def __init__(self):
1212
pass
1313

1414
def construct(self):
15+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()}")
1516
self.show_intro()
1617
self.get_commits()
1718
self.parse_commits(self.commits[0])

git_sim/git_sim_tag.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def __init__(self, name: str):
1212
self.name = name
1313

1414
def construct(self):
15-
print(f"{Settings.INFO_STRING} tag {self.name}")
15+
print(f"{Settings.INFO_STRING} {type(self).__name__.lower()} {self.name}")
1616

1717
self.show_intro()
1818
self.get_commits()

git_sim/settings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Settings:
3232
allow_no_commits = False
3333
low_quality = False
3434
auto_open = True
35-
INFO_STRING = "Simulating: git "
35+
INFO_STRING = "Simulating: git"
3636
# os.path.join(str(pathlib.Path(__file__).parent.resolve()), "logo.png")
3737
logo = pathlib.Path(__file__).parent.resolve() / "logo.png"
3838
media_dir = pathlib.Path().cwd()

0 commit comments

Comments
 (0)