1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2025-03-03 10:15:45 +00:00

(trunk) #3263 "cli-based utils' --help page should limit themselves to 80 columns"

This commit is contained in:
Charles Kerr 2010-06-16 14:05:18 +00:00
parent 82f0ec7413
commit 71c1919cfc
3 changed files with 48 additions and 16 deletions

View file

@ -68,7 +68,7 @@ static const struct tr_option options[] =
{ 'a', "allowed", "Allowed IP addresses. (Default: " TR_DEFAULT_RPC_WHITELIST ")", "a", 1, "<list>" },
{ 'b', "blocklist", "Enable peer blocklists", "b", 0, NULL },
{ 'B', "no-blocklist", "Disable peer blocklists", "B", 0, NULL },
{ 'c', "watch-dir", "Directory to watch for new .torrent files", "c", 1, "<directory>" },
{ 'c', "watch-dir", "Where to watch for new .torrent files", "c", 1, "<directory>" },
{ 'C', "no-watch-dir", "Disable the watch-dir", "C", 0, NULL },
{ 941, "incomplete-dir", "Where to store new torrents until they're complete", NULL, 1, "<directory>" },
{ 942, "no-incomplete-dir", "Don't store incomplete torrents in a different location", NULL, 0, NULL },
@ -96,9 +96,9 @@ static const struct tr_option options[] =
{ 910, "encryption-required", "Encrypt all peer connections", "er", 0, NULL },
{ 911, "encryption-preferred", "Prefer encrypted peer connections", "ep", 0, NULL },
{ 912, "encryption-tolerated", "Prefer unencrypted peer connections", "et", 0, NULL },
{ 'i', "bind-address-ipv4", "Where to listen for peer connections", "i", 1, "<ipv4 address>" },
{ 'I', "bind-address-ipv6", "Where to listen for peer connections", "I", 1, "<ipv6 address>" },
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ipv4 address>" },
{ 'i', "bind-address-ipv4", "Where to listen for peer connections", "i", 1, "<ipv4 addr>" },
{ 'I', "bind-address-ipv6", "Where to listen for peer connections", "I", 1, "<ipv6 addr>" },
{ 'r', "rpc-bind-address", "Where to listen for RPC connections", "r", 1, "<ipv4 addr>" },
{ 953, "global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed until a specific ratio", "gsr", 1, "ratio" },
{ 954, "no-global-seedratio", "All torrents, unless overridden by a per-torrent setting, should seed regardless of ratio", "GSR", 0, NULL },
{ 'x', "pid-file", "Enable PID file", "x", 1, "<pid-file>" },

View file

@ -221,24 +221,24 @@ static tr_option opts[] =
{ 961, "find", "Tell Transmission where to find a torrent's data", NULL, 1, "<path>" },
{ 'm', "portmap", "Enable portmapping via NAT-PMP or UPnP", "m", 0, NULL },
{ 'M', "no-portmap", "Disable portmapping", "M", 0, NULL },
{ 'n', "auth", "Set authentication info", "n", 1, "<user:pass>" },
{ 'N', "netrc", "Set authentication info from a .netrc file", "N", 1, "<filename>" },
{ 'n', "auth", "Set username and password", "n", 1, "<user:pw>" },
{ 'N', "netrc", "Set authentication info from a .netrc file", "N", 1, "<file>" },
{ 'o', "dht", "Enable distributed hash tables (DHT)", "o", 0, NULL },
{ 'O', "no-dht", "Disable distributed hash tables (DHT)", "O", 0, NULL },
{ 'p', "port", "Port for incoming peers (Default: " TR_DEFAULT_PEER_PORT_STR ")", "p", 1, "<port>" },
{ 962, "port-test", "Port testing", "pt", 0, NULL },
{ 'P', "random-port", "Random port for incomping peers", "P", 0, NULL },
{ 900, "priority-high", "Try to download the specified file(s) first", "ph", 1, "<files>" },
{ 901, "priority-normal", "Try to download the specified file(s) normally", "pn", 1, "<files>" },
{ 902, "priority-low", "Try to download the specified file(s) last", "pl", 1, "<files>" },
{ 900, "priority-high", "Try to download these file(s) first", "ph", 1, "<files>" },
{ 901, "priority-normal", "Try to download these file(s) normally", "pn", 1, "<files>" },
{ 902, "priority-low", "Try to download these file(s) last", "pl", 1, "<files>" },
{ 700, "bandwidth-high", "Give this torrent first chance at available bandwidth", "Bh", 0, NULL },
{ 701, "bandwidth-normal", "Give this torrent the bandwidth left over by high priority torrents", "Bn", 0, NULL },
{ 702, "bandwidth-low", "Give this torrent the bandwidth left over by high and normal priority torrents", "Bl", 0, NULL },
{ 701, "bandwidth-normal", "Give this torrent bandwidth left over by high priority torrents", "Bn", 0, NULL },
{ 702, "bandwidth-low", "Give this torrent bandwidth left over by high and normal priority torrents", "Bl", 0, NULL },
{ 'r', "remove", "Remove the current torrent(s)", "r", 0, NULL },
{ 930, "peers", "Set the maximum number of peers for the current torrent(s) or globally", "pr", 1, "<max>" },
{ 'R', "remove-and-delete", "Remove the current torrent(s) and delete local data", NULL, 0, NULL },
{ 800, "torrent-done-script", "Specify a script to run when a torrent finishes", NULL, 1, "<filename>" },
{ 801, "no-torrent-done-script", "Don't run a script when torrnets finish", NULL, 0, NULL },
{ 800, "torrent-done-script", "Specify a script to run when a torrent finishes", NULL, 1, "<file>" },
{ 801, "no-torrent-done-script", "Don't run a script when torrents finish", NULL, 0, NULL },
{ 950, "seedratio", "Let the current torrent(s) seed until a specific ratio", "sr", 1, "ratio" },
{ 951, "seedratio-default", "Let the current torrent(s) use the global seedratio settings", "srd", 0, NULL },
{ 952, "no-seedratio", "Let the current torrent(s) seed regardless of ratio", "SR", 0, NULL },

View file

@ -10,6 +10,7 @@
* $Id$
*/
#include <ctype.h> /* isspace() */
#include <stdio.h>
#include <stdlib.h> /* exit() */
#include <string.h>
@ -37,21 +38,52 @@ getArgName( const tr_option * opt )
return arg;
}
static int
get_next_line_len( const char * description, int maxlen )
{
int end;
int len = strlen( description );
if( len < maxlen )
return len;
end = maxlen < len ? maxlen : len;
while( ( end > 0 ) && !isspace( description[end] ) )
--end;
return end ? end : len;
}
static void
getopts_usage_line( const tr_option * opt,
int longWidth,
int shortWidth,
int argWidth )
{
int len;
const char * longName = opt->longName ? opt->longName : "";
const char * shortName = opt->shortName ? opt->shortName : "";
const char * arg = getArgName( opt );
printf( " %s%-*s %s%-*s %-*s %s\n",
const int d_indent = shortWidth + longWidth + argWidth + 7;
const int d_width = 80 - d_indent;
const char * d = opt->description;
printf( " %s%-*s %s%-*s %-*s ",
(shortName && *shortName ? "-" : " "), shortWidth, shortName,
(longName && *longName ? "--" : " "), longWidth, longName,
argWidth, arg,
opt->description );
argWidth, arg );
len = get_next_line_len( d, d_width );
printf( "%*.*s\n", len, len, d );
d += len;
while( isspace( *d ) ) ++d;
while(( len = get_next_line_len( d, d_width ))) {
printf( "%*.*s%*.*s\n", d_indent, d_indent, "", len, len, d );
d += len;
while( isspace( *d ) ) ++d;
}
}
static void