Changeset 4511ac3 for commands.c


Ignore:
Timestamp:
Aug 5, 2017, 11:21:53 PM (7 years ago)
Author:
Jason Gross <jasongross9@gmail.com>
Branches:
master
Children:
253f37f
Parents:
565a43c
git-author:
Jason Gross <jgross@mit.edu> (08/05/17 22:06:52)
git-committer:
Jason Gross <jasongross9@gmail.com> (08/05/17 23:21:53)
Message:
Better UI for :flush-logs and flush-logs-interval

We now only print the message about how many logs there are to flush
when -q is not passed to :flush-logs.  The timer from
flush-logs-interval passes -q, so the user won't see "There are no logs
to flush." ever few minutes.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • commands.c

    r77beb3c r4511ac3  
    490490  OWLCMD_ARGS("flush-logs", owl_command_flushlogs, OWL_CTX_ANY,
    491491              "flush the queue of messages waiting to be logged",
    492               "flush-logs [-f | --force]",
     492              "flush-logs [-f | --force] [-q | --quiet]",
    493493              "If BarnOwl failed to log a file, this command tells\n"
    494494              "BarnOwl to try logging the messages that have since\n"
     
    501501              "any messages on the queue which cannot successfully be\n"
    502502              "logged are dropped, and BarnOwl will resume logging\n"
    503               "normally."),
     503              "normally.\n"
     504              "\n"
     505              "Unless --quiet is passed, a message is printed about\n"
     506              "how many logs there are to flush."),
    504507
    505508  OWLCMD_ARGS("load-subs", owl_command_loadsubs, OWL_CTX_ANY,
     
    14541457char *owl_command_flushlogs(int argc, const char *const *argv, const char *buff)
    14551458{
    1456   if (argc == 1) {
    1457     owl_log_flush_logs(false);
    1458   } else if (argc == 2) {
    1459     if (!strcmp(argv[1], "-f") || !strcmp(argv[1], "--force")) {
    1460       owl_log_flush_logs(true);
     1459  bool force = false;
     1460  bool quiet = false;
     1461  int i;
     1462
     1463  for (i = 1; i < argc; i++) {
     1464    if (!strcmp(argv[i], "-f") || !strcmp(argv[i], "--force")) {
     1465      force = true;
     1466    } else if (!strcmp(argv[i], "-q") || !strcmp(argv[i], "--quiet")) {
     1467      quiet = true;
    14611468    } else {
    1462       owl_function_makemsg("Invalid flag to flush-logs: %s", argv[1]);
     1469      owl_function_makemsg("Invalid flag to flush-logs: %s", argv[i]);
    14631470    }
    1464   } else {
    1465     owl_function_makemsg("Wrong number of arguments for flush-logs.");
    1466   }
     1471  }
     1472  owl_log_flush_logs(force, quiet);
    14671473  return NULL;
    14681474}
Note: See TracChangeset for help on using the changeset viewer.