Added manpage and fixed a bug that screwed up nomsu loading.

This commit is contained in:
Bruce Hill 2018-06-24 18:20:11 -07:00
parent 034376f5f7
commit 80c8ceb0d4
4 changed files with 109 additions and 39 deletions

View File

@ -60,10 +60,11 @@ install: build version optimize
fi; \
fi; \
version="`cat version`"; \
mkdir -pv $$prefix/bin $$prefix/lib/nomsu/$$version $$prefix/share/nomsu/$$version \
mkdir -pv $$prefix/bin $$prefix/lib/nomsu/$$version $$prefix/share/nomsu/$$version $$prefix/share/man/man1 \
&& echo "#!$(LUA_BIN)\\nlocal NOMSU_VERSION, NOMSU_PREFIX = [[$$version]], [[$$prefix]]" | cat - nomsu.lua > $$prefix/bin/nomsu$$version \
&& chmod +x $$prefix/bin/nomsu$$version \
&& cp -v nomsu $$prefix/bin \
&& install -v -g 0 -o 0 -m 644 doc/nomsu.1 $$prefix/share/man/man1 \
&& cp -rv $(LUA_FILES) $(PEG_FILE) core lib tests $$prefix/share/nomsu/$$version;
.PHONY: uninstall
@ -82,13 +83,13 @@ uninstall: version
version="`cat version`"; \
rm -rvf $$prefix/lib/nomsu/$$version $$prefix/share/nomsu/$$version $$prefix/bin/nomsu$$version; \
if [[ "`find -E $$prefix/bin -type f -regex '.*/nomsu[0-9.]+\$$'`" == "" ]]; then \
rm -vf $$prefix/bin/nomsu; \
rm -vf $$prefix/bin/nomsu $$prefix/share/man/man1/nomsu.1; \
else \
if [ -f $$prefix/bin/nomsu ]; then \
read -p $$'\033[1mIt looks like there are other versions of Nomsu installed. Is it okay to leave the "nomsu" cross-version launcher in place? (recommended) [Y/n]\033[0m ' ans; \
if [[ $$ans =~ ^[Nn] ]]; then \
echo "\033[1mDeleting...\033[0m"; \
rm -vf $$prefix/bin/nomsu; \
rm -vf $$prefix/bin/nomsu $$prefix/share/man/man1/nomsu.1; \
fi; \
fi; \
fi; \

81
doc/nomsu.1 Normal file
View File

@ -0,0 +1,81 @@
.\" Manpage for nomsu.
.\" Contact bruce@bruce-hill.com to correct errors or typos.
.TH man 8 "24 June 2018" "1.0" "nomsu man page"
.SH NAME
nomsu \- run a Nomsu program
.SH SYNOPSIS
.B nomsu
[
.I options
]
[
.I scripts
[ --
.I args
]
]
.SH DESCRIPTION
.B
nomsu
is the compiler/interpreter for the Nomsu programming language.
.SH OPTIONS
.TP
.BI \-V " version"
Specify the desired Nomsu version (defaults to the latest installed version). E.g.
.B
nomsu -V 1.2
or
.B
nomsu -V 1.2.5.9
.TP
.B \-i
Enter interactive mode after the input files are executed.
.TP
.B \-O
Run the compiler in optimized mode (use precompiled .lua versions of .nom files, when available)
.TP
.B \-v
Verbose: print compiled lua code as it's generated for the input files.
.TP
.B \-c
Compile input files into .lua files
.TP
.B \-f
Auto-format the given Nomsu file and print the result.
.TP
.B \-s
Check the program for syntax errors.
.TP
.B \--version
Print the version number and exit.
.TP
.B \--help
Print the command line usage.
.SH EXAMPLES
.TP
.B
nomsu
Runs nomsu in interactive mode (a read-evaluate-print loop)
.TP
.B
nomsu my_file.nom
Runs the Nomsu file 'my_file.nom'
.TP
.B
nomsu -c my_file.nom
Compiles the Nomsu file 'my_file.nom' into a Lua file called 'my_file.lua'
.TP
.B
nomsu my_directory
Runs every '.nom' file in 'my_directory' or its subdirectories.
.TP
.B
nomsu -V 2.3 my_file.nom
Runs my_file.nom using the latest installed version of Nomsu whose version matches 2.3.*
.SH AUTHOR
Bruce Hill (bruce@bruce-hill.com)

View File

