aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2019-10-21 03:11:56 -0400
committerJesse Luehrs <doy@tozt.net>2019-10-21 03:11:56 -0400
commit9fe57eb08616e70344a80f40a5333e1946dc2ed8 (patch)
treea7263b86b365a7a8425ff20969987b52dc20c64a
parent5b24e8972b1749f05907441ca2dbbcb72188dcfa (diff)
downloadteleterm-9fe57eb08616e70344a80f40a5333e1946dc2ed8.tar.gz
teleterm-9fe57eb08616e70344a80f40a5333e1946dc2ed8.zip
improve usage information
-rw-r--r--Cargo.lock13
-rw-r--r--Cargo.toml2
-rw-r--r--src/cmd.rs14
-rw-r--r--src/config.rs77
4 files changed, 89 insertions, 17 deletions
diff --git a/Cargo.lock b/Cargo.lock
index be1d369..cfed453 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -162,6 +162,7 @@ dependencies = [
"atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)",
"bitflags 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"strsim 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
"vec_map 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1623,6 +1624,16 @@ dependencies = [
]
[[package]]
+name = "term_size"
+version = "0.3.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+dependencies = [
+ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.62 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
+]
+
+[[package]]
name = "termcolor"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1635,6 +1646,7 @@ name = "textwrap"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
+ "term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"unicode-width 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -2272,6 +2284,7 @@ dependencies = [
"checksum syn 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "66850e97125af79138385e9b88339cbcd037e3f28ceab8c5ad98e64f0f1f80bf"
"checksum synstructure 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3f085a5855930c0441ca1288cf044ea4aecf4f43a91668abdb870b4ba546a203"
"checksum tempfile 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7a6e24d9338a0a5be79593e2fa15a648add6138caa803e2d5bc782c371732ca9"
+"checksum term_size 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "9e5b9a66db815dcfd2da92db471106457082577c3c278d4138ab3e3b4e189327"
"checksum termcolor 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)" = "96d6098003bde162e4277c70665bd87c326f5a0c3f3fbfb285787fa482d54e6e"
"checksum textwrap 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060"
"checksum thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "c6b53e329000edc2b34dbe8545fd20e55a333362d0a321909685a19bd28c3f1b"
diff --git a/Cargo.toml b/Cargo.toml
index b04deea..b539e88 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,7 +13,7 @@ license = "MIT"
[dependencies]
bytes = "0.4"
-clap = "2"
+clap = { version = "2", features = ["wrap_help"] }
config = "0.9"
crossterm = "0.11"
directories = "2"
diff --git a/src/cmd.rs b/src/cmd.rs
index fb785bc..8861fb9 100644
--- a/src/cmd.rs
+++ b/src/cmd.rs
@@ -56,12 +56,20 @@ pub fn parse<'a>() -> Result<clap::ArgMatches<'a>> {
.arg(
clap::Arg::with_name("config-file")
.long("config-file")
- .takes_value(true),
- );
+ .takes_value(true)
+ .value_name("FILE")
+ .help("Read configuration from FILE"),
+ )
+ .global_setting(clap::AppSettings::DontCollapseArgsInUsage)
+ .global_setting(clap::AppSettings::GlobalVersion)
+ .global_setting(clap::AppSettings::UnifiedHelpMessage)
+ .global_setting(clap::AppSettings::VersionlessSubcommands);
for cmd in COMMANDS {
let subcommand = clap::SubCommand::with_name(cmd.name);
- app = app.subcommand((cmd.cmd)(subcommand));
+ app = app.subcommand(
+ (cmd.cmd)(subcommand).setting(clap::AppSettings::NextLineHelp),
+ );
}
app.get_matches_safe().context(crate::error::ParseArgs)
diff --git a/src/config.rs b/src/config.rs
index 6c47a71..c626afe 100644
--- a/src/config.rs
+++ b/src/config.rs
@@ -94,22 +94,38 @@ impl Client {
}
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ let login_plain_help = "Use the 'plain' authentication method (default), with username USERNAME (defaults to $USER)";
+ let login_recurse_center_help =
+ "Use the 'recurse_center' authentication method";
+ let connect_address_help =
+ "Host and port to connect to (defaults to localhost:4144)";
+ let tls_help = "Connect to the server using TLS";
+
app.arg(
clap::Arg::with_name(LOGIN_PLAIN_OPTION)
.long(LOGIN_PLAIN_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("USERNAME")
+ .help(login_plain_help),
)
.arg(
clap::Arg::with_name(LOGIN_RECURSE_CENTER_OPTION)
.long(LOGIN_RECURSE_CENTER_OPTION)
- .conflicts_with(LOGIN_PLAIN_OPTION),
+ .conflicts_with(LOGIN_PLAIN_OPTION)
+ .help(login_recurse_center_help),
)
.arg(
clap::Arg::with_name(CONNECT_ADDRESS_OPTION)
.long(CONNECT_ADDRESS_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("HOST:PORT")
+ .help(connect_address_help),
+ )
+ .arg(
+ clap::Arg::with_name(TLS_OPTION)
+ .long(TLS_OPTION)
+ .help(tls_help),
)
- .arg(clap::Arg::with_name(TLS_OPTION).long(TLS_OPTION))
}
pub fn merge_args<'a>(
@@ -241,31 +257,47 @@ pub struct Server {
impl Server {
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ let listen_address_help =
+ "Host and port to listen on (defaults to localhost:4144)";
+ let buffer_size_help = "Number of bytes to store for each connection in order to send them to newly connected watchers (defaults to 4194304)";
+ let read_timeout_help = "Number of idle seconds to wait before disconnecting a client (defaults to 30)";
+ let tls_identity_file_help = "File containing the TLS certificate and private key to use for accepting TLS connections. Must be in pfx format. The server will only allow connections over TLS if this option is set.";
+ let allowed_login_methods_help = "Comma separated list containing the auth methods this server should allow. Allows everything by default, valid values are plain, recurse_center";
app.arg(
clap::Arg::with_name(LISTEN_ADDRESS_OPTION)
.long(LISTEN_ADDRESS_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("HOST:PORT")
+ .help(listen_address_help),
)
.arg(
clap::Arg::with_name(BUFFER_SIZE_OPTION)
.long(BUFFER_SIZE_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("BYTES")
+ .help(buffer_size_help),
)
.arg(
clap::Arg::with_name(READ_TIMEOUT_OPTION)
.long(READ_TIMEOUT_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("SECS")
+ .help(read_timeout_help),
)
.arg(
clap::Arg::with_name(TLS_IDENTITY_FILE_OPTION)
.long(TLS_IDENTITY_FILE_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("FILE")
+ .help(tls_identity_file_help),
)
.arg(
clap::Arg::with_name(ALLOWED_LOGIN_METHODS_OPTION)
.long(ALLOWED_LOGIN_METHODS_OPTION)
.use_delimiter(true)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("AUTH_METHODS")
+ .help(allowed_login_methods_help),
)
}
@@ -552,13 +584,28 @@ pub struct Command {
impl Command {
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ let buffer_size_help = "Max number of bytes to buffer in order to be able to resend them when reconnecting to the server (defaults to 4194304)";
+ let command_help = "Command to run";
+ let args_help = "Arguments for the command";
+
app.arg(
clap::Arg::with_name(BUFFER_SIZE_OPTION)
.long(BUFFER_SIZE_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("BYTES")
+ .help(buffer_size_help),
+ )
+ .arg(
+ clap::Arg::with_name(COMMAND_OPTION)
+ .index(1)
+ .help(command_help),
+ )
+ .arg(
+ clap::Arg::with_name(ARGS_OPTION)
+ .index(2)
+ .multiple(true)
+ .help(args_help),
)
- .arg(clap::Arg::with_name(COMMAND_OPTION).index(1))
- .arg(clap::Arg::with_name(ARGS_OPTION).index(2).multiple(true))
}
pub fn merge_args<'a>(
&mut self,
@@ -611,10 +658,14 @@ pub struct Ttyrec {
impl Ttyrec {
pub fn cmd<'a, 'b>(app: clap::App<'a, 'b>) -> clap::App<'a, 'b> {
+ let filename_help =
+ "TTYrec file to use (defaults to teleterm.ttyrec)";
app.arg(
clap::Arg::with_name(FILENAME_OPTION)
.long(FILENAME_OPTION)
- .takes_value(true),
+ .takes_value(true)
+ .value_name("FILE")
+ .help(filename_help),
)
}