[vlc-commits] lua: rename rc interface to cli

Pierre Ynard git at videolan.org
Sat Apr 2 16:41:31 CEST 2011


vlc | branch: master | Pierre Ynard <linkfanel at yahoo.fr> | Sat Apr  2 16:41:28 2011 +0200| [9ce86f776250871b82bc65f2ca3fccff3a0eed70] | committer: Pierre Ynard

lua: rename rc interface to cli

Because a CLI is really what it is

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=9ce86f776250871b82bc65f2ca3fccff3a0eed70
---

 modules/lua/intf.c                 |   32 ++++++++++++++++++++++++++------
 modules/lua/vlc.c                  |   10 +++++++++-
 share/lua/intf/{rc.lua => cli.lua} |   18 +++++++++---------
 share/lua/intf/telnet.lua          |    2 --
 4 files changed, 44 insertions(+), 18 deletions(-)

diff --git a/modules/lua/intf.c b/modules/lua/intf.c
index 7b42fba..3971b61 100644
--- a/modules/lua/intf.c
+++ b/modules/lua/intf.c
@@ -70,9 +70,11 @@ static const struct
     const char *psz_shortcut;
     const char *psz_name;
 } pp_shortcuts[] = {
-    { "luarc", "rc" },
+    { "luacli", "cli" },
+    { "luarc", "cli" },
 #ifndef WIN32
-    { "rc", "rc" },
+    { "cli", "cli" },
+    { "rc", "cli" },
 #endif
     { "luahotkeys", "hotkeys" },
     /* { "hotkeys", "hotkeys" }, */
@@ -347,13 +349,15 @@ int Open_LuaIntf( vlc_object_t *p_this )
             free( psz_telnet_passwd );
             free( psz_telnet_host );
         }
