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

Function main

tools/dsctest/src/main.rs:50–462  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

48
49#[allow(clippy::too_many_lines)]
50fn main() {
51 let args = Args::parse();
52 let json = match args.subcommand {
53 SubCommand::Adapter { input , resource_type, resource_path, operation } => {
54 match adapter::adapt(&resource_type, &input, &operation, &resource_path) {
55 Ok(result) => result,
56 Err(err) => {
57 eprintln!("Error adapting resource: {err}");
58 std::process::exit(1);
59 }
60 }
61 },
62 SubCommand::CopyResource { input } => {
63 let copy_resource = match serde_json::from_str::<CopyResource>(&input) {
64 Ok(copy_resource) => copy_resource,
65 Err(err) => {
66 eprintln!("Error JSON does not match schema: {err}");
67 std::process::exit(1);
68 }
69 };
70 if let Err(err) = copy_the_resource(&copy_resource.source_file, &copy_resource.type_name) {
71 eprintln!("Error copying resource: {err}");
72 std::process::exit(1);
73 }
74 input
75 },
76 SubCommand::Delete { input } => {
77 let mut delete = match serde_json::from_str::<Delete>(&input) {
78 Ok(delete) => delete,
79 Err(err) => {
80 eprintln!("Error JSON does not match schema: {err}");
81 std::process::exit(1);
82 }
83 };
84 delete.delete_called = Some(true);
85 serde_json::to_string(&delete).unwrap()
86 },
87 SubCommand::Exist { input } => {
88 let mut exist = match serde_json::from_str::<Exist>(&input) {
89 Ok(exist) => exist,
90 Err(err) => {
91 eprintln!("Error JSON does not match schema: {err}");
92 std::process::exit(1);
93 }
94 };
95 if exist.exist {
96 exist.state = Some(State::Present);
97 } else {
98 exist.state = Some(State::Absent);
99 }
100
101 serde_json::to_string(&exist).unwrap()
102 },
103 SubCommand::ExitCode { input } => {
104 let exit_code = match serde_json::from_str::<ExitCode>(&input) {
105 Ok(exit_code) => exit_code,
106 Err(err) => {
107 eprintln!("Error JSON does not match schema: {err}");

Callers

nothing calls this directly

Calls 13

adaptFunction · 0.85
copy_the_resourceFunction · 0.85
BoolClass · 0.85
ArrayClass · 0.85
into_iterMethod · 0.80
parseFunction · 0.50
to_stringFunction · 0.50
newFunction · 0.50
is_emptyMethod · 0.45
nextMethod · 0.45
as_refMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected