diff --git a/docs/rmlint.1.rst b/docs/rmlint.1.rst index 73f3acbd..a8426638 100644 --- a/docs/rmlint.1.rst +++ b/docs/rmlint.1.rst @@ -105,7 +105,7 @@ General Options $ rmlint -T "df,dd" # Only search for duplicate files and directories $ rmlint -T "all -df -dd" # Search for all lint except duplicate files and dirs. -:``-o --output=spec`` / ``-O --add-output=spec`` (**default\:** *-o sh\:rmlint.sh -o pretty\:stdout -o summary\:stdout -o json\:rmlint.json*): +:``-o --output=spec`` / ``-O --add-output=spec`` (**default\:** *-o sh\:rmlint.sh -o pretty -o summary -o json\:rmlint.json*): Configure the way ``rmlint`` outputs its results. A ``spec`` is in the form ``format:file`` or just ``format``. A ``file`` might either be an @@ -207,10 +207,7 @@ General Options Show a progressbar with sane defaults. - Convenience shortcut for ``-o progressbar -o summary -o sh:rmlint.sh -o json:rmlint.json -VV``. - - NOTE: This flag clears all previous outputs. If you want additional - outputs, specify them after this flag using ``-O``. + Turns off the default ``-o pretty`` and enables ``-O progressbar -VV``. :``-D --merge-directories`` (**default\:** *disabled*): diff --git a/lib/cmdline.c b/lib/cmdline.c index 49c81627..dac95dcf 100644 --- a/lib/cmdline.c +++ b/lib/cmdline.c @@ -732,23 +732,15 @@ static gboolean rm_cmd_parse_clamp_top(_UNUSED const char *option_name, const gc return (error && *error == NULL); } -static gboolean rm_cmd_parse_progress(_UNUSED const char *option_name, - _UNUSED const gchar *value, RmSession *session, - _UNUSED GError **error) { - rm_fmt_remove_by_name(session->formats, "pretty"); - - rm_fmt_add(session->formats, "progressbar", "stdout"); - rm_fmt_add(session->formats, "summary", "stdout"); - - session->cfg->progress_enabled = true; - - return true; -} - static void rm_cmd_set_default_outputs(RmSession *session) { - rm_fmt_add(session->formats, "pretty", "stdout"); rm_fmt_add(session->formats, "summary", "stdout"); + if(session->cfg->progress_enabled) { + rm_fmt_add(session->formats, "progressbar", "stdout"); + } else { + rm_fmt_add(session->formats, "pretty", "stdout"); + } + if(session->cfg->replay) { rm_fmt_add(session->formats, "sh", "rmlint.replay.sh"); rm_fmt_add(session->formats, "json", "rmlint.replay.json"); @@ -758,14 +750,6 @@ static void rm_cmd_set_default_outputs(RmSession *session) { } } -static gboolean rm_cmd_parse_no_progress(_UNUSED const char *option_name, - _UNUSED const gchar *value, RmSession *session, - _UNUSED GError **error) { - rm_fmt_clear(session->formats); - rm_cmd_set_default_outputs(session); - return true; -} - static gboolean rm_cmd_parse_paranoid(_UNUSED const char *option_name, _UNUSED const gchar *count, RmSession *session, _UNUSED GError **error) { @@ -1064,7 +1048,7 @@ static bool rm_cmd_set_outputs(RmSession *session, GError **error) { g_set_error(error, RM_ERROR_QUARK, 0, _("Specifying both -o and -O is not allowed")); return false; - } else if(session->output_cnt[0] < 0 && session->cfg->progress_enabled == false) { + } else if(session->output_cnt[0] < 0) { rm_cmd_set_default_outputs(session); } @@ -1126,13 +1110,13 @@ bool rm_cmd_parse_args(int argc, char **argv, RmSession *session) { {"xattr" , 'C' , EMPTY , G_OPTION_ARG_CALLBACK , FUNC(xattr) , _("Enable xattr based caching") , ""} , /* Non-trivial switches */ - {"progress" , 'g' , EMPTY , G_OPTION_ARG_CALLBACK , FUNC(progress) , _("Enable progressbar") , NULL} , {"loud" , 'v' , EMPTY , G_OPTION_ARG_CALLBACK , rm_logger_louder , _("Be more verbose (-vv for much more)") , NULL} , {"quiet" , 'V' , EMPTY , G_OPTION_ARG_CALLBACK , rm_logger_quieter , _("Be less verbose (-VV for much less)") , NULL} , {"replay" , 'Y' , 0 , G_OPTION_ARG_CALLBACK , FUNC(replay) , _("Re-output a json file") , "path/to/rmlint.json"} , {"equal" , 0 , EMPTY , G_OPTION_ARG_CALLBACK , FUNC(equal) , _("Test for equality of PATHS") , "PATHS"} , /* Trivial boolean options */ + {"progress" , 'g' , 0 , G_OPTION_ARG_NONE , &cfg->progress_enabled , _("Enable progressbar") , NULL} , {"no-with-color" , 'W' , DISABLE , G_OPTION_ARG_NONE , &cfg->with_color , _("Be not that colorful") , NULL} , {"hidden" , 'r' , EMPTY , G_OPTION_ARG_CALLBACK , FUNC(hidden) , _("Find hidden files") , NULL} , {"followlinks" , 'f' , EMPTY , G_OPTION_ARG_CALLBACK , FUNC(follow_symlinks) , _("Follow symlinks") , NULL} , @@ -1186,7 +1170,7 @@ bool rm_cmd_parse_args(int argc, char **argv, RmSession *session) { {"no-match-extension" , 'E' , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->match_with_extension , "Disable --match-extension" , NULL} , {"no-match-extension" , 'E' , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->match_with_extension , "Disable --match-extension" , NULL} , {"no-match-without-extension" , 'I' , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->match_without_extension , "Disable --match-without-extension" , NULL} , - {"no-progress" , 'G' , EMPTY | HIDDEN , G_OPTION_ARG_CALLBACK , FUNC(no_progress) , "Disable progressbar" , NULL} , + {"no-progress" , 'G' , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->progress_enabled , "Disable progressbar" , NULL} , {"no-xattr-read" , 0 , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->read_cksum_from_xattr , "Disable --xattr-read" , NULL} , {"no-xattr-write" , 0 , DISABLE | HIDDEN , G_OPTION_ARG_NONE , &cfg->write_cksum_to_xattr , "Disable --xattr-write" , NULL} , {"no-partial-hidden" , 0 , EMPTY | HIDDEN , G_OPTION_ARG_CALLBACK , FUNC(no_partial_hidden) , "Invert --partial-hidden" , NULL} , @@ -1322,16 +1306,6 @@ bool rm_cmd_parse_args(int argc, char **argv, RmSession *session) { _("will also disable --merge-directories and trigger this warning.")); } - if(cfg->progress_enabled) { - if(!rm_fmt_has_formatter(session->formats, "sh")) { - rm_fmt_add(session->formats, "sh", "rmlint.sh"); - } - - if(!rm_fmt_has_formatter(session->formats, "json")) { - rm_fmt_add(session->formats, "json", "rmlint.json"); - } - } - /* Overwrite color if we do not print to a terminal directly */ if(cfg->with_color) { cfg->with_stdout_color = isatty(fileno(stdout)); diff --git a/lib/formats.c b/lib/formats.c index 898a531c..dca8e67c 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -150,27 +150,6 @@ bool rm_fmt_is_valid_key(RmFmtTable *self, const char *formatter, const char *ke return false; } -void rm_fmt_remove_by_name(RmFmtTable *self, char *name) { - GQueue deleted_iters = G_QUEUE_INIT; - for(GList *iter = self->handler_order->head; iter; iter = iter->next) { - RmFmtHandler *handler = iter->data; - if(!g_str_equal(handler->name, name)) { - continue; - } - - g_hash_table_remove(self->handler_to_file, handler); - g_hash_table_remove(self->path_to_handler, handler->path); - g_queue_push_tail(&deleted_iters, iter); - } - - for(GList *iter = deleted_iters.head; iter; iter = iter->next) { - g_queue_delete_link(self->handler_order, iter); - } - - // Since we removed all handlers - g_hash_table_remove(self->handler_set, name); -} - // NOTE: This is the same as g_date_time_format_iso8601. // It is only copied here because it is only available since // GLib 2.62. Remove this in a few years (written as of end 2019) diff --git a/lib/formats.h b/lib/formats.h index 2daa5651..781729d7 100644 --- a/lib/formats.h +++ b/lib/formats.h @@ -261,11 +261,6 @@ bool rm_fmt_is_stream(RmFmtTable *self, RmFmtHandler *handler); */ bool rm_fmt_has_formatter(RmFmtTable *self, const char *name); -/** - * @brief Remove all registered formatters with `name`. - */ -void rm_fmt_remove_by_name(RmFmtTable *self, char *name); - /** * You can use this template for implementing new RmFmtHandlers. * All callbacks are not required to be implemented, leave them to NULL if