33"""
44
55from pathlib import Path
6- from typing import Optional
76
87import typer
98from rich .table import Table
109
1110from conserver .console import console , print_error , print_success , print_warning
1211from conserver .docker_ops import DockerOps
13- from conserver .exceptions import ConserverError , ImageError
12+ from conserver .exceptions import ConserverError
1413from conserver .image_registry import ImageRegistry
1514
1615# Create images subcommand app
@@ -26,9 +25,7 @@ def list_images(
2625 False , "--remote" , "-r" , help = "List available tags from remote registry"
2726 ),
2827 limit : int = typer .Option (20 , "--limit" , help = "Maximum number of tags to show" ),
29- registry : str = typer .Option (
30- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
31- ),
28+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
3229) -> None :
3330 """List available vcon-server images."""
3431 try :
@@ -64,9 +61,7 @@ def list_images(
6461
6562 if not images :
6663 print_warning ("No local images found" )
67- console .print (
68- "[dim]Use 'conserver images pull <tag>' to download an image[/dim]"
69- )
64+ console .print ("[dim]Use 'conserver images pull <tag>' to download an image[/dim]" )
7065 return
7166
7267 table = Table (title = "Local Images" )
@@ -93,9 +88,7 @@ def list_images(
9388@app .command ("pull" )
9489def pull_image (
9590 tag : str = typer .Argument ("main" , help = "Image tag to pull (e.g., 'main', 'v1.0.0')" ),
96- registry : str = typer .Option (
97- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
98- ),
91+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
9992) -> None :
10093 """Pull a vcon-server image from the registry."""
10194 try :
@@ -123,10 +116,8 @@ def use_image(
123116 restart : bool = typer .Option (
124117 False , "--restart" , "-r" , help = "Restart containers after switching"
125118 ),
126- registry : str = typer .Option (
127- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
128- ),
129- server_path : Optional [Path ] = typer .Option (
119+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
120+ server_path : Path | None = typer .Option (
130121 None , "--server-path" , help = "Path to vcon-server installation"
131122 ),
132123) -> None :
@@ -182,9 +173,7 @@ def use_image(
182173 print_success (f"Updated .env to use { registry } :{ tag } " )
183174 else :
184175 # Create .env file with the image settings
185- env_path .write_text (
186- f"VCON_SERVER_IMAGE={ registry } \n VCON_SERVER_TAG={ tag } \n "
187- )
176+ env_path .write_text (f"VCON_SERVER_IMAGE={ registry } \n VCON_SERVER_TAG={ tag } \n " )
188177 print_success (f"Created .env with { registry } :{ tag } " )
189178
190179 if was_running and restart :
@@ -204,16 +193,14 @@ def use_image(
204193
205194@app .command ("upgrade" )
206195def upgrade_image (
207- to_tag : Optional [ str ] = typer .Argument (
196+ to_tag : str | None = typer .Argument (
208197 None , help = "Specific version to upgrade to (defaults to latest)"
209198 ),
210199 restart : bool = typer .Option (
211200 True , "--restart/--no-restart" , help = "Restart containers after upgrade"
212201 ),
213- registry : str = typer .Option (
214- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
215- ),
216- server_path : Optional [Path ] = typer .Option (
202+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
203+ server_path : Path | None = typer .Option (
217204 None , "--server-path" , help = "Path to vcon-server installation"
218205 ),
219206) -> None :
@@ -256,7 +243,9 @@ def upgrade_image(
256243 print_warning (
257244 f"Target version { target_tag } is not newer than current { current_tag } "
258245 )
259- console .print ("[dim]Use 'conserver images downgrade' to switch to an older version[/dim]" )
246+ console .print (
247+ "[dim]Use 'conserver images downgrade' to switch to an older version[/dim]"
248+ )
260249 return
261250
262251 console .print (f"\n [bold]Upgrading to { target_tag } ...[/bold]" )
@@ -313,13 +302,9 @@ def downgrade_image(
313302 restart : bool = typer .Option (
314303 True , "--restart/--no-restart" , help = "Restart containers after downgrade"
315304 ),
316- force : bool = typer .Option (
317- False , "--force" , "-f" , help = "Skip confirmation prompt"
318- ),
319- registry : str = typer .Option (
320- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
321- ),
322- server_path : Optional [Path ] = typer .Option (
305+ force : bool = typer .Option (False , "--force" , "-f" , help = "Skip confirmation prompt" ),
306+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
307+ server_path : Path | None = typer .Option (
323308 None , "--server-path" , help = "Path to vcon-server installation"
324309 ),
325310) -> None :
@@ -335,12 +320,12 @@ def downgrade_image(
335320 # Warn if downgrading
336321 if image_registry .compare_versions (to_tag , current_tag ) >= 0 :
337322 print_warning (f"{ to_tag } is not older than { current_tag } " )
338- console .print ("[dim]Use 'conserver images upgrade' to switch to a newer version[/dim]" )
323+ console .print (
324+ "[dim]Use 'conserver images upgrade' to switch to a newer version[/dim]"
325+ )
339326
340327 if not force :
341- console .print (
342- f"\n [yellow]Warning: Downgrading may cause compatibility issues.[/yellow]"
343- )
328+ console .print ("\n [yellow]Warning: Downgrading may cause compatibility issues.[/yellow]" )
344329 if not typer .confirm (f"Downgrade to { to_tag } ?" ):
345330 console .print ("[dim]Cancelled[/dim]" )
346331 raise typer .Exit (0 )
@@ -396,9 +381,7 @@ def downgrade_image(
396381def remove_image (
397382 tag : str = typer .Argument (..., help = "Image tag to remove" ),
398383 force : bool = typer .Option (False , "--force" , "-f" , help = "Force removal" ),
399- registry : str = typer .Option (
400- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
401- ),
384+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
402385) -> None :
403386 """Remove a local vcon-server image."""
404387 try :
@@ -425,9 +408,7 @@ def remove_image(
425408@app .command ("info" )
426409def image_info (
427410 tag : str = typer .Argument ("main" , help = "Image tag to inspect" ),
428- registry : str = typer .Option (
429- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
430- ),
411+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
431412) -> None :
432413 """Show detailed information about an image."""
433414 try :
@@ -491,9 +472,7 @@ def image_info(
491472def prune_images (
492473 keep : int = typer .Option (3 , "--keep" , "-k" , help = "Number of recent images to keep" ),
493474 force : bool = typer .Option (False , "--force" , "-f" , help = "Skip confirmation" ),
494- registry : str = typer .Option (
495- DEFAULT_REGISTRY , "--registry" , help = "Container registry URL"
496- ),
475+ registry : str = typer .Option (DEFAULT_REGISTRY , "--registry" , help = "Container registry URL" ),
497476) -> None :
498477 """Remove old local images, keeping only the most recent ones."""
499478 try :
@@ -508,7 +487,9 @@ def prune_images(
508487 to_remove = images [keep :]
509488
510489 console .print (f"[bold]Found { len (images )} local images[/bold]" )
511- console .print (f"[yellow]Will remove { len (to_remove )} images, keeping { keep } most recent[/yellow]" )
490+ console .print (
491+ f"[yellow]Will remove { len (to_remove )} images, keeping { keep } most recent[/yellow]"
492+ )
512493
513494 if not force :
514495 console .print ("\n [bold]Images to remove:[/bold]" )
0 commit comments