lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I just created a module for lua 5.1.

It is an interactive shell that can be used with debug.debug() or when
lua is in interactive mode. Its purpose is to easily know the structure
of tables.

In fact, it is like a unix shell where tables are folders and others
variables the files. To show you how ot works, there is a copy of a
session :

mildred@louve:~$ lua
Lua 5.1  Copyright (C) 1994-2006 Lua.org, PUC-Rio
> require("shell").maxcol = 74 -- for the email. default=80
> require("shell").new():shell()
[/root table]$ ll
string/ xpcall* package/        tostring*       print*  os/     unpack*
require*        getfenv*        setmetatable*   next*   assert*
tonumber* io/     rawequal*               collectgarbage*
getmetatable*   module* rawset* math/   debug/          pcall*
table/  newproxy* type*   coroutine/              _G/
select* gcinfo* pairs* rawget* loadstring*             ipairs*
_VERSION        dofile* setfenv*        load*           error*
loadfile* [/root table]$ cd os
[/root/os table]$ ls
exit    setlocale       date    getenv  difftime        remove  time
clock   tmpname         rename  execute
[/root/os table]$ cat date
function: 0x806c9f8
[/root/os table]$ cdup
[/root table]$ cd _VERSION
[/root/_VERSION string]$ cat
Lua 5.1
[/root/_VERSION string]$ cdmt
[/root/_VERSION/*mt table]$ ll
__index/
[/root/_VERSION/*mt table]$ cd __index
[/root/_VERSION/*mt/__index table]$ ll
sub*    upper*  len*    gfind*  rep*    find*   match*  char*   dump*
gmatch* reverse*        byte*   format* gsub*   lower*
[/root/_VERSION/*mt/__index table]$ pwd
/root/_VERSION/*mt/__index
[/root/_VERSION/*mt/__index table]$ help
Usage: help [COMMAND]
Usage: man [COMMAND]
commands : ls ll pwd ty cd cdup cdmt goto cat echo eval exit end
[/root/_VERSION/*mt/__index table]$ cdup
[/root/_VERSION/*mt table]$ cdup
[/root/_VERSION string]$ cdup
[/root table]$ cdup
error : You are in root directory, you can't cdup
[/root table]$ goto 12
[/root/*12 number]$ cat
12
[/root/*12 number]$ goto *_G
[/root/*12/*table: 0x8069450 table]$ ls
string  xpcall  package tostring        print   os      unpack  require
getfenv setmetatable    next            assert  tonumber        io
rawequal        collectgarbage          getmetatable    module  rawset
math    debug   pcall   table           newproxy        type
coroutine _G      select  gcinfo  pairs           rawget
loadstring      ipairs _VERSION        dofile  setfenv         load
error   loadfile [/root/*12/*table: 0x8069450 table]$ cdup
[/root/*12 number]$ ty
number
[/root/*12 number]$ exit
>
mildred@louve:~$


The attached file is the module :)

Mildred
-- 
Mildred       <xmpp:mildred@jabber.fr> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]


-- 
Mildred       <xmpp:mildred@jabber.fr> <http://mildred632.free.fr/>
Clef GPG :    <hkp://pgp.mit.edu> ou <http://mildred632.free.fr/gpg_key>
Fingerprint : 197C A7E6 645B 4299 6D37 684B 6F9D A8D6 [9A7D 2E2B]

Attachment: shell.lua
Description: Binary data