+# Enable debug.
+# Global debug if the keyword "all" is given, or just for the
+# current window otherwise
+#
+sub _cmd_debug {
+ my $event = shift;
+ my $scope = shift;
+
+ if (defined($scope) and (lc($scope) eq 'all')) {
+ _io("Global debug enabled");
+ $debug = 1;
+ } else {
+ _io("Debug for this window enabled");
+ $debugwindows{$event->{window}} = 1;
+ }
+}
+
+#
+# Disable debug
+# Disable global debug if the keyword "all" is given (this will
+# also disable all per-window debugs) or just for the current
+# window
+#
+sub _cmd_nodebug {
+ my $event = shift;
+ my $scope = shift;
+
+ if (defined($scope) and (lc($scope) eq 'all')) {
+ $debug = 0;
+ %debugwindows = ();
+ _io("Global debug disabled");
+ } else {
+ delete($debugwindows{$event->{window}});
+ _io("Debug for this window disabled");
+ }
+}
+
+#
+# Handle generic service commands
+#
+sub _cmd_service {
+ my $event = shift;
+ my $subcmd = shift || '';
+
+ $subcmd = lc($subcmd);
+
+ if ($subcmd eq 'cache') {
+ _cmd_service_cache($event, @_);
+ }
+}
+
+
+#
+# Display or clear the content of the config cache
+#
+sub _cmd_service_cache {
+ my $event = shift;
+ my $subcmd = shift;
+
+ $subcmd = 'list' unless defined($subcmd);
+ $subcmd = lc($subcmd);
+
+ if ($subcmd eq 'list') {
+ _io("Content of config cache:");
+ foreach (sort(keys(%config_cache))) {
+ if (exists($config_cache{$_}->{value})) {
+ _io(" %s => %s", $_, $config_cache{$_}->{value});
+ } else {
+ _io(" %s present", $_);
+ }
+ }
+ } elsif ($subcmd eq 'clear') {
+ %config_cache = ();
+ _io("Cache cleared");
+ }
+}
+
+
+#