@@ -3,6 +3,7 @@ import { parse as dotEnvParse } from "@std/dotenv";
33import { getAppFromConfig , readConfig } from "./config.ts" ;
44import { error , withApp } from "./util.ts" ;
55import { createTrpcClient } from "./auth.ts" ;
6+ import type { GlobalOptions } from "./main.ts" ;
67
78interface EnvVar {
89 id : string ;
@@ -16,8 +17,7 @@ interface Context {
1617 name : string ;
1718}
1819
19- type EnvCommandContext = {
20- endpoint : string ;
20+ type EnvCommandContext = GlobalOptions & {
2121 org ?: string ;
2222 app ?: string ;
2323} ;
@@ -30,8 +30,14 @@ export const envListCommand = new Command<EnvCommandContext>()
3030 org ??= options . org ;
3131 app ??= options . app ;
3232
33- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
34- const trpcClient = createTrpcClient ( options . endpoint ) ;
33+ const orgAndApp = await withApp (
34+ options . debug ,
35+ options . endpoint ,
36+ false ,
37+ org ,
38+ app ,
39+ ) ;
40+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
3541
3642 // deno-lint-ignore no-explicit-any
3743 const envVars : EnvVar [ ] = await ( trpcClient . envVarsContexts as any ) . list
@@ -111,8 +117,14 @@ export const envAddCommand = new Command<EnvCommandContext>()
111117 org ??= options . org ;
112118 app ??= options . app ;
113119
114- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
115- const trpcClient = createTrpcClient ( options . endpoint ) ;
120+ const orgAndApp = await withApp (
121+ options . debug ,
122+ options . endpoint ,
123+ false ,
124+ org ,
125+ app ,
126+ ) ;
127+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
116128
117129 // deno-lint-ignore no-explicit-any
118130 const fullApp = await ( trpcClient . apps as any ) . get . query ( {
@@ -152,8 +164,14 @@ export const envUpdateValueCommand = new Command<EnvCommandContext>()
152164 org ??= options . org ;
153165 app ??= options . app ;
154166
155- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
156- const trpcClient = createTrpcClient ( options . endpoint ) ;
167+ const orgAndApp = await withApp (
168+ options . debug ,
169+ options . endpoint ,
170+ false ,
171+ org ,
172+ app ,
173+ ) ;
174+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
157175
158176 // deno-lint-ignore no-explicit-any
159177 const envVars : EnvVar [ ] = await ( trpcClient . envVarsContexts as any ) . list
@@ -165,7 +183,7 @@ export const envUpdateValueCommand = new Command<EnvCommandContext>()
165183 const envVar = envVars . find ( ( envVar ) => envVar . key === variable ) ;
166184
167185 if ( ! envVar ) {
168- error ( `Environment variable '${ variable } ' not found` ) ;
186+ error ( options . debug , `Environment variable '${ variable } ' not found` ) ;
169187 }
170188
171189 // deno-lint-ignore no-explicit-any
@@ -196,8 +214,14 @@ You can define no contexts, which is the equivalent to "All"`,
196214 org ??= options . org ;
197215 app ??= options . app ;
198216
199- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
200- const trpcClient = createTrpcClient ( options . endpoint ) ;
217+ const orgAndApp = await withApp (
218+ options . debug ,
219+ options . endpoint ,
220+ false ,
221+ org ,
222+ app ,
223+ ) ;
224+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
201225
202226 // deno-lint-ignore no-explicit-any
203227 const envVars : EnvVar [ ] = await ( trpcClient . envVarsContexts as any ) . list
@@ -209,7 +233,7 @@ You can define no contexts, which is the equivalent to "All"`,
209233 const envVar = envVars . find ( ( envVar ) => envVar . key === variable ) ;
210234
211235 if ( ! envVar ) {
212- error ( `Environment variable '${ variable } ' not found` ) ;
236+ error ( options . debug , `Environment variable '${ variable } ' not found` ) ;
213237 }
214238
215239 // deno-lint-ignore no-explicit-any
@@ -224,7 +248,7 @@ You can define no contexts, which is the equivalent to "All"`,
224248 for ( const newContext of newContexts ) {
225249 const context = contexts . find ( ( context ) => context . name === newContext ) ;
226250 if ( ! context ) {
227- error ( `Context "${ newContext } " not found` ) ;
251+ error ( options . debug , `Context "${ newContext } " not found` ) ;
228252 }
229253
230254 contextIds . push ( context . id ) ;
@@ -255,8 +279,14 @@ export const envDeleteCommand = new Command<EnvCommandContext>()
255279 org ??= options . org ;
256280 app ??= options . app ;
257281
258- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
259- const trpcClient = createTrpcClient ( options . endpoint ) ;
282+ const orgAndApp = await withApp (
283+ options . debug ,
284+ options . endpoint ,
285+ false ,
286+ org ,
287+ app ,
288+ ) ;
289+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
260290
261291 // deno-lint-ignore no-explicit-any
262292 const envVars : EnvVar [ ] = await ( trpcClient . envVarsContexts as any ) . list
@@ -299,8 +329,14 @@ export const envLoadCommand = new Command<EnvCommandContext>()
299329 org ??= options . org ;
300330 app ??= options . app ;
301331
302- const orgAndApp = await withApp ( options . endpoint , false , org , app ) ;
303- const trpcClient = createTrpcClient ( options . endpoint ) ;
332+ const orgAndApp = await withApp (
333+ options . debug ,
334+ options . endpoint ,
335+ false ,
336+ org ,
337+ app ,
338+ ) ;
339+ const trpcClient = createTrpcClient ( options . debug , options . endpoint ) ;
304340
305341 // deno-lint-ignore no-explicit-any
306342 const fullApp = await ( trpcClient . apps as any ) . get . query ( {
0 commit comments