diff --git a/src/cli.ts b/src/cli.ts index c847b1820..d4970c20b 100755 --- a/src/cli.ts +++ b/src/cli.ts @@ -8,7 +8,7 @@ import updateNotifier from 'tiny-updater' import colors from 'yoctocolors-cjs' import { actionCommand } from './commands/action' -import { analyticsCommand } from './commands/analytics' +import { analyticsCommand } from './commands/analytics/analytics-command' import { auditLogCommand } from './commands/audit-log' import { cdxgenCommand } from './commands/cdxgen' import { dependenciesCommand } from './commands/dependencies' diff --git a/src/commands/analytics/analytics-command.ts b/src/commands/analytics/analytics-command.ts new file mode 100644 index 000000000..3a44f0765 --- /dev/null +++ b/src/commands/analytics/analytics-command.ts @@ -0,0 +1,112 @@ +import meowOrDie from 'meow' +import colors from 'yoctocolors-cjs' + +import { runAnalytics } from './run-analytics.ts' +import { commonFlags, outputFlags } from '../../flags' +import { AuthError, InputError } from '../../utils/errors' +import { getFlagListOutput } from '../../utils/output-formatting' +import { getDefaultToken } from '../../utils/sdk.ts' + +import type { CliCommandConfig } from '../../utils/meow-with-subcommands' +import type { CommandContext } from '../types.ts' + +const config: CliCommandConfig = { + commandName: 'analytics', + description: `Look up analytics data`, + hidden: false, + flags: { + ...commonFlags, + ...outputFlags, + scope: { + type: 'string', + shortFlag: 's', + default: 'org', + description: + "Scope of the analytics data - either 'org' or 'repo', default: org" + }, + time: { + type: 'number', + shortFlag: 't', + default: 7, + description: 'Time filter - either 7, 30 or 90, default: 7' + }, + repo: { + type: 'string', + shortFlag: 'r', + default: '', + description: 'Name of the repository' + }, + file: { + type: 'string', + shortFlag: 'f', + default: '', + description: 'Path to a local file to save the output' + } + }, + help: (parentName, { commandName, flags }) => ` + Usage + $ ${parentName} ${commandName} --scope= --time=