MCPcopy Create free account
hub / github.com/PowerShell/DSC / main

Function main

resources/WindowsUpdate/src/main.rs:12–107  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

10rust_i18n::i18n!("locales", fallback = "en-us");
11
12fn main() {
13 let args: Vec<String> = std::env::args().collect();
14
15 if args.len() < 2 {
16 eprintln!("Error: {}", t!("main.missingOperation"));
17 eprintln!("{}", t!("main.usage"));
18 std::process::exit(1);
19 }
20
21 let operation = args[1].as_str();
22
23 match operation {
24 "export" => {
25 // Read optional input from stdin (only if stdin is not a terminal/TTY)
26 let mut buffer = String::new();
27 if !io::stdin().is_terminal() {
28 let _ = io::stdin().read_to_string(&mut buffer);
29 }
30
31 #[cfg(windows)]
32 match windows_update::handle_export(&buffer) {
33 Ok(output) => {
34 println!("{}", output);
35 std::process::exit(0);
36 }
37 Err(e) => {
38 eprintln!("Error: {}", e);
39 std::process::exit(1);
40 }
41 }
42
43 #[cfg(not(windows))]
44 {
45 eprintln!("Error: {}", t!("main.windowsUpdateOnlySupported"));
46 std::process::exit(1);
47 }
48 }
49 "get" => {
50 // Read input from stdin
51 let mut buffer = String::new();
52 if let Err(e) = io::stdin().read_to_string(&mut buffer) {
53 eprintln!("{}", t!("main.errorReadingInput", err = e));
54 std::process::exit(1);
55 }
56
57 #[cfg(windows)]
58 match windows_update::handle_get(&buffer) {
59 Ok(output) => {
60 println!("{}", output);
61 std::process::exit(0);
62 }
63 Err(e) => {
64 eprintln!("Error: {}", e);
65 std::process::exit(1);
66 }
67 }
68
69 #[cfg(not(windows))]

Callers

nothing calls this directly

Calls 5

as_strMethod · 0.80
newFunction · 0.50
handle_exportFunction · 0.50
handle_getFunction · 0.50
handle_setFunction · 0.50

Tested by

no test coverage detected