Skip to content

Commit c517068

Browse files
author
梶塚太智
committed
外部プログラム実行のshellコマンド追加
1 parent 1aaed63 commit c517068

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@ edition = "2021"
66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
77

88
[dependencies]
9-
rand = "0.8"
9+
powershell_script = "1.1.0"
10+
rand = "0.8"

src/main.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use powershell_script::PsScriptBuilder;
12
use rand::seq::SliceRandom;
23
use std::collections::HashMap;
34
use std::env;
@@ -530,6 +531,17 @@ impl Executor {
530531
}
531532
}
532533

534+
"shell" => {
535+
let ps = PsScriptBuilder::new()
536+
.no_profile(true)
537+
.non_interactive(true)
538+
.hidden(false)
539+
.print_commands(false)
540+
.build();
541+
let output = ps.run(self.pop_stack().get_string().as_str()).unwrap();
542+
self.stack.push(Type::String(output.stdout().unwrap()));
543+
}
544+
533545
// プロセスを終了
534546
"exit" => {
535547
let status = self.pop_stack().get_number();

0 commit comments

Comments
 (0)