@@ -40,13 +40,35 @@ export function parseArgs(argv: string[]): ParsedArgs {
4040 for ( let i = 0 ; i < argv . length ; i ++ ) {
4141 const a = argv [ i ] ;
4242 if ( a === "--env" ) {
43- envRaw = argv [ ++ i ] ;
43+ const v = argv [ ++ i ] ;
44+ // Guard a bare trailing `--env` (undefined) here so the
45+ // operator gets a precise, flag-named diagnostic instead of
46+ // the downstream `resolveEnv` "Unknown env" / "--env required"
47+ // surface. Mirrors the same guard on `--services`.
48+ if ( v === undefined ) {
49+ throw new Error ( "--env requires a value (staging|prod)" ) ;
50+ }
51+ envRaw = v ;
4452 } else if ( a . startsWith ( "--env=" ) ) {
45- envRaw = a . slice ( "--env=" . length ) ;
53+ const v = a . slice ( "--env=" . length ) ;
54+ // `--env=` (empty post-equals) is the equals-form twin of the
55+ // bare-trailing case above; collapse both to the same precise
56+ // error rather than deferring to `resolveEnv`.
57+ if ( v === "" ) {
58+ throw new Error ( "--env requires a value (staging|prod)" ) ;
59+ }
60+ envRaw = v ;
4661 } else if ( a === "--services" ) {
4762 const v = argv [ ++ i ] ;
4863 if ( ! v ) throw new Error ( "--services requires a CSV value" ) ;
4964 services = v . split ( "," ) . map ( ( s ) => s . trim ( ) ) . filter ( Boolean ) ;
65+ // Symmetry with the equals-form below: a raw value like `,,`
66+ // or `" "` survives the `!v` guard but produces an empty
67+ // post-filter list. Throw the same precise error here so both
68+ // forms behave identically.
69+ if ( services . length === 0 ) {
70+ throw new Error ( "--services requires a CSV value" ) ;
71+ }
5072 } else if ( a . startsWith ( "--services=" ) ) {
5173 const v = a . slice ( "--services=" . length ) ;
5274 if ( ! v ) throw new Error ( "--services requires a CSV value" ) ;
0 commit comments