Skip to content

Commit 8cec2e1

Browse files
committed
🚸 Add message to display report and output options
1 parent 5fd1f0e commit 8cec2e1

1 file changed

Lines changed: 53 additions & 1 deletion

File tree

‎cli.js‎

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,54 @@ const cli = meow(createHelpText(), {
198198
flags: CLI_FLAGS,
199199
})
200200

201+
/**
202+
* Displays a structured status message showing what the CLI is scanning for and what options are enabled.
203+
* @param {object} flags - The CLI flags object containing all user options
204+
* @param {string} targetName - The name of the target (enterprise, owner, or repository)
205+
* @param {string} [hostName] - Optional hostname for GitHub Enterprise Server
206+
*/
207+
const displayAnalysisSummary = (flags, targetName, hostName) => {
208+
// Check if any report options are enabled
209+
const {all, listeners, permissions, runsOn, secrets, vars, uses, exclude, unique, archived, forked} = flags
210+
211+
// Create readable list of enabled report types
212+
const enabledReportTypes = []
213+
if (all || listeners) enabledReportTypes.push('listeners')
214+
if (all || permissions) enabledReportTypes.push('permissions')
215+
if (all || runsOn) enabledReportTypes.push('runs-on')
216+
if (all || secrets) enabledReportTypes.push('secrets')
217+
if (all || vars) enabledReportTypes.push('vars')
218+
if (all || uses) enabledReportTypes.push('uses')
219+
220+
// Create readable list of options
221+
const options = []
222+
if (all || uses) {
223+
if (exclude) options.push('excluding actions created by GitHub')
224+
const uniqueValue = all ? 'both' : unique
225+
if (uniqueValue !== 'false') options.push(`unique report=${uniqueValue}`)
226+
}
227+
// Show repository filter information
228+
if (archived) options.push('skip archived repos')
229+
if (forked) options.push('skip forked repos')
230+
231+
// Create readable list of output formats
232+
const outputs = []
233+
if (flags.csv) outputs.push('csv')
234+
if (flags.json) outputs.push('json')
235+
if (flags.md) outputs.push('markdown')
236+
237+
// Build the structured message
238+
console.log(
239+
`Analyzing GitHub Actions in ${blue(targetName)}${hostName ? ` on ${blue(hostName)}` : ''}:
240+
${yellow('→')} scanning:\t${enabledReportTypes.map(type => yellow(type)).join(', ')}
241+
${yellow('→')} options:\t${options.length > 0 ? options.map(opt => yellow(opt)).join(', ') : 'none'}
242+
${yellow('→')} outputs:\t${outputs.length > 0 ? outputs.map(output => yellow(output)).join(', ') : 'none'}
243+
244+
${dim('This can take a while...')}
245+
`,
246+
)
247+
}
248+
201249
/**
202250
* Main execution function that orchestrates the CLI application.
203251
* Handles input validation, option processing, and delegates to appropriate processing functions.
@@ -208,7 +256,7 @@ const cli = meow(createHelpText(), {
208256
async function main() {
209257
console.log(`${bold('@stoe/action-reporting-cli')} ${dim(`v${cli.pkg.version}`)}\n`)
210258

211-
const {token, hostname, enterprise, owner, repository, archived, forked, debug, help, version} = cli.flags
259+
const {token, hostname, enterprise, owner, repository, debug, archived, forked, help, version} = cli.flags
212260
const entity = enterprise || owner || repository
213261
const logger = log(entity, token, debug)
214262
const cache = cacheInstance(null, logger)
@@ -219,6 +267,10 @@ async function main() {
219267
if (version) cli.showVersion(0)
220268

221269
const report = new Report(cli.flags, logger, cache)
270+
271+
// Display analysis summary
272+
displayAnalysisSummary(cli.flags, enterprise || owner || repository, hostname)
273+
222274
let results
223275

224276
if (enterprise) {

0 commit comments

Comments
 (0)