File tree Expand file tree Collapse file tree
server/typescript/packages/cli Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -100,6 +100,33 @@ export function parseVerifyArgs(argv: string[]): VerifyFlags {
100100 } ;
101101}
102102
103+ // ---------------------------------------------------------------------------
104+ // prompt-snapshot flags
105+ // ---------------------------------------------------------------------------
106+
107+ export interface PromptSnapshotFlags {
108+ /** Compare against committed snapshots and fail on drift; never write. */
109+ check : boolean ;
110+ /** Directory (relative to cwd) holding provider-resolved template text. */
111+ prompts : string | undefined ;
112+ }
113+
114+ export function parsePromptSnapshotArgs ( argv : string [ ] ) : PromptSnapshotFlags {
115+ const { values } = parseArgs ( {
116+ args : argv ,
117+ options : {
118+ check : { type : "boolean" , default : false } ,
119+ prompts : { type : "string" } ,
120+ } ,
121+ strict : true ,
122+ allowPositionals : false ,
123+ } ) ;
124+ return {
125+ check : ! ! values . check ,
126+ prompts : values . prompts ,
127+ } ;
128+ }
129+
103130// ---------------------------------------------------------------------------
104131// migrate flags
105132// ---------------------------------------------------------------------------
Original file line number Diff line number Diff line change 1+ import { describe , test , expect } from "bun:test" ;
2+ import { parsePromptSnapshotArgs } from "../../src/lib/args.js" ;
3+
4+ describe ( "parsePromptSnapshotArgs" , ( ) => {
5+ test ( "defaults: check false, prompts undefined" , ( ) => {
6+ expect ( parsePromptSnapshotArgs ( [ ] ) ) . toEqual ( { check : false , prompts : undefined } ) ;
7+ } ) ;
8+ test ( "--check sets check true" , ( ) => {
9+ expect ( parsePromptSnapshotArgs ( [ "--check" ] ) ) . toEqual ( { check : true , prompts : undefined } ) ;
10+ } ) ;
11+ test ( "--prompts <dir> is captured" , ( ) => {
12+ expect ( parsePromptSnapshotArgs ( [ "--prompts" , "templates" ] ) ) . toEqual ( {
13+ check : false ,
14+ prompts : "templates" ,
15+ } ) ;
16+ } ) ;
17+ test ( "throws on an unknown flag" , ( ) => {
18+ expect ( ( ) => parsePromptSnapshotArgs ( [ "--bogus" ] ) ) . toThrow ( ) ;
19+ } ) ;
20+ test ( "throws on a positional argument" , ( ) => {
21+ expect ( ( ) => parsePromptSnapshotArgs ( [ "extra" ] ) ) . toThrow ( ) ;
22+ } ) ;
23+ } ) ;
You can’t perform that action at this time.
0 commit comments