Skip to content

Commit d8cbb35

Browse files
Add --quiet, -q flag to suppress all output except errors
Signed-off-by: Jacob Stopak <[email protected]>
1 parent 8cd527c commit d8cbb35

17 files changed

+39
-20
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ The `[global options]` apply to the overarching `git-sim` simulation itself, inc
140140
`--reverse, -r`: Display commit history in the reverse direction.
141141
`--img-format`: Output format for the image file, i.e. `jpg` or `png`. Default output format is `jpg`.
142142
`--stdout`: Write raw image data to stdout while suppressing all other program output.
143-
`--output-only-path`: Only output the path to the generated media file to stdout. Useful for other programs to ingest.
143+
`--output-only-path`: Only output the path to the generated media file to stdout. Useful for other programs to ingest.
144+
`--quiet, -q`: Suppress all output except errors.
144145

145146
Animation-only global options (to be used in conjunction with `--animate`):
146147

git_sim/__main__.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,12 @@ def main(
111111
settings.output_only_path,
112112
help="Only output the path to the generated media file to stdout (useful for other programs to ingest)",
113113
),
114+
quiet: bool = typer.Option(
115+
settings.quiet,
116+
"--quiet",
117+
"-q",
118+
help="Suppress all output except errors",
119+
),
114120
):
115121
settings.animate = animate
116122
settings.auto_open = auto_open
@@ -131,6 +137,7 @@ def main(
131137
settings.video_format = video_format
132138
settings.stdout = stdout
133139
settings.output_only_path = output_only_path
140+
settings.quiet = quiet
134141

135142
if sys.platform == "linux" or sys.platform == "darwin":
136143
repo_name = git.repo.Repo(

git_sim/add.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, files: List[str]):
3030
sys.exit()
3131

3232
def construct(self):
33-
if not settings.stdout and not settings.output_only_path:
33+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
3434
print(
3535
f"{settings.INFO_STRING} {type(self).__name__.lower()} {' '.join(self.files)}"
3636
)

git_sim/animations.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,22 @@ def handle_animations(scene: Scene) -> None:
4747
os.path.join(settings.media_dir, "images"), image_file_name
4848
)
4949
cv2.imwrite(image_file_path, image)
50-
if not settings.stdout and not settings.output_only_path:
50+
if (
51+
not settings.stdout
52+
and not settings.output_only_path
53+
and not settings.quiet
54+
):
5155
print("Output image location:", image_file_path)
52-
elif not settings.stdout and settings.output_only_path:
56+
elif (
57+
not settings.stdout and settings.output_only_path and not settings.quiet
58+
):
5359
print(image_file_path)
54-
if settings.stdout:
60+
if settings.stdout and not settings.quiet:
5561
sys.stdout.buffer.write(cv2.imencode(".jpg", image)[1].tobytes())
5662
else:
57-
if not settings.stdout and not settings.output_only_path:
63+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
5864
print("Output video location:", scene.renderer.file_writer.movie_file_path)
59-
elif not settings.stdout and settings.output_only_path:
65+
elif not settings.stdout and settings.output_only_path and not settings.quiet:
6066
print(scene.renderer.file_writer.movie_file_path)
6167

6268
if settings.auto_open and not settings.stdout:

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-
if not settings.stdout and not settings.output_only_path:
15+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
1616
print(f"{settings.INFO_STRING} {type(self).__name__.lower()} {self.name}")
1717

1818
self.show_intro()

git_sim/cherrypick.py

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

3636
def construct(self):
37-
if not settings.stdout and not settings.output_only_path:
37+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
3838
print(
3939
f"{settings.INFO_STRING} cherry-pick {self.commit}"
4040
+ ((' -e "' + self.edit + '"') if self.edit else "")

git_sim/commit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def __init__(self, message: str, amend: bool):
3131
sys.exit(1)
3232

3333
def construct(self):
34-
if not settings.stdout and not settings.output_only_path:
34+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
3535
print(
3636
f"{settings.INFO_STRING } {type(self).__name__.lower()} {'--amend ' if self.amend else ''}"
3737
+ '-m "'

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-
if not settings.stdout and not settings.output_only_path:
19+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
2020
print(f"{settings.INFO_STRING} {type(self).__name__.lower()}")
2121
self.show_intro()
2222
self.get_commits()

git_sim/merge.py

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

3939
def construct(self):
40-
if not settings.stdout and not settings.output_only_path:
40+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
4141
print(
4242
f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.branch} {'--no-ff' if self.no_ff else ''}"
4343
)

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-
if not settings.stdout and not settings.output_only_path:
37+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
3838
print(
3939
f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.branch}"
4040
)

git_sim/reset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(
4949
self.mode = ResetMode.SOFT
5050

5151
def construct(self):
52-
if not settings.stdout and not settings.output_only_path:
52+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
5353
print(
5454
f"{settings.INFO_STRING } {type(self).__name__.lower()}{' --' + self.mode.value if self.mode != ResetMode.DEFAULT else ''} {self.commit}",
5555
)

git_sim/restore.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def __init__(self, files: List[str]):
2828
sys.exit()
2929

3030
def construct(self):
31-
if not settings.stdout and not settings.output_only_path:
31+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
3232
print(
3333
f"{settings.INFO_STRING } {type(self).__name__.lower()} {' '.join(self.files)}"
3434
)

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-
if not settings.stdout and not settings.output_only_path:
39+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
4040
print(
4141
f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.commit}"
4242
)

git_sim/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class Settings(BaseSettings):
4040
video_format: VideoFormat = VideoFormat.mp4
4141
stdout = False
4242
output_only_path = False
43+
quiet = False
4344

4445
class Config:
4546
env_prefix = "git_sim_"

git_sim/stash.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,17 @@ def __init__(self, files: List[str], command: StashSubCommand):
4444
y.a_path for y in self.repo.index.diff("HEAD")
4545
]
4646
elif self.files:
47-
if not settings.stdout and not settings.output_only_path:
47+
if (
48+
not settings.stdout
49+
and not settings.output_only_path
50+
and not settings.quiet
51+
):
4852
print(
4953
"Files are not required in apply/pop subcommand. Ignoring the file list....."
5054
)
5155

5256
def construct(self):
53-
if not settings.stdout and not settings.output_only_path:
57+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
5458
print(
5559
f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.command.value if self.command else ''} {' '.join(self.files) if not self.no_files else ''}"
5660
)

git_sim/status.py

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

1414
def construct(self):
15-
if not settings.stdout and not settings.output_only_path:
15+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
1616
print(f"{settings.INFO_STRING } {type(self).__name__.lower()}")
1717
self.show_intro()
1818
self.get_commits()

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-
if not settings.stdout and not settings.output_only_path:
15+
if not settings.stdout and not settings.output_only_path and not settings.quiet:
1616
print(f"{settings.INFO_STRING } {type(self).__name__.lower()} {self.name}")
1717

1818
self.show_intro()

0 commit comments

Comments
 (0)