@ -1,4 +1,4 @@
if NOMSU_VERSION and NOMSU_LIB and NOMSU_SHARE then
if NOMSU_VERSION and NOMSU_PREFIX then
local ver_bits
do
local _accum_0 = { }
@ -24,7 +24,7 @@ if NOMSU_VERSION and NOMSU_LIB and NOMSU_SHARE then
local _len_0 = 1
for _index_0 = 1, #partial_vers do
local v = partial_vers[_index_0]
_accum_0[_len_0] = tostring(NOMSU_SHARE) .. "/" .. tostring(v) .. "/?.lua"
_accum_0[_len_0] = tostring(NOMSU_PREFIX) .. "/share/nomsu/" .. tostring(v) .. "/?.lua"
_len_0 = _len_0 + 1
end
return _accum_0
@ -34,7 +34,7 @@ if NOMSU_VERSION and NOMSU_LIB and NOMSU_SHARE then
local _len_0 = 1
for _index_0 = 1, #partial_vers do
local v = partial_vers[_index_0]
_accum_0[_len_0] = tostring(NOMSU_LIB) .. "/" .. tostring(v) .. "/?.so"
_accum_0[_len_0] = tostring(NOMSU_PREFIX) .. "/lib/nomsu/" .. tostring(v) .. "/?.so"
_len_0 = _len_0 + 1
end
return _accum_0
@ -44,7 +44,7 @@ if NOMSU_VERSION and NOMSU_LIB and NOMSU_SHARE then
local _len_0 = 1
for _index_0 = 1, #partial_vers do
local v = partial_vers[_index_0]
_accum_0[_len_0] = tostring(NOMSU_SHARE) .. "/" .. tostring(v)
_accum_0[_len_0] = tostring(NOMSU_PREFIX) .. "/share/nomsu/" .. tostring(v)
_len_0 = _len_0 + 1
end
return _accum_0
@ -293,23 +293,19 @@ run = function()
if args.interactive then
nomsu:run([[use "core"
use "lib/consolecolor.nom"
action [quit, exit]: lua> "os.exit(0)"
action [help]
say ".."
This is the Nomsu v\(Nomsu version) interactive console.
You can type in Nomsu code here and hit 'enter' twice to run it.
To exit, type 'exit' or 'quit' and hit enter twice.
say ".."
\(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\(reset color)
press \'enter\' twice to run a command
press 'enter' twice to run a command
\("")]])
local ready_to_quit = false
nomsu.A_quit = function()
ready_to_quit = true
return print("Goodbye!")
end
nomsu.A_exit = nomsu.A_quit
nomsu.A_help = function()
print("This is the Nomsu v" .. tostring(nomsu.A_Nomsu_version()) .. " interactive console.")
print("You can type in Nomsu code here and hit 'enter' twice to run it.")
return print("To exit, type 'exit' or 'quit' and hit enter twice")
end
for repl_line = 1, math.huge do
io.write(colored.bright(colored.yellow(">> ")))
local buff = { }
@ -344,9 +340,6 @@ say ".."
elseif not ok then
Errhand.print_error(ret)
end
if ready_to_quit then
break
end
end
end
end

View File

@ -1,11 +1,11 @@
#!/usr/bin/env moon
-- This file contains the command-line Nomsu runner.
if NOMSU_VERSION and NOMSU_LIB and NOMSU_SHARE
if NOMSU_VERSION and NOMSU_PREFIX
ver_bits = [ver_bit for ver_bit in NOMSU_VERSION\gmatch("[0-9]+")]
partial_vers = [table.concat(ver_bits,'.',1,i) for i=#ver_bits,1,-1]
package.path = table.concat(["#{NOMSU_SHARE}/#{v}/?.lua" for v in *partial_vers],";")..";"..package.path
package.cpath = table.concat(["#{NOMSU_LIB}/#{v}/?.so" for v in *partial_vers],";")..";"..package.cpath
package.nomsupath = table.concat(["#{NOMSU_SHARE}/#{v}" for v in *partial_vers],";")
package.path = table.concat(["#{NOMSU_PREFIX}/share/nomsu/#{v}/?.lua" for v in *partial_vers],";")..";"..package.path
package.cpath = table.concat(["#{NOMSU_PREFIX}/lib/nomsu/#{v}/?.so" for v in *partial_vers],";")..";"..package.cpath
package.nomsupath = table.concat(["#{NOMSU_PREFIX}/share/nomsu/#{v}" for v in *partial_vers],";")
EXIT_SUCCESS, EXIT_FAILURE = 0, 1
usage = [=[
@ -204,22 +204,19 @@ run = ->
nomsu\run [[
use "core"
use "lib/consolecolor.nom"
action [quit, exit]: lua> "os.exit(0)"
action [help]
say ".."
This is the Nomsu v\(Nomsu version) interactive console.
You can type in Nomsu code here and hit 'enter' twice to run it.
To exit, type 'exit' or 'quit' and hit enter twice.
say ".."
\(bright)\(underscore)Welcome to the Nomsu v\(Nomsu version) interactive console!\(reset color)
press \'enter\' twice to run a command
press 'enter' twice to run a command
\("")]]
ready_to_quit = false
nomsu.A_quit = ->
export ready_to_quit
ready_to_quit = true
print("Goodbye!")
nomsu.A_exit = nomsu.A_quit
nomsu.A_help = ->
print("This is the Nomsu v#{nomsu.A_Nomsu_version()} interactive console.")
print("You can type in Nomsu code here and hit 'enter' twice to run it.")
print("To exit, type 'exit' or 'quit' and hit enter twice")
for repl_line=1,math.huge
io.write(colored.bright colored.yellow ">> ")
buff = {}
@ -247,8 +244,6 @@ say ".."
print "= "..repr(ret)
elseif not ok
Errhand.print_error ret
if ready_to_quit
break
has_ldt, ldt = pcall(require,'ldt')
if has_ldt