File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -469,28 +469,28 @@ blueprint
469469 . option ( "--user <user:uid>" , "Run as this user (format: username:uid)" )
470470 . option (
471471 "-o, --output [format]" ,
472- "Output format: text|json|yaml (default: text )" ,
472+ "Output format: text|json|yaml (default: json )" ,
473473 )
474474 . action ( async ( options ) => {
475475 const { createBlueprint } = await import ( "./commands/blueprint/create.js" ) ;
476476 await createBlueprint ( options ) ;
477477 } ) ;
478478
479479blueprint
480- . command ( "get <id>" )
481- . description ( "Get blueprint details" )
480+ . command ( "get <name-or- id>" )
481+ . description ( "Get blueprint details by name or ID (IDs start with bpt_) " )
482482 . option (
483483 "-o, --output [format]" ,
484- "Output format: text|json|yaml (default: text )" ,
484+ "Output format: text|json|yaml (default: json )" ,
485485 )
486486 . action ( async ( id , options ) => {
487487 const { getBlueprint } = await import ( "./commands/blueprint/get.js" ) ;
488488 await getBlueprint ( { id, ...options } ) ;
489489 } ) ;
490490
491491blueprint
492- . command ( "logs <id>" )
493- . description ( "Get blueprint build logs" )
492+ . command ( "logs <name-or- id>" )
493+ . description ( "Get blueprint build logs by name or ID (IDs start with bpt_) " )
494494 . option (
495495 "-o, --output [format]" ,
496496 "Output format: text|json|yaml (default: text)" ,
Original file line number Diff line number Diff line change @@ -65,12 +65,8 @@ export async function createBlueprint(options: CreateBlueprintOptions) {
6565 launch_parameters : launchParameters as Parameters < typeof client . blueprints . create > [ 0 ] [ "launch_parameters" ] ,
6666 } ) ;
6767
68- // Default: just output the ID for easy scripting
69- if ( ! options . output || options . output === "text" ) {
70- console . log ( blueprint . id ) ;
71- } else {
72- output ( blueprint , { format : options . output , defaultFormat : "json" } ) ;
73- }
68+ // Default: output JSON
69+ output ( blueprint , { format : options . output , defaultFormat : "json" } ) ;
7470 } catch ( error ) {
7571 outputError ( "Failed to create blueprint" , error ) ;
7672 }
Original file line number Diff line number Diff line change @@ -13,7 +13,28 @@ interface GetBlueprintOptions {
1313export async function getBlueprint ( options : GetBlueprintOptions ) {
1414 try {
1515 const client = getClient ( ) ;
16- const blueprint = await client . blueprints . retrieve ( options . id ) ;
16+
17+ let blueprint ;
18+
19+ // Check if it's an ID (starts with bpt_) or a name
20+ if ( options . id . startsWith ( "bpt_" ) ) {
21+ // It's an ID, retrieve directly
22+ blueprint = await client . blueprints . retrieve ( options . id ) ;
23+ } else {
24+ // It's a name, search for it
25+ const result = await client . blueprints . list ( { name : options . id } ) ;
26+ const blueprints = result . blueprints || [ ] ;
27+
28+ if ( blueprints . length === 0 ) {
29+ outputError ( `Blueprint not found: ${ options . id } ` ) ;
30+ return ;
31+ }
32+
33+ // Return the first exact match, or first result if no exact match
34+ blueprint =
35+ blueprints . find ( ( b ) => b . name === options . id ) || blueprints [ 0 ] ;
36+ }
37+
1738 output ( blueprint , { format : options . output , defaultFormat : "json" } ) ;
1839 } catch ( error ) {
1940 outputError ( "Failed to get blueprint" , error ) ;
Original file line number Diff line number Diff line change @@ -134,7 +134,27 @@ function formatLogs(response: BlueprintBuildLogsListView): void {
134134export async function getBlueprintLogs ( options : BlueprintLogsOptions ) {
135135 try {
136136 const client = getClient ( ) ;
137- const logs = await client . blueprints . logs ( options . id ) ;
137+
138+ let blueprintId = options . id ;
139+
140+ // Check if it's an ID (starts with bpt_) or a name
141+ if ( ! options . id . startsWith ( "bpt_" ) ) {
142+ // It's a name, search for it
143+ const result = await client . blueprints . list ( { name : options . id } ) ;
144+ const blueprints = result . blueprints || [ ] ;
145+
146+ if ( blueprints . length === 0 ) {
147+ outputError ( `Blueprint not found: ${ options . id } ` ) ;
148+ return ;
149+ }
150+
151+ // Use the first exact match, or first result if no exact match
152+ const blueprint =
153+ blueprints . find ( ( b ) => b . name === options . id ) || blueprints [ 0 ] ;
154+ blueprintId = blueprint . id ;
155+ }
156+
157+ const logs = await client . blueprints . logs ( blueprintId ) ;
138158
139159 // Pretty print for text output, JSON for others
140160 if ( ! options . output || options . output === "text" ) {
You can’t perform that action at this time.
0 commit comments