feat: overhaul CLI with new AI commands and mole-style menu #6
@@ -611,11 +611,14 @@ async function showMenu(): Promise<void> {
|
||||
|
||||
if (selected === null || selected === BACK) return;
|
||||
|
||||
if (selected === "commit") await handleCommit(false, false);
|
||||
else if (selected === "pr") await handlePR(false);
|
||||
else await handleConfig();
|
||||
const result =
|
||||
selected === "commit"
|
||||
? await handleCommit(false, false)
|
||||
: selected === "pr"
|
||||
? await handlePR(false)
|
||||
: await handleConfig();
|
||||
|
||||
return;
|
||||
if (result !== "back") return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -660,9 +663,13 @@ async function handleCommit(
|
||||
const unstagedFiles = await getUnstagedFiles();
|
||||
|
||||
if (stagedFiles.length === 0 && unstagedFiles.length === 0) {
|
||||
console.log(`\n ${YELLOW}Nothing to commit.${RESET}`);
|
||||
await ask(` ${DIM}Press Enter to exit...${RESET}`);
|
||||
process.exit(0);
|
||||
const choice = await selectOne({
|
||||
title: "Nothing to commit",
|
||||
subtitle: "No staged or unstaged changes.",
|
||||
items: [{ label: "Back", value: "back" as const }],
|
||||
});
|
||||
if (choice === null) process.exit(0);
|
||||
return "done";
|
||||
}
|
||||
|
||||
if (unstagedFiles.length > 0) {
|
||||
@@ -685,9 +692,13 @@ async function handleCommit(
|
||||
|
||||
const diff = await getStagedDiff();
|
||||
if (!diff) {
|
||||
console.log(`\n ${YELLOW}No staged changes to commit.${RESET}`);
|
||||
await ask(` ${DIM}Press Enter to exit...${RESET}`);
|
||||
process.exit(0);
|
||||
const choice = await selectOne({
|
||||
title: "Nothing to commit",
|
||||
subtitle: "No staged changes to commit.",
|
||||
items: [{ label: "Back", value: "back" as const }],
|
||||
});
|
||||
if (choice === null) process.exit(0);
|
||||
return "done";
|
||||
}
|
||||
|
||||
const MAX_DIFF_SIZE = 15000;
|
||||
@@ -815,11 +826,13 @@ async function handlePR(draft: boolean): Promise<"done" | "back"> {
|
||||
const commits = await getBranchCommits(baseBranch);
|
||||
|
||||
if (commits.length === 0) {
|
||||
console.error(
|
||||
`\n ${YELLOW}No commits on ${branchName} compared to ${baseBranch}. Commit something first.${RESET}`,
|
||||
);
|
||||
await ask(` ${DIM}Press Enter to exit...${RESET}`);
|
||||
process.exit(0);
|
||||
const choice = await selectOne({
|
||||
title: "No commits to compare",
|
||||
subtitle: `No commits on ${branchName} compared to ${baseBranch}. Commit something first.`,
|
||||
items: [{ label: "Back", value: "back" as const }],
|
||||
});
|
||||
if (choice === null) process.exit(0);
|
||||
return "done";
|
||||
}
|
||||
|
||||
console.log(
|
||||
|
||||
Reference in New Issue
Block a user