Skip to content

Commit

Permalink
feat: Add VM command with feature flag support
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnPhamous committed Feb 14, 2025
1 parent fa313a6 commit 124c2f9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,12 @@ import { registerDev } from "./lib/dev.ts";
import { registerLogin } from "./lib/login.ts";
import { registerMe } from "./lib/me.ts";
import { registerOrders } from "./lib/orders/index.tsx";
import { analytics, IS_TRACKING_DISABLED } from "./lib/posthog.ts";
import { IS_TRACKING_DISABLED, analytics } from "./lib/posthog.ts";
import { registerSell } from "./lib/sell.ts";
import { registerTokens } from "./lib/tokens.ts";
import { registerScale } from "./lib/updown.tsx";
import { registerUpgrade } from "./lib/upgrade.ts";
import { registerVM } from "./lib/vm.ts";

const program = new Command();

Expand All @@ -42,6 +43,7 @@ registerUpgrade(program);
registerScale(program);
registerClusters(program);
registerMe(program);
await registerVM(program);

// (development commands)
registerDev(program);
Expand Down Expand Up @@ -69,7 +71,7 @@ const main = async () => {
}
}

program.exitOverride((error) => {
program.exitOverride(error => {
let isError = true;

switch (error.code) {
Expand All @@ -89,8 +91,8 @@ const main = async () => {
const nextArg = arr[i + 1];
if (nextArg && !nextArg.startsWith("-")) {
(acc as Record<string, string | number | boolean>)[key] = isNaN(
Number(nextArg),
)
Number(nextArg)
)
? nextArg
: Number(nextArg);
} else {
Expand Down
19 changes: 19 additions & 0 deletions src/lib/vm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type { Command } from "@commander-js/extra-typings";
import { isFeatureEnabled } from "./posthog.ts";

export async function registerVM(program: Command) {
const isEnabled = await isFeatureEnabled("vms");

if (!isEnabled) {
return;
}

program
.command("vm")
.description("Manage virtual machines")
.action(async () => {
console.log("VMs!!!");

process.exit(0);
});
}

0 comments on commit 124c2f9

Please sign in to comment.