5252import ssl
5353import truststore
5454
55+
5556ssl_context = truststore .SSLContext (ssl .PROTOCOL_TLS_CLIENT )
5657client = httpx .Client (verify = ssl_context )
5758
59+
60+ if __package__ is None :
61+ # hardcode the version for local development
62+ __package__ = "specify_cli"
63+ __version__ = "0.0.0"
64+ else :
65+ # get the version from the metadata
66+ import importlib .metadata
67+ try :
68+ __version__ = importlib .metadata .version (__package__ )
69+ except importlib .metadata .PackageNotFoundError :
70+ __version__ = "0.0.0"
71+
72+
5873def _github_token (cli_token : str | None = None ) -> str | None :
5974 """Return sanitized GitHub token (cli arg takes precedence) or None."""
6075 return ((cli_token or os .getenv ("GH_TOKEN" ) or os .getenv ("GITHUB_TOKEN" ) or "" ).strip ()) or None
@@ -64,6 +79,7 @@ def _github_auth_headers(cli_token: str | None = None) -> dict:
6479 token = _github_token (cli_token )
6580 return {"Authorization" : f"Bearer { token } " } if token else {}
6681
82+
6783# Agent configuration with name, folder, install URL, and CLI tool requirement
6884AGENT_CONFIG = {
6985 "copilot" : {
@@ -373,9 +389,22 @@ def show_banner():
373389 console .print (Align .center (Text (TAGLINE , style = "italic bright_yellow" )))
374390 console .print ()
375391
392+ def show_version ():
393+ """Show the application version."""
394+ typer .echo (f"{ __package__ } { __version__ } " )
395+
376396@app .callback ()
377- def callback (ctx : typer .Context ):
397+ def callback (
398+ ctx : typer .Context ,
399+ version : bool = typer .Option (
400+ None , "--version" , help = "Show version and exit." , is_eager = True
401+ ),
402+ ):
378403 """Show banner when no subcommand is provided."""
404+ if version :
405+ show_version ()
406+ raise typer .Exit ()
407+
379408 if ctx .invoked_subcommand is None and "--help" not in sys .argv and "-h" not in sys .argv :
380409 show_banner ()
381410 console .print (Align .center ("[dim]Run 'specify --help' for usage information[/dim]" ))
@@ -1118,6 +1147,11 @@ def check():
11181147 if not any (agent_results .values ()):
11191148 console .print ("[dim]Tip: Install an AI assistant for the best experience[/dim]" )
11201149
1150+ @app .command ()
1151+ def version ():
1152+ """Show the application version."""
1153+ show_version ()
1154+
11211155def main ():
11221156 app ()
11231157
0 commit comments