diff options
| author | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 10:35:12 +0000 |
|---|---|---|
| committer | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 16:13:46 +0000 |
| commit | 347fd1f8fcf6c14fe936eb4c4c21d101c6e24ca7 (patch) | |
| tree | f4f4dd3cf6069f1f19a8fc7bdc55dd7c2fd86799 | |
| parent | d7cf3b4217a4a6ef16ade15f32170894a66d5b52 (diff) | |
Feature: Added basic plugin supportplugins
This includes support to run plugins as --preprocessor and a newly
added --generate.
| -rwxr-xr-x | webgen | 39 |
1 files changed, 39 insertions, 0 deletions
@@ -47,8 +47,34 @@ DEFAULT_MENU='-menu-none' PREPROCESSOR='none' LANGUAGE='' TEMPLATES='' +PLUGINS='' # CODE: +call_plugin() { +# Args: plugin, mode, input, output, args... + _plugin="$1" + _mode="$2" + _input="$3" + _output="$4" + shift 4 + + "webgenp-$_plugin" --tpl . --mode "$_mode" --input "$_input" --output "$_output" "$@" +} + +generate() { + cd $TPLS + if [ -z "$PLUGINS" ] + then + PLUGINS=`cat \#plugin` + fi + + for _p in $PLUGINS + do + echo "Calling plugin $_p" + call_plugin "$_p" generate . . + done +} + setup() { if [ -e $TPLS -o -e Makefile ] then @@ -209,6 +235,7 @@ list_dependencies() { show_help() { echo "Usage: webgen [--preprocessor PP] [--language LANG] [{+|~|=}][TPL]" echo " or: webgen [--language LANG] --list-dependencies [{+|~|=}]TPL" + echo " or: webgen [--plugin PLUGIN] --generate" echo " or: webgen --setup" echo " or: webgen --list" echo " or: webgen --help" @@ -221,6 +248,10 @@ do PREPROCESSOR="$2" shift ;; + '--plugin') + PLUGINS="$PLUGINS $2" + shift + ;; '--language') if [ "$2" = 'default' ] then @@ -236,6 +267,10 @@ do popd > /dev/null shift; ;; + '--generate') + generate + exit 0 + ;; '--setup') setup exit 0 @@ -278,6 +313,10 @@ cat_file() { cpp) cpp -P -o - -D__TEMPLATE__="\"$_tpl\"" -D__TEMPLATE_CLEAN__="\"$CLEANTPLNAME\"" -D __OUTPUT_FILE__="\"$OF\"" ./"$_file" ;; + plugin-*) + _plugin=`echo "$PREPROCESSOR" | sed 's/^plugin-//'`; + call_plugin "$_plugin" preprocessor "$_file" - --kv template "$_tpl" --kv template-clean "$CLEANTPLNAME" --kv output-file "$OF" + ;; *) echo "Error: Unknown preprocessor: $PREPROCESSOR" >&2 ;; |
