diff --git a/build.sh b/build.sh index adf2670..997b3ad 100755 --- a/build.sh +++ b/build.sh @@ -1,11 +1,40 @@ #!/bin/bash EXEC=dam +gen_help() { + for file in $(find help/ -type f -printf "%P\n"); do + echo -e " + # ${file} help + help_${file}() { + echo -e \"" + cat help/${file} + echo -e "\" + }" + done -echo -e "#!/bin/bash\n" > ${EXEC} +} -for file in src/env $(find bunc/src -type f) $(find src/ -type f -not -name env -not -name parser) src/parser; do - awk '!/^ *#/ && NF' ${file} >> ${EXEC} -done +gen_env() { + echo -e "#!/bin/bash\n" + echo "VERSION=$(git describe --tags)" + awk '!/^ *#/ && NF' src/env +} + +gen_function() { + functionList=(${@}) + for function in ${functionList[@]}; do + awk '!/^ *#/ && NF' ${function} + done +} + +gen_parser() { + awk '!/^ *#/ && NF' src/parser +} + +gen_env > ${EXEC} +gen_help >> ${EXEC} +gen_function $(find src/ -type f -not -name env -not -name parser) >> ${EXEC} +gen_function $(find bunc/src/ -type f) >> ${EXEC} +gen_parser >> ${EXEC} chmod +x ${EXEC} diff --git a/help/conditions b/help/conditions new file mode 100644 index 0000000..da93e5b --- /dev/null +++ b/help/conditions @@ -0,0 +1,17 @@ +Conditions + +Note + Conditions are defined using the following format: + = + The metadta field can be anything that can be injected as metadta in a Vorbis tag. + +Example + You want to exclude everything from "GENRE" "Pop": + dam exclude "GENRE=Pop" + + ...but want to keep Lady Gaga, just because + dam include "ARTIST=Lady Gaga" + + ...but not THAT album + dam exclude "ALBUM=THAT" + diff --git a/help/general b/help/general new file mode 100644 index 0000000..57a431d --- /dev/null +++ b/help/general @@ -0,0 +1,19 @@ +Usage: dam [--help] [--info] [] + +Options + --git-dir= + Defines path to git directory that contains the music collection. Defaults to current directory when not set. + +Commands + update + Populates database present in target folder with new images. + deploy + Deploys tracks to target folder, with applies metadata and cover image + exclude [] + Exclude tracks based on conditions (see dam --help conditions for more information) + include [] + Include tracks based on conditions (see dam --help conditions for more information) + du + Prints total projected disk usage of currently selected tracks + fsck + Does a series of tests on target's database file diff --git a/help/info b/help/info new file mode 100644 index 0000000..71bf2eb --- /dev/null +++ b/help/info @@ -0,0 +1,6 @@ +dam ${VERSION} +Copyright (c) 2018 Antoine Martin + +Distributed under the GNU Affero General Public License (AGPL v3) +See LICENSE or http://www.gnu.org/licenses/agpl.html + diff --git a/src/parser b/src/parser index a0463ab..c68e4c1 100644 --- a/src/parser +++ b/src/parser @@ -10,12 +10,15 @@ GIT_DIR="./" while true; do case ${1} in --help) - help + shift + HELP="${1}" + [[ -z "${HELP}" ]] && HELP=general + eval help_${HELP} exit ;; --info) - help info + help_info exit ;;