This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch main
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=621de6ecfa78a1380f6d8b9d39453f91b9df80a7

commit 621de6ecfa78a1380f6d8b9d39453f91b9df80a7
Author: Guillem Jover <[email protected]>
AuthorDate: Thu Dec 12 04:08:38 2024 +0100

    Dpkg::ErrorHandling: Add support for hint printing
    
    This will make it possible to provide hints for the user so that they
    can perform some action prompted by diagnostics printed by dpkg tools.
---
 scripts/Dpkg/ErrorHandling.pm | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/scripts/Dpkg/ErrorHandling.pm b/scripts/Dpkg/ErrorHandling.pm
index e2f2c2009..c7fbf15f0 100644
--- a/scripts/Dpkg/ErrorHandling.pm
+++ b/scripts/Dpkg/ErrorHandling.pm
@@ -36,6 +36,7 @@ our @EXPORT_OK = qw(
     REPORT_COMMAND
     REPORT_STATUS
     REPORT_DEBUG
+    REPORT_HINT
     REPORT_INFO
     REPORT_NOTICE
     REPORT_WARN
@@ -47,6 +48,7 @@ our @EXPORT_OK = qw(
 our @EXPORT = qw(
     report_options
     debug
+    hint
     info
     notice
     warning
@@ -64,6 +66,7 @@ use Dpkg ();
 use Dpkg::Gettext;
 
 my $quiet_warnings = 0;
+my $show_hints = 1;
 my $debug_level = 0;
 my $info_fh = \*STDOUT;
 
@@ -93,6 +96,7 @@ use constant {
     REPORT_WARN => 6,
     REPORT_ERROR => 7,
     REPORT_DEBUG => 8,
+    REPORT_HINT => 9,
 };
 
 my %report_mode = (
@@ -114,6 +118,10 @@ my %report_mode = (
         # and all debug messages are untranslated anyway.
         name => 'debug',
     },
+    REPORT_HINT() => {
+        color => 'bold blue',
+        name => g_('hint'),
+    },
     REPORT_INFO() => {
         color => 'green',
         name => g_('info'),
@@ -139,6 +147,9 @@ sub report_options
     if (exists $opts{quiet_warnings}) {
         $quiet_warnings = $opts{quiet_warnings};
     }
+    if (exists $opts{show_hints}) {
+        $show_hints = $opts{show_hints};
+    }
     if (exists $opts{debug_level}) {
         $debug_level = $opts{debug_level};
     }
@@ -205,6 +216,15 @@ sub debug
     print report(REPORT_DEBUG, @args) if $level <= $debug_level;
 }
 
+sub hint
+{
+    my @args = @_;
+
+    return if not $show_hints;
+
+    print report(REPORT_HINT, @args) if not $quiet_warnings;
+}
+
 sub info
 {
     my @args = @_;

-- 
Dpkg.Org's dpkg

Reply via email to