X-Git-Url: https://git.camperquake.de/gitweb.cgi?a=blobdiff_plain;f=libvideosite.pm;h=8791c649db8c5de30fe2e5b23020bd2707d4a549;hb=a795367c342cad54115ac809d52fdd5980c85860;hp=bc41e5c136c06b39304be8b5efc436513d3ef18b;hpb=88757bf7a37a953e33c37721eb086789a5e5e169;p=videosite.git diff --git a/libvideosite.pm b/libvideosite.pm index bc41e5c..8791c64 100644 --- a/libvideosite.pm +++ b/libvideosite.pm @@ -51,6 +51,24 @@ my $defaultconfig = { }; # +# This is a list of default values for the remote API. These +# are used if the values are not registered by the library user. +# +my $remote_api = { + io => sub { print @_, "\n" }, + config_init => \&_builtin_config_init, + config_get => \&_builtin_config_get, + config_set => \&_builtin_config_set, + config_has => \&_builtin_config_has, + config_save => \&_builtin_config_save, + config_del => \&_builtin_config_del, + color => sub { return '' }, + module_path => sub { return dirname(realpath($0)) }, + quote => sub { return $_ }, + reload => sub {}, +}; + +# # List of known commands and handlers # my $videosite_commands = { @@ -83,7 +101,7 @@ my $videosite_commands = { }, 'reload' => sub { - init(); + $remote_api->{reload}->(); }, 'mode' => sub { @@ -112,23 +130,6 @@ my $videosite_commands = { }; # -# This is a list of default values for the remote API. These -# are used if the values are not registered by the library user. -# -my $remote_api = { - io => sub { print @_, "\n" }, - config_init => \&_builtin_config_init, - config_get => \&_builtin_config_get, - config_set => \&_builtin_config_set, - config_has => \&_builtin_config_has, - config_save => \&_builtin_config_save, - config_del => \&_builtin_config_del, - color => sub { return '' }, - module_path => sub { return dirname(realpath($0)) }, - quote => sub { return $_ }, -}; - -# # Output a string on the client. # Works like (s)printf in that it takes a format string and a list of # values to be replaced. Undefined values will be printed as '(undef)' @@ -522,7 +523,11 @@ sub _expand_url_shortener { # Save the config to durable storage # sub _cmd_save { - $remote_api->{config_save}->(); + if ($remote_api->{config_save}->()) { + _io("Config saved"); + } else { + _io(sprintf("%sConfig save failed%s", _colorpair("*red"), _colorpair())); + } } #