diff options
| author | Reiner Herrmann <reiner@reiner-h.de> | 2019-08-29 21:48:44 +0200 |
|---|---|---|
| committer | Reiner Herrmann <reiner@reiner-h.de> | 2019-08-29 21:48:44 +0200 |
| commit | 16c6dd8f7116271508974d8acf04da1f1bf0afc9 (patch) | |
| tree | a530112274d4dcb77a65c37aa035341353acefb2 /src/tftpd.rs | |
| parent | 50e6a82f0955bf5d489d311f2c9600c379006c37 (diff) | |
Drop -d parameter and allow appending directory at end of command line
Diffstat (limited to 'src/tftpd.rs')
| -rw-r--r-- | src/tftpd.rs | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/tftpd.rs b/src/tftpd.rs index 5342145..102063d 100644 --- a/src/tftpd.rs +++ b/src/tftpd.rs @@ -306,7 +306,7 @@ fn usage(opts: &Options, program: &str, error: Option<String>) { println!("{}\n", err); } let version = rtftp::VERSION.unwrap_or(""); - println!("{}", opts.usage(format!("RusTFTP {}\n\n{} [options]", version, program).as_str())); + println!("{}", opts.usage(format!("RusTFTP {}\n\n{} [options] [directory]", version, program).as_str())); } fn parse_commandline(args: &[String]) -> Option<Configuration> { @@ -314,7 +314,6 @@ fn parse_commandline(args: &[String]) -> Option<Configuration> { let mut conf: Configuration = Default::default(); let mut opts = Options::new(); opts.optflag("h", "help", "display usage information"); - opts.optopt("d", "directory", "directory to serve (default: current directory)", "DIRECTORY"); opts.optopt("p", "port", format!("port to listen on (default: {})", conf.port).as_ref(), "PORT"); opts.optopt("u", "uid", format!("user id to run as (default: {})", conf.uid).as_ref(), "UID"); opts.optopt("g", "gid", format!("group id to run as (default: {})", conf.gid).as_ref(), "GID"); @@ -341,14 +340,8 @@ fn parse_commandline(args: &[String]) -> Option<Configuration> { usage(&opts, &program, Some(String::from("Only one of r (read-only) and w (write-only) allowed"))); return None; } - if matches.opt_present("d") { - conf.dir = match matches.opt_str("d") { - Some(d) => Path::new(&d).to_path_buf(), - None => { - usage(&opts, &program, None); - return None; - } - }; + if matches.free.len() > 0 { + conf.dir = Path::new(&matches.free[0]).to_path_buf(); } Some(conf) |
