diff --git a/Makefile b/Makefile index 936761a..7bd04c0 100644 --- a/Makefile +++ b/Makefile @@ -17,7 +17,7 @@ CORE_NOM_FILES= $(wildcard core/*.nom) CORE_LUA_FILES= $(patsubst %.nom,%.lua,$(CORE_NOM_FILES)) LIB_NOM_FILES= $(wildcard lib/*.nom) LIB_LUA_FILES= $(patsubst %.nom,%.lua,$(LIB_NOM_FILES)) -PEG_FILE= nomsu.peg +PEG_FILES= $(wildcard nomsu.*.peg) GET_VERSION= $(LUA_BIN) nomsu.lua --version all: build optimize @@ -36,7 +36,7 @@ test: build optimize @$(LUA_BIN) nomsu.lua -c $< .DELETE_ON_ERROR: version -version: $(LUA_FILES) $(CORE_NOM_FILES) $(LIB_NOM_FILES) $(PEG_FILE) +version: $(LUA_FILES) $(CORE_NOM_FILES) $(LIB_NOM_FILES) @$(LUA_BIN) nomsu.lua --version > version || exit build: $(LUA_FILES) @@ -47,7 +47,7 @@ optimize: build $(CORE_LUA_FILES) $(LIB_LUA_FILES) .PHONY: clean clean: @echo "\033[1mDeleting...\033[0m" - @rm -rvf version core/*.lua lib/*.lua + @rm -rvf version core/*.lua lib/*.lua tools/*.lua tests/*.lua compatibility/*.lua .PHONY: install install: build version optimize @@ -68,7 +68,7 @@ install: build version optimize && chmod +x $$prefix/bin/nomsu$$version \ && cp -v nomsu $$prefix/bin \ && cp -v doc/nomsu.1 $$prefix/share/man/man1 \ - && cp -rv $(LUA_FILES) $(PEG_FILE) core lib tests $$prefix/share/nomsu/$$version; + && cp -rv $(LUA_FILES) $(PEG_FILES) core lib compatibility tools tests $$prefix/share/nomsu/$$version; .PHONY: uninstall uninstall: version diff --git a/doc/nomsu.1 b/doc/nomsu.1 index 20cb7a9..4eef711 100644 --- a/doc/nomsu.1 +++ b/doc/nomsu.1 @@ -30,6 +30,9 @@ If no input files are provided, \fBnomsu\fR will run in interactive mode. .BI \-V " version" Specify the desired Nomsu version (defaults to the latest installed version). E.g. \fBnomsu -V 1.2\fR or \fBnomsu -V 1.2.5.9\fR .TP +.BI \-L +List the installed versions of Nomsu (if \fB-V\fR is supplied, only print versions that match the requested pattern). +.TP .B \-O Run the compiler in optimized mode (use precompiled .lua versions of .nom files, when available) .TP diff --git a/nomsu b/nomsu index af9993d..dbeee11 100755 --- a/nomsu +++ b/nomsu @@ -1,7 +1,8 @@ #!/bin/bash -while getopts ':V:' flag; do +while getopts ':V:L' flag; do case "${flag}" in V) VERSION="${OPTARG/./\.}\\b" ;; + L) LIST="YES" ;; esac done @@ -11,6 +12,11 @@ else candidates=$(ls $(dirname $BASH_SOURCE) | grep "^nomsu[0-9.]\+$") fi +if [[ $LIST ]]; then + echo "$candidates" + exit +fi + if [[ $candidates ]]; then eval $(dirname $BASH_SOURCE)/$(echo "$candidates" | sort -V | tail -n 1) $@ else