aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-20 00:46:33 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-20 00:52:52 -0400
commitcead6e8872e7312284031feee81d91102656fc7d (patch)
tree234a9785bbaaad1be87e6327b9e244c72a8de90a
parentfabf5bf86b3f7d63d9a47c12f91b756d67ea7f7c (diff)
downloadteleterm-cead6e8872e7312284031feee81d91102656fc7d.tar.gz
teleterm-cead6e8872e7312284031feee81d91102656fc7d.zip
also move the flag definitions into the config reader
-rw-r--r--src/cmd/play.rs6
-rw-r--r--src/cmd/record.rs16
-rw-r--r--src/cmd/server.rs28
-rw-r--r--src/cmd/stream.rs27
-rw-r--r--src/cmd/watch.rs18
-rw-r--r--src/config.rs65
6 files changed, 74 insertions, 86 deletions
diff --git a/src/cmd/play.rs b/src/cmd/play.rs
index 7eae765..2e41816 100644
--- a/src/cmd/play.rs
+++ b/src/cmd/play.rs
@@ -24,11 +24,7 @@ impl crate::config::Config for Config {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app.about("Play recorded terminal sessions").arg(
- clap::Arg::with_name("filename")
- .long("filename")
- .takes_value(true),
- )
+ crate::config::Ttyrec::cmd(app.about("Play recorded terminal sessions"))
}
pub fn config(config: config::Config) -> Box<dyn crate::config::Config> {
diff --git a/src/cmd/record.rs b/src/cmd/record.rs
index 3e19ed8..f36f161 100644
--- a/src/cmd/record.rs
+++ b/src/cmd/record.rs
@@ -32,19 +32,9 @@ impl crate::config::Config for Config {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app.about("Record a terminal session to a file")
- .arg(
- clap::Arg::with_name("filename")
- .long("filename")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("buffer-size")
- .long("buffer-size")
- .takes_value(true),
- )
- .arg(clap::Arg::with_name("command").index(1))
- .arg(clap::Arg::with_name("args").index(2).multiple(true))
+ crate::config::Command::cmd(crate::config::Ttyrec::cmd(
+ app.about("Record a terminal session to a file"),
+ ))
}
pub fn config(config: config::Config) -> Box<dyn crate::config::Config> {
diff --git a/src/cmd/server.rs b/src/cmd/server.rs
index ea238ba..6a937c7 100644
--- a/src/cmd/server.rs
+++ b/src/cmd/server.rs
@@ -46,33 +46,7 @@ impl crate::config::Config for Config {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app.about("Run a teleterm server")
- .arg(
- clap::Arg::with_name("address")
- .long("address")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("buffer-size")
- .long("buffer-size")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("read-timeout")
- .long("read-timeout")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("tls-identity-file")
- .long("tls-identity-file")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("allowed-login-methods")
- .long("allowed-login-methods")
- .use_delimiter(true)
- .takes_value(true),
- )
+ crate::config::Server::cmd(app.about("Run a teleterm server"))
}
pub fn config(config: config::Config) -> Box<dyn crate::config::Config> {
diff --git a/src/cmd/stream.rs b/src/cmd/stream.rs
index 14f4fac..e013660 100644
--- a/src/cmd/stream.rs
+++ b/src/cmd/stream.rs
@@ -86,30 +86,9 @@ impl crate::config::Config for Config {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app.about("Stream your terminal")
- .arg(
- clap::Arg::with_name("login-plain")
- .long("login-plain")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("login-recurse-center")
- .long("login-recurse-center")
- .conflicts_with("login-plain"),
- )
- .arg(
- clap::Arg::with_name("address")
- .long("address")
- .takes_value(true),
- )
- .arg(clap::Arg::with_name("tls").long("tls"))
- .arg(
- clap::Arg::with_name("buffer-size")
- .long("buffer-size")
- .takes_value(true),
- )
- .arg(clap::Arg::with_name("command").index(1))
- .arg(clap::Arg::with_name("args").index(2).multiple(true))
+ crate::config::Client::cmd(crate::config::Command::cmd(
+ app.about("Stream your terminal"),
+ ))
}
pub fn config(config: config::Config) -> Box<dyn crate::config::Config> {
diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs
index 62ef2e0..4bf9fdd 100644
--- a/src/cmd/watch.rs
+++ b/src/cmd/watch.rs
@@ -82,23 +82,7 @@ impl crate::config::Config for Config {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
- app.about("Watch teleterm streams")
- .arg(
- clap::Arg::with_name("login-plain")
- .long("login-plain")
- .takes_value(true),
- )
- .arg(
- clap::Arg::with_name("login-recurse-center")
- .long("login-recurse-center")
- .conflicts_with("login-plain"),
- )
- .arg(
- clap::Arg::with_name("address")
- .long("address")
- .takes_value(true),
- )
- .arg(clap::Arg::with_name("tls").long("tls"))
+ crate::config::Client::cmd(app.about("Watch teleterm streams"))
}
pub fn config(config: config::Config) -> Box<dyn crate::config::Config> {
diff --git a/src/config.rs b/src/config.rs
index 8fc2596..d3352d9 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -70,6 +70,25 @@ impl Client {
&self.connect_address.1
}
+ pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ app.arg(
+ clap::Arg::with_name("login-plain")
+ .long("login-plain")
+ .takes_value(true),
+ )
+ .arg(
+ clap::Arg::with_name("login-recurse-center")
+ .long("login-recurse-center")
+ .conflicts_with("login-plain"),
+ )
+ .arg(
+ clap::Arg::with_name("address")
+ .long("address")
+ .takes_value(true),
+ )
+ .arg(clap::Arg::with_name("tls").long("tls"))
+ }
+
pub fn merge_args<'a>(
&mut self,
matches: &clap::ArgMatches<'a>,
@@ -192,6 +211,35 @@ pub struct Server {
}
impl Server {
+ pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ app.arg(
+ clap::Arg::with_name("address")
+ .long("address")
+ .takes_value(true),
+ )
+ .arg(
+ clap::Arg::with_name("buffer-size")
+ .long("buffer-size")
+ .takes_value(true),
+ )
+ .arg(
+ clap::Arg::with_name("read-timeout")
+ .long("read-timeout")
+ .takes_value(true),
+ )
+ .arg(
+ clap::Arg::with_name("tls-identity-file")
+ .long("tls-identity-file")
+ .takes_value(true),
+ )
+ .arg(
+ clap::Arg::with_name("allowed-login-methods")
+ .long("allowed-login-methods")
+ .use_delimiter(true)
+ .takes_value(true),
+ )
+ }
+
pub fn merge_args<'a>(
&mut self,
matches: &clap::ArgMatches<'a>,
@@ -358,6 +406,15 @@ pub struct Command {
}
impl Command {
+ pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ app.arg(
+ clap::Arg::with_name("buffer-size")
+ .long("buffer-size")
+ .takes_value(true),
+ )
+ .arg(clap::Arg::with_name("command").index(1))
+ .arg(clap::Arg::with_name("args").index(2).multiple(true))
+ }
pub fn merge_args<'a>(
&mut self,
matches: &clap::ArgMatches<'a>,
@@ -407,6 +464,14 @@ pub struct Ttyrec {
}
impl Ttyrec {
+ pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ app.arg(
+ clap::Arg::with_name("filename")
+ .long("filename")
+ .takes_value(true),
+ )
+ }
+
pub fn merge_args<'a>(
&mut self,
matches: &clap::ArgMatches<'a>,