mirror of
https://github.com/QwenLM/qwen-code.git
synced 2025-12-19 09:33:53 +00:00
Question flag (#125)
This commit is contained in:
@@ -20,6 +20,7 @@ interface CliArgs {
|
||||
target_dir: string | undefined;
|
||||
model: string | undefined;
|
||||
debug_mode: boolean | undefined;
|
||||
question: string | undefined;
|
||||
}
|
||||
|
||||
function parseArguments(): CliArgs {
|
||||
@@ -42,6 +43,12 @@ function parseArguments(): CliArgs {
|
||||
description: 'Whether to run in debug mode. Defaults to false.',
|
||||
default: false,
|
||||
})
|
||||
.option('question', {
|
||||
alias: 'q',
|
||||
type: 'string',
|
||||
description:
|
||||
'The question to pass to the command when using piped input.',
|
||||
})
|
||||
.help()
|
||||
.alias('h', 'help')
|
||||
.strict().argv;
|
||||
@@ -71,6 +78,7 @@ export function loadCliConfig(): Config {
|
||||
argv.model || DEFAULT_GEMINI_MODEL,
|
||||
argv.target_dir || process.cwd(),
|
||||
argv.debug_mode || false,
|
||||
argv.question || '',
|
||||
// TODO: load passthroughCommands from .env file
|
||||
);
|
||||
}
|
||||
|
||||
@@ -13,9 +13,10 @@ import { GeminiClient } from '@gemini-code/server';
|
||||
|
||||
async function main() {
|
||||
const config = loadCliConfig();
|
||||
let input = config.getQuestion();
|
||||
|
||||
// Render UI, passing necessary config values and initial input
|
||||
if (process.stdin.isTTY) {
|
||||
// Render UI, passing necessary config values. Check that there is no command line question.
|
||||
if (process.stdin.isTTY && input?.length === 0) {
|
||||
render(
|
||||
React.createElement(App, {
|
||||
config,
|
||||
@@ -24,7 +25,11 @@ async function main() {
|
||||
return;
|
||||
}
|
||||
|
||||
const input = await readStdin();
|
||||
// If not a TTY, read from stdin
|
||||
// This is for cases where the user pipes input directly into the command
|
||||
if (!process.stdin.isTTY) {
|
||||
input += await readStdin();
|
||||
}
|
||||
if (!input) {
|
||||
console.error('No input provided via stdin.');
|
||||
process.exit(1);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
import { exec as _exec, exec } from 'child_process';
|
||||
import { exec as _exec } from 'child_process';
|
||||
import { useState, useRef, useCallback, useEffect } from 'react';
|
||||
import { useInput } from 'ink';
|
||||
import {
|
||||
|
||||
Reference in New Issue
Block a user