@@ -62,12 +62,12 @@ export const getCloudData = async (
6262
6363export const getServersData = async ( {
6464 client,
65- v ,
65+ verbosity ,
6666} : {
6767 client : ApolloClient < NormalizedCacheObject > ;
68- v : number ;
68+ verbosity : number ;
6969} ) : Promise < ServersPayload | null > => {
70- if ( v === 0 ) {
70+ if ( verbosity === 0 ) {
7171 return null ;
7272 }
7373
@@ -201,6 +201,12 @@ export class ReportCommand extends CommandRunner {
201201 super ( ) ;
202202 }
203203
204+ private defaultOptions : ReportOptions = {
205+ raw : false ,
206+ json : false ,
207+ verbose : 0 ,
208+ } ;
209+
204210 @Option ( {
205211 flags : '-r, --raw' ,
206212 description : 'whether to enable raw command output' ,
@@ -236,7 +242,7 @@ export class ReportCommand extends CommandRunner {
236242 }
237243 }
238244
239- async report ( options ? : ReportOptions ) : Promise < string | ReportObject | void > {
245+ async report ( options : ReportOptions = this . defaultOptions ) : Promise < string | ReportObject | void > {
240246 // Check if we have a tty attached to stdout
241247 // If we don't then this is being piped to a log file, etc.
242248 const hasTty = process . stdout . isTTY ;
@@ -245,7 +251,7 @@ export class ReportCommand extends CommandRunner {
245251 // If this has a tty it's interactive
246252 // AND
247253 // If they don't have --raw
248- const isInteractive = hasTty && ! options ? .raw ;
254+ const isInteractive = hasTty && ! options . raw ;
249255
250256 try {
251257 // Show loading message
@@ -254,7 +260,6 @@ export class ReportCommand extends CommandRunner {
254260 }
255261
256262 const jsonReport = options ?. json ?? false ;
257- const v = options ?. verbose ?? 0 ;
258263
259264 // Find all processes called "unraid-api" which aren't this process
260265 const unraidApiRunning = await isUnraidApiRunning ( ) ;
@@ -282,7 +287,7 @@ export class ReportCommand extends CommandRunner {
282287
283288 // Query local graphql using upc's API key
284289 // Get the servers array
285- const servers = await getServersData ( { client, v } ) ;
290+ const servers = await getServersData ( { client, verbosity : options . verbose } ) ;
286291
287292 // Check if the API key is valid
288293 const isApiKeyValid = cloud ?. apiKey . valid ?? false ;
@@ -322,8 +327,8 @@ export class ReportCommand extends CommandRunner {
322327 status : cloud ?. cloud . status ?? 'error' ,
323328 ...( cloud ?. cloud . error ? { error : cloud . cloud . error } : { } ) ,
324329 ...( cloud ?. cloud . status === 'ok' ? { ip : cloud . cloud . ip ?? 'NO_IP' } : { } ) ,
325- ...( getAllowedOrigins ( cloud , v )
326- ? { allowedOrigins : getAllowedOrigins ( cloud , v ) }
330+ ...( getAllowedOrigins ( cloud , options . verbose )
331+ ? { allowedOrigins : getAllowedOrigins ( cloud , options . verbose ) }
327332 : { } ) ,
328333 } ,
329334 } ;
@@ -347,10 +352,10 @@ MY_SERVERS: ${reportObject.myServers.status}${
347352 ? `\nMY_SERVERS_USERNAME: ${ reportObject . myServers . myServersUsername } `
348353 : ''
349354 }
350- CLOUD: ${ getReadableCloudDetails ( reportObject , v ) }
355+ CLOUD: ${ getReadableCloudDetails ( reportObject , options . verbose ) }
351356MINI-GRAPH: ${ getReadableMinigraphDetails ( reportObject ) } ${ getReadableServerDetails (
352357 reportObject ,
353- v
358+ options . verbose
354359 ) } ${ getReadableAllowedOrigins ( reportObject ) }
355360</----UNRAID-API-REPORT----->
356361` ;
0 commit comments