diff --git a/src/commands/new.ts b/src/commands/new.ts index e0995fd..5b76f8f 100644 --- a/src/commands/new.ts +++ b/src/commands/new.ts @@ -10,6 +10,25 @@ import { requireApiKey } from "../env.ts" import { renderMarkdown } from "../markdown.ts" import { saveChanges } from "./helpers.ts" +const ADJECTIVES = [ + "calm", "bold", "warm", "cool", "keen", "soft", "fast", "wild", "fair", "rare", + "deep", "dark", "pale", "wide", "slim", "tall", "glad", "pure", "safe", "free", + "hazy", "lazy", "cozy", "tiny", "vast", "busy", "easy", "gray", "gold", "blue", + "rosy", "wavy", "mild", "loud", "firm", "flat", "crisp", "dry", "raw", "odd", +] +const NOUNS = [ + "fern", "dune", "cove", "pine", "reef", "hawk", "pond", "mesa", "vale", "glen", + "haze", "moss", "peak", "tide", "dawn", "lynx", "wren", "sage", "crag", "flint", + "leaf", "reed", "cave", "star", "gust", "surf", "opal", "lark", "vale", "plum", + "birch", "clay", "jade", "ivy", "fox", "elk", "bay", "ash", "dew", "oak", +] + +function randomBranchName(): string { + const adj = ADJECTIVES[Math.floor(Math.random() * ADJECTIVES.length)] + const noun = NOUNS[Math.floor(Math.random() * NOUNS.length)] + return `${adj}-${noun}` +} + function fallbackBranchName(text: string): string { return text .toLowerCase() @@ -63,7 +82,7 @@ export async function action( if (!branch && opts.print) { branch = await branchFromPrompt(opts.print) } else if (!branch) { - die("Branch name or prompt is required.") + branch = randomBranchName() } else if (branch.includes(" ")) { // If the "branch" contains spaces, it's actually a prompt — derive the branch name prompt = branch