]> git.sesse.net Git - vlc/commitdiff
lua: rename rc interface to cli
authorPierre Ynard <linkfanel@yahoo.fr>
Sat, 2 Apr 2011 14:41:28 +0000 (16:41 +0200)
committerPierre Ynard <linkfanel@yahoo.fr>
Sat, 2 Apr 2011 14:41:28 +0000 (16:41 +0200)
Because a CLI is really what it is

modules/lua/intf.c
modules/lua/vlc.c
share/lua/intf/cli.lua [moved from share/lua/intf/rc.lua with 98% similarity]
share/lua/intf/telnet.lua

index 7b42fba871a6577faab54f018ac972ee06b129ca..3971b61b52f6632d141dab0a549fd9391b0e92a4 100644 (file)
@@ -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 );
index 9e6c306c1d260cfbb23dbba28f45feabb7373dbd..e209e6fd7e99da1767961ea543f40f1cf14aad1e 100644 (file)
 #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 )
similarity index 98%
rename from share/lua/intf/rc.lua
rename to share/lua/intf/cli.lua
index 3321f10c9ddd53615dfe7944d22f512e0c4e7ea5..567f07c6411cdbccdff2b865cc3abe74ce30bf44 100644 (file)
@@ -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$
 
 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
index 6da0ef53aa1beb8282958bac034c7e85500bbc2e..45393244abccb7e07c6aeb9767f70703f4618336 100644 (file)
@@ -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