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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue