Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/trepl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Farabet <clement.farabet@gmail.com>2014-07-08 00:39:30 +0400
committerClement Farabet <clement.farabet@gmail.com>2014-07-08 00:39:30 +0400
commit0a310c749dee414f6d3a711c840d913e1d7b701e (patch)
tree01518736dc8e9fa489f6311d3c2bdea05c56c716
parent7a9a10acf5884e285121a3ea4691cb1438e93372 (diff)
Help.
-rw-r--r--README.md1
-rw-r--r--init.lua42
2 files changed, 42 insertions, 1 deletions
diff --git a/README.md b/README.md
index 2801283..4ef8cd8 100644
--- a/README.md
+++ b/README.md
@@ -33,6 +33,7 @@ Features:
* Each command is profiled, timing is reported
* No need for '=' to print
* Easy help with: `? funcname`
+* Self help: `?`
* Shell commands with: $ cmd (example: `$ ls`)
* Print all user globals with `who()`
* Import a package's symbols globally with `import(package)`
diff --git a/init.lua b/init.lua
index 35d34b0..3d8e9d9 100644
--- a/init.lua
+++ b/init.lua
@@ -25,6 +25,40 @@ pcall(require,'paths')
local colors = require 'trepl.colors'
local col = require 'trepl.colorize'
+-- Help string:
+local selfhelp = [[
+ ______ __
+ /_ __/__ ________/ /
+ / / / _ \/ __/ __/ _ \
+ /_/ \___/_/ \__/_//_/
+
+]]..col.red('th')..[[ is an enhanced interpreter (repl) for Torch7/LuaJIT.
+
+]]..col.blue('Features:')..[[
+
+ Tab-completion on nested namespaces
+ Tab-completion on disk files (when opening a string)
+ History
+ Pretty print (table introspection and coloring)
+ Auto-print after eval (can be stopped with ;)
+ Each command is profiled, timing is reported
+ No need for '=' to print
+ Easy help on functions/packages:
+ ]]..col.magenta("? torch.randn")..[[
+ Shell commands with:
+ ]]..col.magenta("$ ls -l")..[[
+ Print all user globals with:
+ ]]..col.magenta("who()")..[[
+ Import a package's symbols globally with:
+ ]]..col.magenta("import 'torch' ")..[[
+ Require is overloaded to provide relative (form within a file) search paths:
+ ]]..col.magenta("require './local/lib' ")..[[
+ Optional strict global namespace monitoring:
+ ]]..col.magenta('th -g')..[[
+ Optional async repl (based on https://github.com/clementfarabet/async):
+ ]]..col.magenta('th -a')..[[
+]]
+
-- If no Torch:
if not torch then
torch = {
@@ -468,7 +502,13 @@ $endif
if line and line:find('^%s-?') then
local ok = pcall(require,'dok')
if ok then
- line = 'help(' .. line:gsub('^%s-?','') .. ')'
+ local pkg = line:gsub('^%s-?','')
+ if pkg:gsub('%s*','') == '' then
+ print(selfhelp)
+ return
+ else
+ line = 'help(' .. pkg .. ')'
+ end
else
print('error: could not load help backend')
return line