refactor: async-ify yargs (#236)
This commit is contained in:
parent
339d598295
commit
b27aae26c8
|
@ -23,8 +23,8 @@ interface CliArgs {
|
||||||
full_context: boolean | undefined;
|
full_context: boolean | undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseArguments(): CliArgs {
|
async function parseArguments(): Promise<CliArgs> {
|
||||||
const argv = yargs(hideBin(process.argv))
|
const argv = await yargs(hideBin(process.argv))
|
||||||
.option('model', {
|
.option('model', {
|
||||||
alias: 'm',
|
alias: 'm',
|
||||||
type: 'string',
|
type: 'string',
|
||||||
|
@ -53,11 +53,11 @@ function parseArguments(): CliArgs {
|
||||||
.help()
|
.help()
|
||||||
.alias('h', 'help')
|
.alias('h', 'help')
|
||||||
.strict().argv;
|
.strict().argv;
|
||||||
return argv as unknown as CliArgs;
|
return argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Renamed function for clarity
|
// Renamed function for clarity
|
||||||
export function loadCliConfig(): Config {
|
export async function loadCliConfig(): Promise<Config> {
|
||||||
// Load .env file using logic from server package
|
// Load .env file using logic from server package
|
||||||
loadEnvironment();
|
loadEnvironment();
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ export function loadCliConfig(): Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse CLI arguments
|
// Parse CLI arguments
|
||||||
const argv = parseArguments();
|
const argv = await parseArguments();
|
||||||
|
|
||||||
// Create config using factory from server package
|
// Create config using factory from server package
|
||||||
return createServerConfig(
|
return createServerConfig(
|
||||||
|
|
|
@ -19,7 +19,7 @@ const __filename = fileURLToPath(import.meta.url);
|
||||||
const __dirname = dirname(__filename);
|
const __dirname = dirname(__filename);
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const config = loadCliConfig();
|
const config = await loadCliConfig();
|
||||||
let input = config.getQuestion();
|
let input = config.getQuestion();
|
||||||
|
|
||||||
// hop into sandbox if we are outside and sandboxing is enabled
|
// hop into sandbox if we are outside and sandboxing is enabled
|
||||||
|
|
Loading…
Reference in New Issue