Skip to content

Commit

Permalink
Merge pull request #2 from simonkowallik/dev
Browse files Browse the repository at this point in the history
init-files update
  • Loading branch information
simonkowallik committed Apr 13, 2019
2 parents eab0465 + 61b2316 commit 8f65b6a
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 18 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ language: generic

script:
- ./tests/test_init.sh
- ./tests/test_init-files.sh
- ./tests/test_simple.sh
- ./tests/test_advanced.sh
- ./tests/test_version_attributes.sh
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ Of course you can just use your favorite editor to modify the file.
## Usage
`mkiapp --help` will provide you with the following help.

usage: mkiapp [init] [init-files] [showbuiltin] [showmakefile] [config [edit] [<key>] [<key> <value>]] [-t|--template <file>] [--(no-)impl|--(no-)implementation] [--(no-)apl|--(no-)presentation] [--(no-)macro] [--(no-)html] [-h|--help] [-v|--version]
usage: mkiapp [init] [init-files [DIR]] [showbuiltin] [showmakefile] [config [edit] [<key>] [<key> <value>]] [-t|--template <file>] [--(no-)impl|--(no-)implementation] [--(no-)apl|--(no-)presentation] [--(no-)macro] [--(no-)html] [-h|--help] [-v|--version]
init: initialize current working directory for mkiapp
init-files: create Section Skeleton Files in current working directory
init-files: create Section Skeleton Files in current working directory or [DIR]
showbuiltin: print builtin iApp Skeleton Template
showmakefile: print example Makefile
config: no arguments: prints full configuration
Expand All @@ -150,7 +150,7 @@ Of course you can just use your favorite editor to modify the file.
mkiapp simplifies the process of combining separate source files into an iApp Template.
Start with 'mkiapp init' to initialize the current working directory. Executing 'mkiapp' will generate an iApp.

You start with `mkiapp init`, as outlined earlier. If you start a new project you can use `mkiapp init-files` to create the `Section Skeleton Files` in the current working directory (don't worry, existing files will not be overwritten).
You start with `mkiapp init`, as outlined earlier. If you start a new project you can use `mkiapp init-files [DIR]` to create the `Section Skeleton Files` in the current working directory or `[DIR]` (don't worry, existing files will not be overwritten).

Once you have you files ready and updated with content, you can generate your own iApp.
Running `mkiapp` will use the `iApp Skeleton Template`, include all `Section Skeleton Files` and `Skeleton Template Variables` and output your own iApp Template on the console (`STDOUT`).
Expand Down
23 changes: 14 additions & 9 deletions mkiapp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

VERSION="2.0"
VERSION="2.1"
HOMEPAGE="https://github.com/simonkowallik/mkiapp"
PROGRAM=$(basename "$0")
CONFIGFILE=".mkiapp"
Expand Down Expand Up @@ -143,10 +143,15 @@ echo

# init mkiapp function
function mkinit_files() {
touch implementation.tcl && echo "implementation.tcl"
touch presentation.tcl && echo "presentation.tcl"
touch macro.tcl && echo "macro.tcl"
touch help.html && echo "help.html"
DIR=$1
if [[ -n "$DIR" ]]; then
mkdir -p ./$DIR
DIR=${DIR%/}/
fi
touch ${DIR}implementation.tcl && echo "${DIR}implementation.tcl"
touch ${DIR}presentation.tcl && echo "${DIR}presentation.tcl"
touch ${DIR}macro.tcl && echo "${DIR}macro.tcl"
touch ${DIR}help.html && echo "${DIR}help.html"
}
#
function mkiapp_config() {
Expand Down Expand Up @@ -178,9 +183,9 @@ function mkiapp_config() {
}

function print_help() {
printf 'usage: %s [init] [init-files] [showbuiltin] [showmakefile] [config [edit] [<key>] [<key> <value>]] [-t|--template <file>] [--(no-)impl|--(no-)implementation] [--(no-)apl|--(no-)presentation] [--(no-)macro] [--(no-)html] [-h|--help] [-v|--version]\n' "$PROGRAM"
printf 'usage: %s [init] [init-files [DIR]] [showbuiltin] [showmakefile] [config [edit] [<key>] [<key> <value>]] [-t|--template <file>] [--(no-)impl|--(no-)implementation] [--(no-)apl|--(no-)presentation] [--(no-)macro] [--(no-)html] [-h|--help] [-v|--version]\n' "$PROGRAM"
printf '%20s %s\n' "init:" "initialize current working directory for $PROGRAM"
printf '%20s %s\n' "init-files:" "create Section Skeleton Files in current working directory"
printf '%20s %s\n' "init-files:" "create Section Skeleton Files in current working directory or [DIR]"
printf '%20s %s\n' "showbuiltin:" "print builtin iApp Skeleton Template"
printf '%20s %s\n' "showmakefile:" "print example Makefile"
printf '%20s %s\n' "config:" "no arguments: prints full configuration"
Expand Down Expand Up @@ -258,8 +263,8 @@ function parse_cmd() {
fi
;;
init-files)
test $# -gt 1 && err_exit "Too many arugments '$_arg'."
mkinit_files
test $# -gt 2 && err_exit "Too many arugments '$_arg'."
mkinit_files $2
exit 0
;;
showbuiltin)
Expand Down
26 changes: 26 additions & 0 deletions tests/test_init-files.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -ev

# prepare for tests
export PATH="$PATH:$(pwd)"
export BASEDIR=$(pwd)
mkdir ./test_initfiles
cd ./test_initfiles

# init files in current working directory
mkiapp init-files >/dev/null || exit 1

# check if all init-files exist
ls ./macro.tcl || exit 1
ls ./help.html || exit 1
ls ./implementation.tcl || exit 1
ls ./presentation.tcl || exit 1

# init files in ./src directory
mkiapp init-files ./src >/dev/null || exit 1

# check if all init-files in ./src exist
ls ./src/macro.tcl || exit 1
ls ./src/help.html || exit 1
ls ./src/implementation.tcl || exit 1
ls ./src/presentation.tcl || exit 1
19 changes: 13 additions & 6 deletions tests/test_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ export BASEDIR=$(pwd)
mkdir ./test_init
cd ./test_init

# create section files
mkdir ./src
touch ./src/macro.tcl
touch ./src/help.html
touch ./src/implementation.tcl
touch ./src/presentation.tcl

# init mkiapp in current directory
mkiapp init-files >/dev/null || exit 1
mkiapp init >/dev/null || exit 1

# check if all init-files exist
ls ./macro.tcl || exit 1
ls ./help.html || exit 1
ls ./implementation.tcl || exit 1
ls ./presentation.tcl || exit 1
# test if all section files have been detected and loaded to the correct variable
grep -e 'src/macro.tcl' .mkiapp | grep 'MKIAPP_SECTIONFILE_MACRO' || exit 1
grep -e 'src/help.html' .mkiapp | grep 'MKIAPP_SECTIONFILE_HELP' || exit 1
grep -e 'src/implementation.tcl' .mkiapp | grep 'MKIAPP_SECTIONFILE_IMPLEMENTATION' || exit 1
grep -e 'src/presentation.tcl' .mkiapp | grep 'MKIAPP_SECTIONFILE_PRESENTATION' || exit 1

0 comments on commit 8f65b6a

Please sign in to comment.