Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions packages/cli-v3/src/cli/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,17 @@ export const CommonCommandOptions = z.object({
apiUrl: z.string().optional(),
logLevel: z.enum(["debug", "info", "log", "warn", "error", "none"]).default("log"),
skipTelemetry: z.boolean().default(false),
profile: z.string().default(readAuthConfigCurrentProfileName()),
profile: z
.string()
.optional()
.transform((v) => v ?? readAuthConfigCurrentProfileName()),
});

export type CommonCommandOptions = z.infer<typeof CommonCommandOptions>;

export function commonOptions(command: Command) {
return command
.option("--profile <profile>", "The login profile to use", readAuthConfigCurrentProfileName())
.option("--profile <profile>", "The login profile to use")
.option("-a, --api-url <value>", "Override the API URL", CLOUD_API_URL)
.option(
"-l, --log-level <level>",
Expand All @@ -30,9 +33,9 @@ export function commonOptions(command: Command) {
.option("--skip-telemetry", "Opt-out of sending telemetry");
}

export class SkipLoggingError extends Error {}
export class SkipCommandError extends Error {}
export class OutroCommandError extends SkipCommandError {}
export class SkipLoggingError extends Error { }
export class SkipCommandError extends Error { }
export class OutroCommandError extends SkipCommandError { }

export async function handleTelemetry(action: () => Promise<void>) {
try {
Expand Down