From aabed04a2c8f0211711b489c5bb86331a645bab3 Mon Sep 17 00:00:00 2001 From: Dan Moore Date: Mon, 26 Jul 2021 08:51:50 -0700 Subject: [PATCH] Added command line options -help and -version --- tcltk/Makefile | 4 +++- tcltk/netgen.sh.in | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/tcltk/Makefile b/tcltk/Makefile index e74b1b5..ef305a5 100644 --- a/tcltk/Makefile +++ b/tcltk/Makefile @@ -4,6 +4,7 @@ SRCS = tclnetgen.c include ${NETGENDIR}/defs.mak +VERSION := $(shell cat ../VERSION) EXTRA_LIBS = ${MAIN_EXTRA_LIBS} DFLAGS += -DNETGEN_DATE="\"`date`\"" @@ -32,11 +33,12 @@ netgen.tcl: netgen.tcl.in -e 's%SHDLIB_EXT%${SHDLIB_EXT}%g' \ netgen.tcl.in > netgen.tcl -netgen.sh: netgen.sh.in +netgen.sh: netgen.sh.in ../VERSION sed -e 's%TCL_DIR%${TCLDIR}%g' \ -e 's%PY_DIR%${PYDIR}%g' \ -e 's%TCLLIB_DIR%${TCL_LIB_DIR}%g' \ -e 's%WISH_EXE%${WISH_EXE}%g' \ + -e 's%=VERSION%=${VERSION}%' \ netgen.sh.in > netgen.sh $(DESTDIR)${INSTALL_TCLDIR}/%: % diff --git a/tcltk/netgen.sh.in b/tcltk/netgen.sh.in index 215330a..f2952a1 100755 --- a/tcltk/netgen.sh.in +++ b/tcltk/netgen.sh.in @@ -16,6 +16,7 @@ TKCON=true BATCH= GUI= NETGEN_WISH=WISH_EXE +VERSION=VERSION export NETGEN_WISH # Hacks for Cygwin @@ -24,6 +25,20 @@ if [ ${TERM:=""} = "cygwin" ]; then export DISPLAY=${DISPLAY:=":0"} fi +usage() { + echo "Usage: netgen [-noconsole] []" + echo " netgen -batch " + echo " netgen -gui" + echo " netgen [-help | -version]" + echo "Options:" + echo " -noconsole no console window, interpreter prompt will be in the terminal" + echo " -batch implies -noconsole, and exits after executing argument" + echo " -gui runs the LVS manager" + echo " -help show help and exit" + echo " -version show version and exit" + exit 1 +} + # Preserve quotes in arguments (thanks, Stackoverflow!) arglist='' for i in "$@" ; do @@ -31,6 +46,8 @@ for i in "$@" ; do -noc*) TKCON=;; -bat*) BATCH=true; TKCON=;; -gui) GUI=true; TKCON=;; + -v | -version | --version) echo ${VERSION}; exit 1;; + -h | -help | --help) usage;; *) arglist="$arglist${arglist:+ }\"${i//\"/\\\"}\"";; esac done