From 2eefd096122d569e244fd84dee9a02920fd87499 Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 9 Nov 2021 16:30:53 -0500 Subject: Generate skeleton shell scripts --- shopenscad.sh | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/shopenscad.sh b/shopenscad.sh index e8b350f..6d85de6 100755 --- a/shopenscad.sh +++ b/shopenscad.sh @@ -8,6 +8,7 @@ INTERACTIVE= PRINT_VARS= USER_OUTPUT_FILENAME= SCAD_FILE= +SHELL_SKEL= help() { @@ -22,6 +23,7 @@ Usage: $0 [-h] [-n] [-p] [-i] [-o OUTPUT-FILENAME] INPUT.scad -p, --print-vars print variables parsed from INPUT.scad -i, --interactive show output command and query for execution -n, --no-act show output command, do not execute + -s, --shell-skel initialize a skeleton shell script -o, --output-filename Specify an output filename. The following variables are available to you: @@ -62,8 +64,8 @@ EOF parse_options() { OPTS=$(getopt \ - --options 'hpino:' \ - --longoptions 'help,print-vars,interactive,no-act,output-filename:' \ + --options 'hpinso:' \ + --longoptions 'help,print-vars,interactive,no-act,shell-skel,output-filename:' \ -- "$@") eval set -- "$OPTS" unset OPTS @@ -79,6 +81,7 @@ parse_options() -p | --print-vars ) PRINT_VARS=y;; -i | --interactive ) INTERACTIVE=y;; -n | --no-act ) RUN=;; + -s | --shell-skel ) SHELL_SKEL=y;; -o | --output-filename ) shift; USER_OUTPUT_FILENAME=$1;; -- ) shift; break;; esac @@ -189,6 +192,18 @@ main() exit fi + if [ "$SHELL_SKEL" ]; then + all_vars=$($0 $SCAD_FILE -p |sed -e 's/^/# /') + cat <