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

Function main

resources/sshdconfig/src/main.rs:37–93  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

35const EXIT_FAILURE: i32 = 1;
36
37fn main() {
38 let args = Args::parse();
39
40 enable_tracing(args.trace_level.as_ref(), &args.trace_format);
41
42 let result = match &args.command {
43 Command::Export { input, compare } => {
44 debug!("{}: {:?}", t!("main.export").to_string(), input);
45 invoke_export(input.as_ref(), *compare)
46 },
47 Command::Get { input, setting } => {
48 invoke_get(input.as_ref(), setting)
49 },
50 Command::Schema { setting } => {
51 debug!("{}; {:?}", t!("main.schema").to_string(), setting);
52 let schema = match setting {
53 Setting::SshdConfig => {
54 schema_for!(SshdConfigParser)
55 },
56 Setting::SshdConfigRepeat => {
57 schema_for!(RepeatInput)
58 },
59 Setting::SshdConfigRepeatList => {
60 schema_for!(RepeatListInput)
61 },
62 Setting::WindowsGlobal => {
63 schema_for!(DefaultShell)
64 }
65 };
66 println!("{}", serde_json::to_string(&schema).unwrap());
67 Ok(Map::new())
68 },
69 Command::Set { input, setting } => {
70 debug!("{}", t!("main.set", input = input).to_string());
71 invoke_set(input, setting)
72 },
73 };
74
75 match result {
76 Ok(output) => {
77 if !output.is_empty() {
78 match serde_json::to_string(&output) {
79 Ok(json) => println!("{json}"),
80 Err(e) => {
81 error!("{}", e);
82 exit(EXIT_FAILURE);
83 }
84 }
85 }
86 exit(EXIT_SUCCESS);
87 },
88 Err(e) => {
89 error!("{}", e);
90 exit(EXIT_FAILURE);
91 }
92 }
93}

Callers

nothing calls this directly

Calls 9

enable_tracingFunction · 0.70
invoke_exportFunction · 0.70
invoke_getFunction · 0.70
invoke_setFunction · 0.70
parseFunction · 0.50
newFunction · 0.50
to_stringFunction · 0.50
as_refMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected