[tracker/wip/carlosg/cli-improvements: 6/8] tracker: Add pager support to "tracker3 sql" command




commit 99d8fc64a9006a2b656ab3a2f7268915113f17a0
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Aug 19 11:21:34 2020 +0200

    tracker: Add pager support to "tracker3 sql" command

 src/tracker/tracker-sql.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/tracker/tracker-sql.c b/src/tracker/tracker-sql.c
index 533b3ccc1..493e09f33 100644
--- a/src/tracker/tracker-sql.c
+++ b/src/tracker/tracker-sql.c
@@ -102,6 +102,7 @@ sql_by_query (void)
        gint n_rows = 0;
        GFile *db_location;
        TrackerDataManager *data_manager;
+       gint retval = EXIT_SUCCESS;
 
        db_location = g_file_new_for_commandline_arg (database_path);
        data_manager = tracker_data_manager_new (TRACKER_DB_MANAGER_READONLY,
@@ -116,6 +117,8 @@ sql_by_query (void)
                return EXIT_FAILURE;
        }
 
+       tracker_term_pipe_to_pager ();
+
        g_print ("--------------------------------------------------\n");
        g_print ("\n\n");
 
@@ -132,8 +135,8 @@ sql_by_query (void)
                            _("Could not run query"),
                            error->message);
                g_error_free (error);
-
-               return EXIT_FAILURE;
+               retval = EXIT_FAILURE;
+               goto out;
        }
 
        g_print ("%s:\n", _("Results"));
@@ -165,15 +168,18 @@ sql_by_query (void)
                            _("Could not run query"),
                            error->message);
                g_error_free (error);
-
-               return EXIT_FAILURE;
+               retval = EXIT_FAILURE;
+               goto out;
        }
 
        if (n_rows == 0) {
                g_print ("%s\n", _("Empty result set"));
        }
 
-       return EXIT_SUCCESS;
+out:
+       tracker_term_pager_close ();
+
+       return retval;
 }
 
 static int


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]