refactor: rename flag variables for improved clarity and intent
This commit is contained in:
parent
d157978d52
commit
bf5e223abf
2 changed files with 28 additions and 28 deletions
38
src/index.ts
38
src/index.ts
|
|
@ -40,26 +40,26 @@ async function main() {
|
|||
const newConvo = args.new ?? args.n;
|
||||
const plainOut = args["plain-out"] ?? args.plain ?? !process.stdout.isTTY;
|
||||
const plainErr = args["plain-err"] ?? args.plain ?? !process.stderr.isTTY;
|
||||
const modelFlag = args.model ?? args.m;
|
||||
const versionFlag = args.version ?? args.v;
|
||||
const configFlag = args.config ?? args.c;
|
||||
const messageFlag = args["git-message"] ?? args.g;
|
||||
const reviewFlag = args.review ?? args.r;
|
||||
const fileFlag = args.file ?? args.f;
|
||||
const modelOverride = args.model ?? args.m;
|
||||
const showVersion = args.version ?? args.v;
|
||||
const editConfig = args.config ?? args.c;
|
||||
const generateGitMessage = args["git-message"] ?? args.g;
|
||||
const generateReview = args.review ?? args.r;
|
||||
const inputFile = args.file ?? args.f;
|
||||
|
||||
if (versionFlag) {
|
||||
if (showVersion) {
|
||||
console.log("0.0.0");
|
||||
return;
|
||||
}
|
||||
|
||||
const config = await loadConfig(configFlag);
|
||||
const config = await loadConfig(editConfig);
|
||||
|
||||
if (configFlag || !config) {
|
||||
if (editConfig || !config) {
|
||||
await initConfig(config);
|
||||
return;
|
||||
}
|
||||
|
||||
const model = modelFlag ?? config.model;
|
||||
const model = modelOverride ?? config.model;
|
||||
|
||||
const renderer = new Renderer(plainOut, plainErr);
|
||||
|
||||
|
|
@ -74,22 +74,22 @@ async function main() {
|
|||
|
||||
if (!newConvo) {
|
||||
await convo.load();
|
||||
if (modelFlag) convo.model = modelFlag;
|
||||
if (modelOverride) convo.model = modelOverride;
|
||||
}
|
||||
|
||||
let input = positionals.join(" ").trim();
|
||||
if (input === "-") input = await consumers.text(process.stdin);
|
||||
|
||||
let prompt = input;
|
||||
if (messageFlag) {
|
||||
if (generateGitMessage) {
|
||||
prompt = commitDiff(input);
|
||||
} else if (reviewFlag && fileFlag) {
|
||||
const content = await fs.readFile(fileFlag, "utf8");
|
||||
prompt = reviewFile(file(fileFlag, content));
|
||||
} else if (fileFlag) {
|
||||
const content = await fs.readFile(fileFlag, "utf8");
|
||||
prompt = `${file(fileFlag, content)}\n\n${input}`;
|
||||
} else if (reviewFlag) {
|
||||
} else if (generateReview && inputFile) {
|
||||
const content = await fs.readFile(inputFile, "utf8");
|
||||
prompt = reviewFile(file(inputFile, content));
|
||||
} else if (inputFile) {
|
||||
const content = await fs.readFile(inputFile, "utf8");
|
||||
prompt = `${file(inputFile, content)}\n\n${input}`;
|
||||
} else if (generateReview) {
|
||||
prompt = reviewDiff(input);
|
||||
}
|
||||
|
||||
|
|
|
|||
18
src/tts.ts
18
src/tts.ts
|
|
@ -30,19 +30,19 @@ async function main() {
|
|||
allowPositionals: true,
|
||||
});
|
||||
|
||||
const wait = args.wait ?? args.w;
|
||||
const url = args.url ?? args.u;
|
||||
const edit = args.edit ?? args.e;
|
||||
const waitAndCombine = args.wait ?? args.w;
|
||||
const readURL = args.url ?? args.u;
|
||||
const editContent = args.edit ?? args.e;
|
||||
|
||||
let input = positionals.join(" ").trim();
|
||||
|
||||
if (!input) input = await consumers.text(process.stdin);
|
||||
if (!input) input = (await consumers.text(process.stdin)).trim();
|
||||
|
||||
if (!input) {
|
||||
throw new Error("No input was given. Use positional arguments or stdin.");
|
||||
}
|
||||
|
||||
if (url) {
|
||||
if (readURL) {
|
||||
const result = await fetch(input);
|
||||
const window = new Window({ url: input });
|
||||
const doc = window.document;
|
||||
|
|
@ -60,7 +60,7 @@ async function main() {
|
|||
const home = os.homedir();
|
||||
const cwd = path.join(home, ".ttsc");
|
||||
|
||||
if (edit) {
|
||||
if (editContent) {
|
||||
const file = path.join(cwd, "input.txt");
|
||||
await fs.writeFile(file, input, "utf8");
|
||||
const editor = process.env.EDITOR || "nano";
|
||||
|
|
@ -90,7 +90,7 @@ async function main() {
|
|||
stderr: "inherit",
|
||||
})`uv run -- python -u main.py`;
|
||||
|
||||
if (!wait) {
|
||||
if (!waitAndCombine) {
|
||||
koko.catch(() => {});
|
||||
koko.then(() => {
|
||||
const stop = Date.now();
|
||||
|
|
@ -124,7 +124,7 @@ async function main() {
|
|||
|
||||
const file = path.join(cwd, `${info.file}.wav`);
|
||||
|
||||
if (wait) {
|
||||
if (waitAndCombine) {
|
||||
files.push(file);
|
||||
process.stdout.write(".");
|
||||
} else {
|
||||
|
|
@ -141,7 +141,7 @@ async function main() {
|
|||
}
|
||||
|
||||
await koko;
|
||||
if (!wait) return;
|
||||
if (!waitAndCombine) return;
|
||||
|
||||
const stop = Date.now();
|
||||
const duration = ((stop - start) / 1000).toFixed(2);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue