[build.sh] Rewritten to build help menus
[help/conditions] [help/general] [help/info] Initial version [parser] Added support for help
This commit is contained in:
parent
dc6464ab54
commit
342d7d7eed
5 changed files with 80 additions and 6 deletions
37
build.sh
37
build.sh
|
@ -1,11 +1,40 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
EXEC=dam
|
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
|
gen_env() {
|
||||||
awk '!/^ *#/ && NF' ${file} >> ${EXEC}
|
echo -e "#!/bin/bash\n"
|
||||||
done
|
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}
|
chmod +x ${EXEC}
|
||||||
|
|
17
help/conditions
Normal file
17
help/conditions
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
Conditions
|
||||||
|
|
||||||
|
Note
|
||||||
|
Conditions are defined using the following format:
|
||||||
|
<metadatafield>=<value>
|
||||||
|
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"
|
||||||
|
|
19
help/general
Normal file
19
help/general
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
Usage: dam [--help] [--info] [<options>] <command> <args>
|
||||||
|
|
||||||
|
Options
|
||||||
|
--git-dir=</path/to/git/dir>
|
||||||
|
Defines path to git directory that contains the music collection. Defaults to current directory when not set.
|
||||||
|
|
||||||
|
Commands
|
||||||
|
update </path/to/target>
|
||||||
|
Populates database present in target folder with new images.
|
||||||
|
deploy </path/to/target>
|
||||||
|
Deploys tracks to target folder, with applies metadata and cover image
|
||||||
|
exclude </path/to/target> <condition> [<additional condition>]
|
||||||
|
Exclude tracks based on conditions (see dam --help conditions for more information)
|
||||||
|
include </path/to/target> <condition> [<additional condition>]
|
||||||
|
Include tracks based on conditions (see dam --help conditions for more information)
|
||||||
|
du </path/to/target>
|
||||||
|
Prints total projected disk usage of currently selected tracks
|
||||||
|
fsck </path/to/target>
|
||||||
|
Does a series of tests on target's database file
|
6
help/info
Normal file
6
help/info
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
dam ${VERSION}
|
||||||
|
Copyright (c) 2018 Antoine Martin <antoine.martin@protonmail.com>
|
||||||
|
|
||||||
|
Distributed under the GNU Affero General Public License (AGPL v3)
|
||||||
|
See LICENSE or http://www.gnu.org/licenses/agpl.html
|
||||||
|
|
|
@ -10,12 +10,15 @@ GIT_DIR="./"
|
||||||
while true; do
|
while true; do
|
||||||
case ${1} in
|
case ${1} in
|
||||||
--help)
|
--help)
|
||||||
help
|
shift
|
||||||
|
HELP="${1}"
|
||||||
|
[[ -z "${HELP}" ]] && HELP=general
|
||||||
|
eval help_${HELP}
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
--info)
|
--info)
|
||||||
help info
|
help_info
|
||||||
exit
|
exit
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue