MCPcopy Create free account
hub / github.com/ExtropyIO/SolanaBootcamp / main

Function main

homeworks_rust/src/main.rs:84–157  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

82}
83
84fn main() {
85
86 let args: Args = argh::from_env();
87
88 if args.version {
89 println!("v{}", VERSION);
90 std::process::exit(0);
91 }
92
93 if args.nested.is_none() {
94 println!("\n{}\n", WELCOME);
95 }
96
97 if !Path::new("info.toml").exists() {
98 println!(
99 "{} must be run from the rustlings directory",
100 std::env::current_exe().unwrap().to_str().unwrap()
101 );
102 println!("Try `cd rustlings/`!");
103 std::process::exit(1);
104 }
105
106 if !rustc_exists() {
107 println!("We cannot find `rustc`.");
108 println!("Try running `rustc --version` to diagnose your problem.");
109 println!("For instructions on how to install Rust, check the README.");
110 std::process::exit(1);
111 }
112
113 // Gets homework structs
114 let toml_str = &fs::read_to_string("info.toml").unwrap();
115 let exercises = toml::from_str::<ExerciseList>(toml_str).unwrap().exercises;
116 let verbose = args.nocapture;
117
118 let command = args.nested.unwrap_or_else(|| {
119 println!("{}\n", DEFAULT_OUT);
120 std::process::exit(0);
121 });
122
123 println!("\n\nEND\n\n");
124
125 match command {
126
127 Subcommands::Run(subargs) => {
128 let exercise = find_exercise(&subargs.name, &exercises);
129 run(exercise, verbose).unwrap_or_else(|_| std::process::exit(1));
130 }
131
132 Subcommands::Hint(subargs) => {
133 let exercise = find_exercise(&subargs.name, &exercises);
134 println!("{}", exercise.hint);
135 }
136
137 Subcommands::Verify(_subargs) => {
138 verify(&exercises, verbose).unwrap_or_else(|_| std::process::exit(1));
139 }
140
141 Subcommands::Homework(subargs) => match homework(&exercises, verbose, subargs.name) {

Callers

nothing calls this directly

Calls 5

rustc_existsFunction · 0.85
find_exerciseFunction · 0.85
runFunction · 0.85
verifyFunction · 0.85
homeworkFunction · 0.85

Tested by

no test coverage detected