3030# Helpers
3131# ---------------------------------------------------------------------------
3232
33+
3334def _find_specs_dir (config , base_dir ) -> Path | None :
3435 """Find the specifications repo directory via the repo config."""
3536 repo = find_repo_by_name ("specifications" , base_dir , config )
@@ -100,13 +101,19 @@ def _apply_patches(driver_repo, verbose: bool = False) -> bool:
100101 return True
101102
102103 cmd = [
103- "git" , "apply" , "-R" , "--allow-empty" , "--whitespace=fix" ,
104+ "git" ,
105+ "apply" ,
106+ "-R" ,
107+ "--allow-empty" ,
108+ "--whitespace=fix" ,
104109 * [str (p ) for p in patches ],
105110 ]
106111 if verbose :
107112 typer .echo (f"[verbose] Running: { ' ' .join (cmd )} " )
108113
109- result = subprocess .run (cmd , cwd = str (driver_repo ["path" ]), check = False , capture_output = True , text = True )
114+ result = subprocess .run (
115+ cmd , cwd = str (driver_repo ["path" ]), check = False , capture_output = True , text = True
116+ )
110117 if result .returncode != 0 :
111118 typer .echo (f"❌ Failed to apply patches: { result .stderr .strip ()} " , err = True )
112119 return False
@@ -117,6 +124,7 @@ def _apply_patches(driver_repo, verbose: bool = False) -> bool:
117124# dbx spec sync
118125# ---------------------------------------------------------------------------
119126
127+
120128@app .command ("sync" )
121129def spec_sync (
122130 ctx : typer .Context ,
@@ -186,13 +194,17 @@ def spec_sync(
186194 else :
187195 mdb_specs = _find_specs_dir (config , base_dir )
188196 if not mdb_specs :
189- typer .echo ("❌ Error: Could not find the 'specifications' repository" , err = True )
197+ typer .echo (
198+ "❌ Error: Could not find the 'specifications' repository" , err = True
199+ )
190200 typer .echo ("\n Clone it with: dbx clone specifications" )
191201 typer .echo ("Or specify the path with: --specs-dir <path>" )
192202 raise typer .Exit (1 )
193203
194204 if not mdb_specs .exists ():
195- typer .echo (f"❌ Error: Specifications directory not found: { mdb_specs } " , err = True )
205+ typer .echo (
206+ f"❌ Error: Specifications directory not found: { mdb_specs } " , err = True
207+ )
196208 raise typer .Exit (1 )
197209
198210 script = driver_repo ["path" ] / ".evergreen" / "resync-specs.sh"
@@ -223,7 +235,9 @@ def spec_sync(
223235 typer .echo (f" Working directory: { cwd } " )
224236 patch_count = len (_list_patches (_get_patch_dir (driver_repo )))
225237 if patch_count :
226- typer .echo (f"\n 📋 { patch_count } patch(es) would be applied with --apply-patches" )
238+ typer .echo (
239+ f"\n 📋 { patch_count } patch(es) would be applied with --apply-patches"
240+ )
227241 return
228242
229243 spec_label = ", " .join (specs ) if specs else "all"
@@ -248,6 +262,7 @@ def spec_sync(
248262# dbx spec list
249263# ---------------------------------------------------------------------------
250264
265+
251266@app .command ("list" )
252267def spec_list (
253268 ctx : typer .Context ,
@@ -273,13 +288,17 @@ def spec_list(
273288 else :
274289 mdb_specs = _find_specs_dir (config , base_dir )
275290 if not mdb_specs :
276- typer .echo ("❌ Error: Could not find the 'specifications' repository" , err = True )
291+ typer .echo (
292+ "❌ Error: Could not find the 'specifications' repository" , err = True
293+ )
277294 typer .echo ("\n Clone it with: dbx clone specifications" )
278295 typer .echo ("Or specify the path with: --specs-dir <path>" )
279296 raise typer .Exit (1 )
280297
281298 if not mdb_specs .exists ():
282- typer .echo (f"❌ Error: Specifications directory not found: { mdb_specs } " , err = True )
299+ typer .echo (
300+ f"❌ Error: Specifications directory not found: { mdb_specs } " , err = True
301+ )
283302 raise typer .Exit (1 )
284303
285304 source_dir = mdb_specs / "source"
@@ -289,7 +308,9 @@ def spec_list(
289308 typer .echo (f"[verbose] Listing specs in: { search_dir } \n " )
290309
291310 spec_dirs = sorted (
292- d .name for d in search_dir .iterdir () if d .is_dir () and not d .name .startswith ("." )
311+ d .name
312+ for d in search_dir .iterdir ()
313+ if d .is_dir () and not d .name .startswith ("." )
293314 )
294315
295316 if not spec_dirs :
@@ -307,6 +328,7 @@ def spec_list(
307328# dbx spec patch list
308329# ---------------------------------------------------------------------------
309330
331+
310332@patch_app .command ("list" )
311333def patch_list (
312334 ctx : typer .Context ,
@@ -352,6 +374,7 @@ def patch_list(
352374# dbx spec patch create
353375# ---------------------------------------------------------------------------
354376
377+
355378@patch_app .command ("create" )
356379def patch_create (
357380 ctx : typer .Context ,
@@ -425,7 +448,9 @@ def patch_create(
425448 diff = result .stdout
426449 if not diff .strip ():
427450 typer .echo ("❌ No changes to capture (git diff is empty)" , err = True )
428- typer .echo ("\n Make sure you have unstaged changes in the driver repo after syncing." )
451+ typer .echo (
452+ "\n Make sure you have unstaged changes in the driver repo after syncing."
453+ )
429454 raise typer .Exit (1 )
430455
431456 if dry_run :
@@ -447,6 +472,7 @@ def patch_create(
447472# dbx spec patch remove
448473# ---------------------------------------------------------------------------
449474
475+
450476@patch_app .command ("remove" )
451477def patch_remove (
452478 ctx : typer .Context ,
@@ -488,6 +514,7 @@ def patch_remove(
488514# dbx spec patch apply
489515# ---------------------------------------------------------------------------
490516
517+
491518@patch_app .command ("apply" )
492519def patch_apply (
493520 ctx : typer .Context ,
@@ -527,7 +554,9 @@ def patch_apply(
527554 typer .echo (f"No patch files found in { patch_dir } " )
528555 return
529556
530- typer .echo (f"🩹 { 'Would apply' if dry_run else 'Applying' } { len (patches )} patch(es) to { repo_name } :" )
557+ typer .echo (
558+ f"🩹 { 'Would apply' if dry_run else 'Applying' } { len (patches )} patch(es) to { repo_name } :"
559+ )
531560 for p in patches :
532561 files = _parse_patch_files (p )
533562 typer .echo (f" • { p .stem } ({ len (files )} file(s))" )
0 commit comments