mirror of
https://github.com/OneUptime/oneuptime.git
synced 2026-04-06 00:32:12 +02:00
- Added missing newlines at the end of files in MarkdownContent.tsx and RootCauseCard.tsx - Reformatted shadowColor and color properties in NotesSection.tsx, SegmentedControl.tsx, MainTabNavigator.tsx, HomeScreen.tsx for better readability - Enhanced code formatting in SectionHeader.tsx and OnCallStackNavigator.tsx for consistency - Improved readability of getEntityId function in useAllProjectOnCallPolicies.ts - Refactored conditional rendering in AlertDetailScreen.tsx, AlertEpisodeDetailScreen.tsx, IncidentDetailScreen.tsx, and IncidentEpisodeDetailScreen.tsx for better clarity
67 lines
2.6 KiB
TypeScript
67 lines
2.6 KiB
TypeScript
import { Command, Option } from "commander";
|
|
import { registerConfigCommands } from "../Commands/ConfigCommands";
|
|
import { registerResourceCommands } from "../Commands/ResourceCommands";
|
|
import { registerUtilityCommands } from "../Commands/UtilityCommands";
|
|
|
|
describe("Index (CLI entry point)", () => {
|
|
it("should create a program with all command groups registered", () => {
|
|
const program: Command = new Command();
|
|
program
|
|
.name("oneuptime")
|
|
.description(
|
|
"OneUptime CLI - Manage your OneUptime resources from the command line",
|
|
)
|
|
.version("1.0.0")
|
|
.option("--api-key <key>", "API key (overrides config)")
|
|
.option("--url <url>", "OneUptime instance URL (overrides config)")
|
|
.option("--context <name>", "Use a specific context")
|
|
.option("-o, --output <format>", "Output format: json, table, wide")
|
|
.option("--no-color", "Disable colored output");
|
|
|
|
registerConfigCommands(program);
|
|
registerUtilityCommands(program);
|
|
registerResourceCommands(program);
|
|
|
|
// Verify all expected commands are registered
|
|
const commandNames: string[] = program.commands.map((c: Command) => {
|
|
return c.name();
|
|
});
|
|
expect(commandNames).toContain("login");
|
|
expect(commandNames).toContain("context");
|
|
expect(commandNames).toContain("version");
|
|
expect(commandNames).toContain("whoami");
|
|
expect(commandNames).toContain("resources");
|
|
expect(commandNames).toContain("incident");
|
|
expect(commandNames).toContain("monitor");
|
|
expect(commandNames).toContain("alert");
|
|
});
|
|
|
|
it("should set correct program name and description", () => {
|
|
const program: Command = new Command();
|
|
program.name("oneuptime").description("OneUptime CLI");
|
|
|
|
expect(program.name()).toBe("oneuptime");
|
|
});
|
|
|
|
it("should define global options", () => {
|
|
const program: Command = new Command();
|
|
program
|
|
.option("--api-key <key>", "API key")
|
|
.option("--url <url>", "URL")
|
|
.option("--context <name>", "Context")
|
|
.option("-o, --output <format>", "Output format")
|
|
.option("--no-color", "Disable color");
|
|
|
|
// Parse with just the program name - verify options are registered
|
|
const options: readonly Option[] = program.options;
|
|
const optionNames: (string | undefined)[] = options.map((o: Option) => {
|
|
return o.long || o.short;
|
|
});
|
|
expect(optionNames).toContain("--api-key");
|
|
expect(optionNames).toContain("--url");
|
|
expect(optionNames).toContain("--context");
|
|
expect(optionNames).toContain("--output");
|
|
expect(optionNames).toContain("--no-color");
|
|
});
|
|
});
|