-        else if( !strcmp( psz_name, "rc" ) )
+        else if( !strcmp( psz_name, "cli" ) )
         {
             char *psz_rc_host = var_CreateGetNonEmptyString( p_intf, "rc-host" );
+            if( !psz_rc_host )
+                psz_rc_host = var_CreateGetNonEmptyString( p_intf, "cli-host" );
             if( psz_rc_host )
             {
                 char *psz_esc_host = config_StringEscape( psz_rc_host );
-                asprintf( &psz_config, "rc={host='%s'}", psz_esc_host );
+                asprintf( &psz_config, "cli={host='%s'}", psz_esc_host );
 
                 free( psz_esc_host );
                 free( psz_rc_host );
@@ -379,6 +383,19 @@ int Open_LuaIntf( vlc_object_t *p_this )
             lua_getglobal( L, "config" );
             if( lua_istable( L, -1 ) )
             {
+                if( !strcmp( psz_name, "cli" ) )
+                {
+                    lua_getfield( L, -1, "rc" );
+                    if( lua_istable( L, -1 ) )
+                    {
+                        /* msg_Warn( p_intf, "The `rc' lua interface script "
+                                          "was renamed `cli', please update "
+                                          "your configuration!" ); */
+                        lua_setfield( L, -2, "cli" );
+                    }
+                    else
+                        lua_pop( L, 1 );
+                }
                 lua_getfield( L, -1, psz_name );
                 if( lua_istable( L, -1 ) )
                 {
@@ -399,10 +416,13 @@ int Open_LuaIntf( vlc_object_t *p_this )
     /* Wrapper for legacy telnet config */
     if ( !strcmp( psz_name, "telnet" ) )
     {
-        char *wrapped_file = vlclua_find_file( p_this, "intf", "rc" );
+        /* msg_Warn( p_intf, "The `telnet' lua interface script was replaced "
+                          "by `cli', please update your configuration!" ); */
+
+        char *wrapped_file = vlclua_find_file( p_this, "intf", "cli" );
         if( !wrapped_file )
         {
-            msg_Err( p_intf, "Couldn't find lua interface script \"rc\", "
+            msg_Err( p_intf, "Couldn't find lua interface script \"cli\", "
                              "needed by telnet wrapper" );
             p_intf->psz_header = NULL;
             lua_close( p_sys->L );
diff --git a/modules/lua/vlc.c b/modules/lua/vlc.c
index 9e6c306..e209e6f 100644
--- a/modules/lua/vlc.c
+++ b/modules/lua/vlc.c
@@ -85,6 +85,11 @@
 #define RCHOST_TEXT N_("TCP command input")
 #define RCHOST_LONGTEXT N_("Accept commands over a socket rather than stdin. " \
             "You can set the address and port the interface will bind to." )
+#define CLIHOST_TEXT N_("CLI input")
+#define CLIHOST_LONGTEXT N_( "Accept commands from this source. " \
+    "The CLI defaults to stdin (\"*console\"), but can also bind to a " \
+    "plain TCP socket (\"localhost:4212\") or use the telnet protocol " \
+    "(\"telnet://0.0.0.0:4212\")" )
 
 static int vlc_sd_probe_Open( vlc_object_t * );
 
@@ -109,8 +114,9 @@ vlc_module_begin ()
             add_string ( "http-host", NULL, HOST_TEXT, HOST_LONGTEXT, true )
             add_string ( "http-src",  NULL, SRC_TEXT,  SRC_LONGTEXT,  true )
             add_bool   ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
-        set_section( N_("Lua RC"), 0 )
+        set_section( N_("Lua CLI"), 0 )
             add_string( "rc-host", NULL, RCHOST_TEXT, RCHOST_LONGTEXT, true )
+            add_string( "cli-host", NULL, CLIHOST_TEXT, CLIHOST_LONGTEXT, true )
         set_section( N_("Lua Telnet"), 0 )
             add_string( "telnet-host", "localhost", TELNETHOST_TEXT,
                         TELNETHOST_LONGTEXT, true )
@@ -142,8 +148,10 @@ vlc_module_begin ()
 
     add_submodule ()
         set_description( N_("Lua Interface Module (shortcuts)") )
+        add_shortcut( "luacli" )
         add_shortcut( "luarc" )
 #ifndef WIN32
+        add_shortcut( "cli" )
         add_shortcut( "rc" )
 #endif
         set_capability( "interface", 25 )
diff --git a/share/lua/intf/rc.lua b/share/lua/intf/cli.lua
similarity index 98%
rename from share/lua/intf/rc.lua
rename to share/lua/intf/cli.lua
index 3321f10..567f07c 100644
--- a/share/lua/intf/rc.lua
+++ b/share/lua/intf/cli.lua
@@ -1,5 +1,5 @@
 --[==========================================================================[
- rc.lua: remote control module for VLC
+ cli.lua: CLI module for VLC
 --[==========================================================================[
  Copyright (C) 2007-2011 the VideoLAN team
  $Id$
@@ -24,22 +24,22 @@
 
 description=
 [============================================================================[
- Remote control interface for VLC
+ Command Line Interface for VLC
 
  This is a modules/control/rc.c look alike (with a bunch of new features).
  It also provides a VLM interface copied from the telnet interface.
 
  Use on local term:
-    vlc -I rc
+    vlc -I cli
  Use on tcp connection:
-    vlc -I rc --lua-config "rc={host='localhost:4212'}"
+    vlc -I cli --lua-config "cli={host='localhost:4212'}"
  Use on telnet connection:
-    vlc -I rc --lua-config "rc={host='telnet://localhost:4212'}"
+    vlc -I cli --lua-config "cli={host='telnet://localhost:4212'}"
  Use on multiple hosts (term + plain tcp port + telnet):
-    vlc -I rc --lua-config "rc={hosts={'*console','localhost:4212','telnet://localhost:5678'}}"
+    vlc -I cli --lua-config "cli={hosts={'*console','localhost:4212','telnet://localhost:5678'}}"
 
  Note:
-    -I rc and -I luarc are aliases for -I lua --lua-intf rc
+    -I cli and -I luacli are aliases for -I lua --lua-intf cli
 
  Configuration options setable throught the --lua-config option are:
     * hosts: A list of hosts to listen on.
@@ -72,7 +72,7 @@ env = { prompt = "> ";
         width = 70;
         autocompletion = 1;
         autoalias = 1;
-        welcome = _("Remote control interface initialized. Type `help' for help.");
+        welcome = _("Command Line Interface initialized. Type `help' for help.");
         flatplaylist = 0;
       }
 
@@ -305,7 +305,7 @@ function help(name,client,arg)
     local long = (name == "longhelp")
     local extra = ""
     if arg then extra = "matching `" .. arg .. "' " end
-    client:append("+----[ Remote control commands "..extra.."]")
+    client:append("+----[ CLI commands "..extra.."]")
     for i, cmd in ipairs(commands_ordered) do
         if (cmd == "" or not commands[cmd].adv or long)
         and (not arg or string.match(cmd,arg)) then
diff --git a/share/lua/intf/telnet.lua b/share/lua/intf/telnet.lua
index 6da0ef5..4539324 100644
--- a/share/lua/intf/telnet.lua
+++ b/share/lua/intf/telnet.lua
@@ -21,8 +21,6 @@
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 --]==========================================================================]
 
---vlc.msg.warn("The telnet lua interface script was replaced by rc, please update your configuration!")
-
 if config.hosts == nil and config.host == nil then
     config.host = "telnet://localhost:4212"
 else



More information about the vlc-commits mailing list