summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReiner Herrmann <reiner@reiner-h.de>2019-08-29 21:48:44 +0200
committerReiner Herrmann <reiner@reiner-h.de>2019-08-29 21:48:44 +0200
commit16c6dd8f7116271508974d8acf04da1f1bf0afc9 (patch)
treea530112274d4dcb77a65c37aa035341353acefb2
parent50e6a82f0955bf5d489d311f2c9600c379006c37 (diff)
Drop -d parameter and allow appending directory at end of command line
-rw-r--r--README4
-rw-r--r--src/tftpd.rs13
-rwxr-xr-xtest.sh2
3 files changed, 5 insertions, 14 deletions
diff --git a/README b/README
index 3045fcd..e6a5f44 100644
--- a/README
+++ b/README
@@ -39,12 +39,10 @@ Server:
$ ./rtftpd --help
RusTFTP
- ./rtftpd [options]
+ ./rtftpd [options] [directory]
Options:
-h, --help display usage information
- -d, --directory DIRECTORY
- directory to serve (default: current directory)
-p, --port PORT port to listen on (default: 69)
-u, --uid UID user id to run as (default: 65534)
-g, --gid GID group id to run as (default: 65534)
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)
diff --git a/test.sh b/test.sh
index 61fa6d0..7ee1800 100755
--- a/test.sh
+++ b/test.sh
@@ -52,7 +52,7 @@ tftpc() {
}
rtftpd() {
- $SSD --background --exec "$RTFTPD" --start -- -p $PORT -d "$SERVERDIR" 1>/dev/null
+ $SSD --background --exec "$RTFTPD" --start -- -p $PORT "$SERVERDIR" 1>/dev/null
}
rtftpc() {