refactor: async-ify yargs (#236)

This commit is contained in:
Brandon Keiji 2025-05-01 01:00:53 +00:00 committed by GitHub
parent 339d598295
commit b27aae26c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 6 deletions

View File

@ -23,8 +23,8 @@ interface CliArgs {
full_context: boolean | undefined;
}
function parseArguments(): CliArgs {
const argv = yargs(hideBin(process.argv))
async function parseArguments(): Promise<CliArgs> {
const argv = await yargs(hideBin(process.argv))
.option('model', {
alias: 'm',
type: 'string',
@ -53,11 +53,11 @@ function parseArguments(): CliArgs {
.help()
.alias('h', 'help')
.strict().argv;
return argv as unknown as CliArgs;
return argv;
}
// Renamed function for clarity
export function loadCliConfig(): Config {
export async function loadCliConfig(): Promise<Config> {
// Load .env file using logic from server package
loadEnvironment();
@ -71,7 +71,7 @@ export function loadCliConfig(): Config {
}
// Parse CLI arguments
const argv = parseArguments();
const argv = await parseArguments();
// Create config using factory from server package
return createServerConfig(

View File

@ -19,7 +19,7 @@ const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
async function main() {
const config = loadCliConfig();
const config = await loadCliConfig();
let input = config.getQuestion();
// hop into sandbox if we are outside and sandboxing is enabled