Skip to content

Commit

Permalink
feat(gui): add input parameter handling for GUI mode
Browse files Browse the repository at this point in the history
  • Loading branch information
FliPPeDround committed Jan 8, 2025
1 parent 504d3c0 commit 4bb9833
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions packages/core/src/command/actions/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ export function actionGuiCLI() {
})

const [command, ..._args] = fullCustomCommand.split(' ')
const { error, stdout } = sync(command, [..._args], {
input,
const { error, stdout } = sync(command, [..._args, '--input', input], {
stdio: 'pipe',
})

Expand All @@ -36,6 +35,7 @@ export function actionGuiCLI() {
let data: any
if (stdout.length > 0) {
const data_string = stdout.toString()
console.log(data_string)

Check warning on line 38 in packages/core/src/command/actions/gui.ts

View workflow job for this annotation

GitHub Actions / lint

Unexpected console statement
try {
const _data = JSON.parse(data_string)
if (_data.useTemplate) {
Expand Down
7 changes: 6 additions & 1 deletion packages/gui/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ pub fn create_webview() -> Result<()> {
let current_dir: PathBuf = env::current_dir().expect("Unable to get current working directory");
let mut input = String::new();

io::stdin().read_to_string(&mut input).unwrap();
let args: Vec<String> = env::args().collect();
if let Some(input_value) = args.iter().position(|x| x == "--input").and_then(|i| args.get(i + 1)) {
input = input_value.to_string();
} else {
println!("No input provided.");
}

let current_dir_str = current_dir.to_str().unwrap_or("");
let escaped_current_dir_str = current_dir_str.replace("\\", "\\\\");
Expand Down

0 comments on commit 4bb9833

Please sign in to comment.