refactor: extract model flag and simplify config return type
This commit is contained in:
parent
6dc55bc3f3
commit
d327ed614a
2 changed files with 9 additions and 8 deletions
11
index.ts
11
index.ts
|
|
@ -31,14 +31,17 @@ async function main() {
|
|||
const newConvo = args.new ?? args.n;
|
||||
const plainOut = args.plainOut ?? args.plain ?? !process.stdout.isTTY;
|
||||
const plainErr = args.plainErr ?? args.plain ?? !process.stderr.isTTY;
|
||||
const modelFlag = args.model ?? args.m;
|
||||
const saveConfigFlag = args.save ?? args.s;
|
||||
|
||||
const { config } = await loadConfig();
|
||||
const config = await loadConfig();
|
||||
|
||||
config.model = args.model ?? args.m ?? config.model;
|
||||
config.model = modelFlag ?? config.model;
|
||||
|
||||
if (!config.model) {
|
||||
console.error("Please specify a model with --model/-m at least one time.");
|
||||
console.error(
|
||||
"Please run 'aicl --model <model> --save' to set a default model.",
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
|
@ -65,7 +68,7 @@ async function main() {
|
|||
convo = await loadConversation(config.model);
|
||||
|
||||
if (args.model || args.m) {
|
||||
convo.model = args.model ?? args.m ?? config.model;
|
||||
convo.model = modelFlag ?? config.model;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue