feat: Add basename support
Now, the user can decide to show only the program name, instead of the full program path. It is useful, when you have a very long hierarchy of directories, which, with the full path name, the user might not see the program name.
This commit is contained in:
committed by
Matheus Rambo
parent
82a30bb644
commit
b94cd9f227
@@ -27,7 +27,7 @@ static void help(bool iserror) {
|
||||
// output << "usage: nethogs [-V] [-b] [-d seconds] [-t] [-p] [-f (eth|ppp))]
|
||||
// [device [device [device ...]]]\n";
|
||||
output << "usage: nethogs [-V] [-h] [-x] [-d seconds] [-v mode] [-c count] "
|
||||
"[-t] [-p] [-s] [-a] [-l] [-f filter] [-C]"
|
||||
"[-t] [-p] [-s] [-a] [-l] [-f filter] [-C] [-b]"
|
||||
"[device [device [device ...]]]\n";
|
||||
output << " -V : prints version.\n";
|
||||
output << " -h : prints this help.\n";
|
||||
@@ -48,6 +48,7 @@ static void help(bool iserror) {
|
||||
output << " -C : capture TCP and UDP.\n";
|
||||
output << " -g : garbage collection period in number of refresh. "
|
||||
"default is 50.\n";
|
||||
output << " -b : Short program name. Displays only the program name.\n";
|
||||
output << " -f : EXPERIMENTAL: specify string pcap filter (like "
|
||||
"tcpdump)."
|
||||
" This may be removed or changed in a future version.\n";
|
||||
@@ -59,6 +60,7 @@ static void help(bool iserror) {
|
||||
output << " s: sort by SENT traffic\n";
|
||||
output << " r: sort by RECEIVED traffic\n";
|
||||
output << " l: display command line\n";
|
||||
output << " b: display the program basename instead of the fullpath\n";
|
||||
output << " m: switch between total (KB, B, MB) and throughput (KB/s, MB/s, "
|
||||
"GB/s) mode\n";
|
||||
}
|
||||
@@ -145,7 +147,7 @@ int main(int argc, char **argv) {
|
||||
int garbage_collection_period = 50;
|
||||
|
||||
int opt;
|
||||
while ((opt = getopt(argc, argv, "Vhxtpsd:v:c:laf:Cg:")) != -1) {
|
||||
while ((opt = getopt(argc, argv, "Vhxtpsd:v:c:laf:Cbg:")) != -1) {
|
||||
switch (opt) {
|
||||
case 'V':
|
||||
versiondisplay();
|
||||
@@ -187,6 +189,9 @@ int main(int argc, char **argv) {
|
||||
case 'C':
|
||||
catchall = true;
|
||||
break;
|
||||
case 'b':
|
||||
showBasename = true;
|
||||
break;
|
||||
case 'g':
|
||||
garbage_collection_period = (time_t)atoi(optarg);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user