Better help, readme
This commit is contained in:
		
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							| @ -8,3 +8,21 @@ TODO: | |||||||
| * Gather info about the client (IP, User-Agent, etc) to do funny stuff with it => Just printing client's adress for now | * Gather info about the client (IP, User-Agent, etc) to do funny stuff with it => Just printing client's adress for now | ||||||
| * Use arguments => Done, clap is very very nice ! | * Use arguments => Done, clap is very very nice ! | ||||||
| * Not satisfied with the way root_folder is handled, being passed on from one function to another. | * Not satisfied with the way root_folder is handled, being passed on from one function to another. | ||||||
|  |  | ||||||
|  | # Usage | ||||||
|  | ``` | ||||||
|  | A simple web server. Conf file must be  toml or ini. Example:  | ||||||
|  |  | ||||||
|  |         threads = 10 | ||||||
|  |         bind_addr = "0.0.0.0:7878" | ||||||
|  |         root_folder = "/my/web/site" | ||||||
|  |  | ||||||
|  | Usage: ssw -c <CONF_FILE> | ||||||
|  |  | ||||||
|  | Options: | ||||||
|  |   -c <CONF_FILE> | ||||||
|  |            | ||||||
|  |  | ||||||
|  |   -h, --help | ||||||
|  |           Print help information (use `-h` for a summary) | ||||||
|  | ``` | ||||||
|  | |||||||
							
								
								
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								src/main.rs
									
									
									
									
									
								
							| @ -8,7 +8,6 @@ use std::{ | |||||||
|     collections::HashMap, |     collections::HashMap, | ||||||
|     fmt, |     fmt, | ||||||
|     thread, |     thread, | ||||||
|     env, |  | ||||||
| }; | }; | ||||||
| use config::Config; | use config::Config; | ||||||
| use clap::Parser; | use clap::Parser; | ||||||
| @ -18,8 +17,12 @@ use clap::Parser; | |||||||
| #[command(name = "ssw")] | #[command(name = "ssw")] | ||||||
| #[command(author = None)] | #[command(author = None)] | ||||||
| #[command(about = "A simple web server. Pass a configuration file with -c.")] | #[command(about = "A simple web server. Pass a configuration file with -c.")] | ||||||
|  | #[command(long_about = "A simple web server. Conf file must be  toml or ini. Example: \n | ||||||
|  |         threads = 10 | ||||||
|  |         bind_addr = \"0.0.0.0:7878\" | ||||||
|  |         root_folder = \"/my/web/site\"")] | ||||||
| struct Args { | struct Args { | ||||||
|     #[arg(short, long)] |     #[arg(short)] | ||||||
|     conf_file: String, |     conf_file: String, | ||||||
| } | } | ||||||
|  |  | ||||||
| @ -205,11 +208,6 @@ fn handle_connection(mut stream: TcpStream, root_folder: &str) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| fn get_args() -> Vec<String> { |  | ||||||
|     let args: Vec<String> = env::args().collect(); |  | ||||||
|     return args; |  | ||||||
| } |  | ||||||
|  |  | ||||||
| fn main() { | fn main() { | ||||||
|     let args = Args::parse(); |     let args = Args::parse(); | ||||||
|     println!("Hello {}!", args.conf_file); |     println!("Hello {}!", args.conf_file); | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user