Added returncode for main function
This commit is contained in:
		| @@ -1,8 +1,7 @@ | |||||||
| use std::{time::Duration, fmt::format}; | use std::time::Duration; | ||||||
| use bit::BitIndex; | use bit::BitIndex; | ||||||
| use chrono_tz::Europe::Berlin; | use chrono_tz::Europe::Berlin; | ||||||
| use chrono::{DateTime, NaiveDateTime, Utc, Timelike}; | use chrono::{DateTime, NaiveDateTime, Utc, Timelike}; | ||||||
| use chrono::prelude::*; |  | ||||||
| use std::time::{SystemTime, UNIX_EPOCH}; | use std::time::{SystemTime, UNIX_EPOCH}; | ||||||
| use openweathermap::forecast::Weather; | use openweathermap::forecast::Weather; | ||||||
| use substring::Substring; | use substring::Substring; | ||||||
| @@ -19,6 +18,7 @@ use embedded_graphics::{ | |||||||
| use std::net::UdpSocket; | use std::net::UdpSocket; | ||||||
| use std::{env, thread}; | use std::{env, thread}; | ||||||
| use std::io; | use std::io; | ||||||
|  | use std::process::ExitCode; | ||||||
|  |  | ||||||
| use openweathermap::forecast::Forecast; | use openweathermap::forecast::Forecast; | ||||||
| use straba::NextDeparture; | use straba::NextDeparture; | ||||||
| @@ -336,14 +336,14 @@ fn check_connection(ipaddress: String) -> bool { | |||||||
|     return device_online; |     return device_online; | ||||||
| } | } | ||||||
|  |  | ||||||
| fn main() { | fn main() -> ExitCode { | ||||||
|     let args: Vec<String> = env::args().collect(); |     let args: Vec<String> = env::args().collect(); | ||||||
|  |  | ||||||
|     match args.len() { |     match args.len() { | ||||||
|         // no arguments passed |         // no arguments passed | ||||||
|         1 => { |         1 => { | ||||||
|             // show a help message |             // show a help message | ||||||
|             help(); |             help(); | ||||||
|  |             return ExitCode::SUCCESS; | ||||||
|         } |         } | ||||||
|         // one argument passed |         // one argument passed | ||||||
|         2 => { |         2 => { | ||||||
| @@ -353,7 +353,7 @@ fn main() { | |||||||
|             let mut device_online = check_connection(ip.to_string()); |             let mut device_online = check_connection(ip.to_string()); | ||||||
|             if !device_online { |             if !device_online { | ||||||
|                 println!("{} not online", ip); |                 println!("{} not online", ip); | ||||||
|                 return |                 return ExitCode::FAILURE; | ||||||
|             } |             } | ||||||
|  |  | ||||||
|             let receiver = openweathermap::init_forecast("Mannheim", |             let receiver = openweathermap::init_forecast("Mannheim", | ||||||
| @@ -409,6 +409,7 @@ fn main() { | |||||||
|         _ => { |         _ => { | ||||||
|             // show a help message |             // show a help message | ||||||
|             help(); |             help(); | ||||||
|  |             return ExitCode::SUCCESS; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user