@@ -2406,35 +2406,36 @@ def _parse_percentile(name: str, raw: str) -> float:
24062406 "force" : os .environ .get ("GRAPHIFY_FORCE" , "" ).lower ()
24072407 in ("1" , "true" , "yes" ),
24082408 }
2409- # option -> (destination, action, converter, allow_equals)
2409+ # option -> (destination, action, converter, allow_equals, allow_empty )
24102410 option_specs = {
2411- "--backend" : ("backend" , "store" , None , True ),
2412- "--model" : ("model" , "store" , None , True ),
2413- "--mode" : ("extract_mode" , "store" , None , True ),
2414- "--out" : ("out_dir" , "store" , lambda _n , raw : Path (raw ), True ),
2415- "--no-cluster" : ("no_cluster" , "flag" , None , False ),
2416- "--dedup-llm" : ("dedup_llm" , "flag" , None , False ),
2417- "--code-only" : ("code_only" , "flag" , None , False ),
2418- "--google-workspace" : ("google_workspace" , "flag" , None , False ),
2419- "--no-gitignore" : ("no_gitignore" , "flag" , None , False ),
2420- "--global" : ("global_merge" , "flag" , None , False ),
2421- "--as" : ("global_repo_tag" , "store" , None , False ),
2422- "--max-workers" : ("cli_max_workers" , "store" , _parse_int , True ),
2423- "--token-budget" : ("cli_token_budget" , "store" , _parse_int , True ),
2411+ "--backend" : ("backend" , "store" , None , True , False ),
2412+ "--model" : ("model" , "store" , None , True , False ),
2413+ "--mode" : ("extract_mode" , "store" , None , True , False ),
2414+ "--out" : ("out_dir" , "store" , lambda _n , raw : Path (raw ), True , False ),
2415+ "--no-cluster" : ("no_cluster" , "flag" , None , False , False ),
2416+ "--dedup-llm" : ("dedup_llm" , "flag" , None , False , False ),
2417+ "--code-only" : ("code_only" , "flag" , None , False , False ),
2418+ "--google-workspace" : ("google_workspace" , "flag" , None , False , False ),
2419+ "--no-gitignore" : ("no_gitignore" , "flag" , None , False , False ),
2420+ "--global" : ("global_merge" , "flag" , None , False , False ),
2421+ "--as" : ("global_repo_tag" , "store" , None , False , False ),
2422+ "--max-workers" : ("cli_max_workers" , "store" , _parse_int , True , False ),
2423+ "--token-budget" : ("cli_token_budget" , "store" , _parse_int , True , False ),
24242424 "--max-concurrency" : (
2425- "cli_max_concurrency" , "store" , _parse_int , True
2425+ "cli_max_concurrency" , "store" , _parse_int , True , False
24262426 ),
2427- "--api-timeout" : ("cli_api_timeout" , "store" , _parse_float , True ),
2428- "--resolution" : ("cli_resolution" , "store" , _parse_float , True ),
2427+ "--api-timeout" : ("cli_api_timeout" , "store" , _parse_float , True , False ),
2428+ "--resolution" : ("cli_resolution" , "store" , _parse_float , True , False ),
24292429 "--exclude-hubs" : (
2430- "cli_exclude_hubs" , "store" , _parse_percentile , True
2430+ "cli_exclude_hubs" , "store" , _parse_percentile , True , False
24312431 ),
2432- "--exclude" : ("cli_excludes" , "append" , None , True ),
2433- "--postgres" : ("cli_postgres_dsn" , "store" , None , True ),
2434- "--cargo" : ("cli_cargo" , "flag" , None , False ),
2435- "--force" : ("force" , "flag" , None , False ),
2436- "--allow-partial" : ("cli_allow_partial" , "flag" , None , False ),
2437- "--timing" : ("cli_timing" , "flag" , None , False ),
2432+ "--exclude" : ("cli_excludes" , "append" , None , True , False ),
2433+ # Empty DSN intentionally lets psycopg use PG* environment variables.
2434+ "--postgres" : ("cli_postgres_dsn" , "store" , None , True , True ),
2435+ "--cargo" : ("cli_cargo" , "flag" , None , False , False ),
2436+ "--force" : ("force" , "flag" , None , False , False ),
2437+ "--allow-partial" : ("cli_allow_partial" , "flag" , None , False , False ),
2438+ "--timing" : ("cli_timing" , "flag" , None , False , False ),
24382439 }
24392440
24402441 i = 0
@@ -2449,7 +2450,7 @@ def _parse_percentile(name: str, raw: str) -> float:
24492450 print ("error: unexpected extract positional argument" , file = sys .stderr )
24502451 sys .exit (2 )
24512452
2452- destination , action , converter , allow_equals = spec
2453+ destination , action , converter , allow_equals , allow_empty = spec
24532454 if action == "flag" :
24542455 if equals :
24552456 print (f"error: { name } does not take a value" , file = sys .stderr )
@@ -2466,15 +2467,15 @@ def _parse_percentile(name: str, raw: str) -> float:
24662467 else :
24672468 if (
24682469 i + 1 >= len (args )
2469- or not args [i + 1 ]
2470+ or ( not args [i + 1 ] and not allow_empty )
24702471 or args [i + 1 ].startswith ("--" )
24712472 ):
24722473 print (f"error: { name } requires a value" , file = sys .stderr )
24732474 sys .exit (2 )
24742475 raw_value = args [i + 1 ]
24752476 i += 1
24762477
2477- if not raw_value :
2478+ if not raw_value and not allow_empty :
24782479 print (f"error: { name } requires a value" , file = sys .stderr )
24792480 sys .exit (2 )
24802481 value = converter (name , raw_value ) if converter else raw_value
0 commit comments