Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short flag, for terser output. Doesn't show command name or its a… #131

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions progress.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ signed char flag_throughput = 0;
signed char flag_monitor = 0;
signed char flag_monitor_continuous = 0;
signed char flag_open_mode = 0;
signed char flag_short = 0;
double throughput_wait_secs = 1;

WINDOW *mainwin;
Expand Down Expand Up @@ -508,10 +509,11 @@ static struct option long_options[] = {
{"pid", required_argument, 0, 'p'},
{"ignore-file", required_argument, 0, 'i'},
{"open-mode", required_argument, 0, 'o'},
{"short", no_argument, 0, 's'},
{0, 0, 0, 0}
};

static char *options_string = "vqdwmMha:c:p:W:i:o:";
static char *options_string = "svqdwmMha:c:p:W:i:o:";
int c,i;
int option_index = 0;
char *rp;
Expand Down Expand Up @@ -546,6 +548,7 @@ while(1) {
printf(" -W --wait-delay secs wait 'secs' seconds for I/O estimation (implies -w, default=%.1f)\n", throughput_wait_secs);
printf(" -m --monitor loop while monitored processes are still running\n");
printf(" -M --monitor-continuously like monitor but never stop (similar to watch %s)\n", argv[0]);
printf(" -s --short terser output, e.g. don't show command\n");
printf(" -a --additional-command cmd add additional command to default command list\n");
printf(" -c --command cmd monitor only this command name (ex: firefox)\n");
printf(" -p --pid id monitor only this process ID (ex: `pidof firefox`)\n");
Expand Down Expand Up @@ -610,6 +613,10 @@ while(1) {
flag_monitor_continuous = 1;
break;

case 's':
flag_short = 1;
break;

case 'W':
flag_throughput = 1;
throughput_wait_secs = atof(optarg);
Expand Down Expand Up @@ -847,13 +854,20 @@ for (i = 0 ; i < result_count ; i++) {

}

nprintf("[%5d] %s %s\n\t%.1f%% (%s / %s)",
results[i].pid.pid,
results[i].pid.name,
results[i].fd.name,
perc,
fpos,
fsize);
if (flag_short)
nprintf("[%5d] %.1f%% (%s / %s)",
results[i].pid.pid,
perc,
fpos,
fsize);
else
nprintf("[%5d] %s %s\n\t%.1f%% (%s / %s)",
results[i].pid.pid,
results[i].pid.name,
results[i].fd.name,
perc,
fpos,
fsize);

if (flag_throughput && still_there && !first_pass) {
// results[i] vs fdinfo
Expand All @@ -875,7 +889,10 @@ for (i = 0 ; i < result_count ; i++) {
}


nprintf("\n\n");
if (flag_short)
nprintf("\n");
else
nprintf("\n\n");

// Need to work on window width when using screen/watch/...
//~ printf(" [");
Expand Down