File tree Expand file tree Collapse file tree 3 files changed +13
-0
lines changed
Expand file tree Collapse file tree 3 files changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -115,8 +115,14 @@ async function cli(args: ParsedArgs) {
115115
116116 const commandParams : Record < string , any > = { }
117117
118+ /**
119+ * Whether or not to auto-select first option
120+ */
121+ const is_interactive = args . y !== true
122+
118123 const ctx : ContextHelpers = {
119124 api,
125+ is_interactive,
120126 }
121127
122128 for ( const k in args ) {
Original file line number Diff line number Diff line change @@ -46,6 +46,12 @@ export const interactForOpenApiObject = async (
4646
4747 const haveAllRequiredParams = required . every ( ( k ) => args . params [ k ] )
4848
49+ const should_auto_submit =
50+ ! ctx . is_interactive && haveAllRequiredParams && ! args . isSubProperty
51+ if ( should_auto_submit ) {
52+ return args . params
53+ }
54+
4955 const propSortScore = ( prop : string ) => {
5056 if ( required . includes ( prop ) ) return 100 - ergonomicPropOrder . indexOf ( prop )
5157 if ( args . params [ prop ] !== undefined )
Original file line number Diff line number Diff line change @@ -2,4 +2,5 @@ import { ApiDefinitions } from "./get-api-definitions"
22
33export interface ContextHelpers {
44 api : ApiDefinitions
5+ is_interactive : boolean
56}
You can’t perform that action at this time.
0 commit comments