diff --git a/src/cli/cli.rs b/src/cli/cli.rs index 6e7892238b4f64d4fd77e962550d1451376270fa..6ed8e07173e94ba9dca83f75b92360ff0609a2f2 100644 --- a/src/cli/cli.rs +++ b/src/cli/cli.rs @@ -14,6 +14,8 @@ Options: -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 -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)] @@ -26,4 +28,6 @@ pub struct Args { pub flag_help: bool, pub flag_quiet: bool, pub flag_no_index: bool, + pub flag_upload: bool, + pub flag_upload_path: Option<String>, } \ No newline at end of file diff --git a/src/cli/config_file.rs b/src/cli/config_file.rs new file mode 100644 index 0000000000000000000000000000000000000000..538dac181bbe340ced756ea782f3e1d073f509c1 --- /dev/null +++ b/src/cli/config_file.rs @@ -0,0 +1,28 @@ +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 diff --git a/src/cli/mod.rs b/src/cli/mod.rs index c983ad56c981fc700a000ff721a54bad1a3dea92..3f293ea53beffc270f205de17388c2dd2332dbce 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,3 +1,5 @@ mod cli; +mod config_file; -pub use self::cli::{Args, USAGE}; \ No newline at end of file +pub use self::cli::{Args, USAGE}; +pub use self::config_file::{HandlerMethod, SwerveConfig}; \ No newline at end of file