1
1
import pathlib
2
-
3
2
import typer
3
+ import os
4
+ import sys
5
+ import datetime
6
+ import time
7
+ import git
4
8
5
9
import git_sim .add
6
10
import git_sim .branch
16
20
import git_sim .status
17
21
import git_sim .tag
18
22
from git_sim .settings import ImgFormat , VideoFormat , settings
23
+ from manim import config , WHITE
19
24
20
25
app = typer .Typer (context_settings = {"help_option_names" : ["-h" , "--help" ]})
21
26
22
27
23
28
@app .callback (no_args_is_help = True )
24
29
def main (
30
+ ctx : typer .Context ,
25
31
animate : bool = typer .Option (
26
32
settings .animate ,
27
33
help = "Animate the simulation and output as an mp4 video" ,
@@ -110,7 +116,7 @@ def main(
110
116
settings .low_quality = low_quality
111
117
settings .max_branches_per_commit = max_branches_per_commit
112
118
settings .max_tags_per_commit = max_tags_per_commit
113
- settings .media_dir = media_dir
119
+ settings .media_dir = os . path . join ( os . path . expanduser ( media_dir ), "git-sim_media" )
114
120
settings .outro_bottom_text = outro_bottom_text
115
121
settings .outro_top_text = outro_top_text
116
122
settings .reverse = reverse
@@ -121,6 +127,29 @@ def main(
121
127
settings .video_format = video_format
122
128
settings .stdout = stdout
123
129
130
+ if sys .platform == "linux" or sys .platform == "darwin" :
131
+ repo_name = git .repo .Repo (
132
+ search_parent_directories = True
133
+ ).working_tree_dir .split ("/" )[- 1 ]
134
+ elif sys .platform == "win32" :
135
+ repo_name = git .repo .Repo (
136
+ search_parent_directories = True
137
+ ).working_tree_dir .split ("\\ " )[- 1 ]
138
+
139
+ settings .media_dir = os .path .join (settings .media_dir , repo_name )
140
+
141
+ config .media_dir = settings .media_dir
142
+ config .verbosity = "ERROR"
143
+
144
+ if settings .low_quality :
145
+ config .quality = "low_quality"
146
+
147
+ if settings .light_mode :
148
+ config .background_color = WHITE
149
+
150
+ t = datetime .datetime .fromtimestamp (time .time ()).strftime ("%m-%d-%y_%H-%M-%S" )
151
+ config .output_file = "git-sim-" + ctx .invoked_subcommand + "_" + t + ".mp4"
152
+
124
153
125
154
app .command ()(git_sim .add .add )
126
155
app .command ()(git_sim .branch .branch )
0 commit comments