aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-09-30 11:21:13 -0400
committerJesse Luehrs <doy@tozt.net>2019-09-30 11:21:13 -0400
commit3ce894e84bc0a8edbe867e90437500c1042e38c9 (patch)
tree9252e23a164e7fa73112f5465e56863b261765b2 /src
parentf6fa62994d00c2f2959e0d5908210e8015351005 (diff)
downloadteleterm-3ce894e84bc0a8edbe867e90437500c1042e38c9.tar.gz
teleterm-3ce894e84bc0a8edbe867e90437500c1042e38c9.zip
make address configurable for casting too
Diffstat (limited to 'src')
-rw-r--r--src/cmd/watch.rs26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/cmd/watch.rs b/src/cmd/watch.rs
index 5cf4b38..4995047 100644
--- a/src/cmd/watch.rs
+++ b/src/cmd/watch.rs
@@ -31,24 +31,32 @@ pub type Result<T> = std::result::Result<T, Error>;
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
app.about("Watch termcast streams")
+ .arg(
+ clap::Arg::with_name("address")
+ .long("address")
+ .takes_value(true),
+ )
.arg(clap::Arg::with_name("id"))
}
pub fn run<'a>(matches: &clap::ArgMatches<'a>) -> super::Result<()> {
- run_impl(matches.value_of("id")).context(super::Watch)
+ run_impl(
+ matches.value_of("address").unwrap_or("127.0.0.1:8000"),
+ matches.value_of("id"),
+ )
+ .context(super::Watch)
}
-fn run_impl(id: Option<&str>) -> Result<()> {
+fn run_impl(address: &str, id: Option<&str>) -> Result<()> {
if let Some(id) = id {
- watch(id)
+ watch(address, id)
} else {
- list()
+ list(address)
}
}
-fn list() -> Result<()> {
- let sock =
- std::net::TcpStream::connect("127.0.0.1:8000").context(Connect)?;
+fn list(address: &str) -> Result<()> {
+ let sock = std::net::TcpStream::connect(address).context(Connect)?;
let term = std::env::var("TERM").unwrap_or_else(|_| "".to_string());
let msg = crate::protocol::Message::login("doy", &term);
msg.write(&sock).context(Write)?;
@@ -75,11 +83,11 @@ fn list() -> Result<()> {
Ok(())
}
-fn watch(id: &str) -> Result<()> {
+fn watch(address: &str, id: &str) -> Result<()> {
tokio::run(
WatchSession::new(
id,
- "127.0.0.1:8000",
+ address,
"doy",
std::time::Duration::from_secs(5),
)?