refactor: rename flag variables for improved clarity and intent

This commit is contained in:
mitchell 2026-06-19 14:28:16 -04:00
parent d157978d52
commit bf5e223abf
2 changed files with 28 additions and 28 deletions

View file

@ -40,26 +40,26 @@ async function main() {
const newConvo = args.new ?? args.n; const newConvo = args.new ?? args.n;
const plainOut = args["plain-out"] ?? args.plain ?? !process.stdout.isTTY; const plainOut = args["plain-out"] ?? args.plain ?? !process.stdout.isTTY;
const plainErr = args["plain-err"] ?? args.plain ?? !process.stderr.isTTY; const plainErr = args["plain-err"] ?? args.plain ?? !process.stderr.isTTY;
const modelFlag = args.model ?? args.m; const modelOverride = args.model ?? args.m;
const versionFlag = args.version ?? args.v; const showVersion = args.version ?? args.v;
const configFlag = args.config ?? args.c; const editConfig = args.config ?? args.c;
const messageFlag = args["git-message"] ?? args.g; const generateGitMessage = args["git-message"] ?? args.g;
const reviewFlag = args.review ?? args.r; const generateReview = args.review ?? args.r;
const fileFlag = args.file ?? args.f; const inputFile = args.file ?? args.f;
if (versionFlag) { if (showVersion) {
console.log("0.0.0"); console.log("0.0.0");
return; return;
} }
const config = await loadConfig(configFlag); const config = await loadConfig(editConfig);
if (configFlag || !config) { if (editConfig || !config) {
await initConfig(config); await initConfig(config);
return; return;
} }
const model = modelFlag ?? config.model; const model = modelOverride ?? config.model;
const renderer = new Renderer(plainOut, plainErr); const renderer = new Renderer(plainOut, plainErr);
@ -74,22 +74,22 @@ async function main() {
if (!newConvo) { if (!newConvo) {
await convo.load(); await convo.load();
if (modelFlag) convo.model = modelFlag; if (modelOverride) convo.model = modelOverride;
} }
let input = positionals.join(" ").trim(); let input = positionals.join(" ").trim();
if (input === "-") input = await consumers.text(process.stdin); if (input === "-") input = await consumers.text(process.stdin);
let prompt = input; let prompt = input;
if (messageFlag) { if (generateGitMessage) {
prompt = commitDiff(input); prompt = commitDiff(input);
} else if (reviewFlag && fileFlag) { } else if (generateReview && inputFile) {
const content = await fs.readFile(fileFlag, "utf8"); const content = await fs.readFile(inputFile, "utf8");
prompt = reviewFile(file(fileFlag, content)); prompt = reviewFile(file(inputFile, content));
} else if (fileFlag) { } else if (inputFile) {
const content = await fs.readFile(fileFlag, "utf8"); const content = await fs.readFile(inputFile, "utf8");
prompt = `${file(fileFlag, content)}\n\n${input}`; prompt = `${file(inputFile, content)}\n\n${input}`;
} else if (reviewFlag) { } else if (generateReview) {
prompt = reviewDiff(input); prompt = reviewDiff(input);
} }

View file

@ -30,19 +30,19 @@ async function main() {
allowPositionals: true, allowPositionals: true,
}); });
const wait = args.wait ?? args.w; const waitAndCombine = args.wait ?? args.w;
const url = args.url ?? args.u; const readURL = args.url ?? args.u;
const edit = args.edit ?? args.e; const editContent = args.edit ?? args.e;
let input = positionals.join(" ").trim(); let input = positionals.join(" ").trim();
if (!input) input = await consumers.text(process.stdin); if (!input) input = (await consumers.text(process.stdin)).trim();
if (!input) { if (!input) {
throw new Error("No input was given. Use positional arguments or stdin."); throw new Error("No input was given. Use positional arguments or stdin.");
} }
if (url) { if (readURL) {
const result = await fetch(input); const result = await fetch(input);
const window = new Window({ url: input }); const window = new Window({ url: input });
const doc = window.document; const doc = window.document;
@ -60,7 +60,7 @@ async function main() {
const home = os.homedir(); const home = os.homedir();
const cwd = path.join(home, ".ttsc"); const cwd = path.join(home, ".ttsc");
if (edit) { if (editContent) {
const file = path.join(cwd, "input.txt"); const file = path.join(cwd, "input.txt");
await fs.writeFile(file, input, "utf8"); await fs.writeFile(file, input, "utf8");
const editor = process.env.EDITOR || "nano"; const editor = process.env.EDITOR || "nano";
@ -90,7 +90,7 @@ async function main() {
stderr: "inherit", stderr: "inherit",
})`uv run -- python -u main.py`; })`uv run -- python -u main.py`;
if (!wait) { if (!waitAndCombine) {
koko.catch(() => {}); koko.catch(() => {});
koko.then(() => { koko.then(() => {
const stop = Date.now(); const stop = Date.now();
@ -124,7 +124,7 @@ async function main() {
const file = path.join(cwd, `${info.file}.wav`); const file = path.join(cwd, `${info.file}.wav`);
if (wait) { if (waitAndCombine) {
files.push(file); files.push(file);
process.stdout.write("."); process.stdout.write(".");
} else { } else {
@ -141,7 +141,7 @@ async function main() {
} }
await koko; await koko;
if (!wait) return; if (!waitAndCombine) return;
const stop = Date.now(); const stop = Date.now();
const duration = ((stop - start) / 1000).toFixed(2); const duration = ((stop - start) / 1000).toFixed(2);