Skip to content
Snippets Groups Projects
Unverified Commit b4b1fd82 authored by Louis's avatar Louis :fire:
Browse files

Support --upload and --upload-path flags in arg parser, implement mock config file

parent 658d76d7
No related branches found
No related tags found
No related merge requests found
...@@ -14,6 +14,8 @@ Options: ...@@ -14,6 +14,8 @@ Options:
-a=<addr>, --address=<addr> Address to bind to (e.g. 10.0.0.15); defaults to localhost -a=<addr>, --address=<addr> Address to bind to (e.g. 10.0.0.15); defaults to localhost
-c=<path>, --config=<path> Path to the .swerve config file -c=<path>, --config=<path> Path to the .swerve config file
-t=<num>, --threads=<num> Number of worker threads to use for serving files; defaults to 32 -t=<num>, --threads=<num> Number of worker threads to use for serving files; defaults to 32
-u, --upload Support file uploads to '/upload'
-U=<path>, --upload-path=<path> Set the url path that will accept file uploads. Implies -u if not present
"; ";
#[derive(Debug, Deserialize, Clone)] #[derive(Debug, Deserialize, Clone)]
...@@ -26,4 +28,6 @@ pub struct Args { ...@@ -26,4 +28,6 @@ pub struct Args {
pub flag_help: bool, pub flag_help: bool,
pub flag_quiet: bool, pub flag_quiet: bool,
pub flag_no_index: bool, pub flag_no_index: bool,
pub flag_upload: bool,
pub flag_upload_path: Option<String>,
} }
\ No newline at end of file
use std::path::Path;
use std::convert::AsRef;
use std::io::prelude::*;
use std::io;
use std::fs::File;
pub enum HandlerMethod {
Log,
File,
}
pub struct SwerveConfig {
pub field_handling: HandlerMethod,
pub file_handling: HandlerMethod,
}
impl SwerveConfig {
pub fn from_file<P>(path: P) -> io::Result<SwerveConfig> where P: AsRef<Path> {
// let mut file = File::open(path)?;
// let mut buffer = String::new();
// file.read_to_string(buffer)?;
Ok(SwerveConfig {
field_handling: HandlerMethod::Log,
file_handling: HandlerMethod::Log,
})
}
}
\ No newline at end of file
mod cli; mod cli;
mod config_file;
pub use self::cli::{Args, USAGE}; pub use self::cli::{Args, USAGE};
\ No newline at end of file pub use self::config_file::{HandlerMethod, SwerveConfig};
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment