You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
149 lines
3.3 KiB
149 lines
3.3 KiB
#!/bin/bash
|
|
set -e
|
|
|
|
dir="$(readlink -f "$(dirname "$(readlink -f ${BASH_SOURCE[0]})")/..")"
|
|
source "$dir/bin/includes/includes"
|
|
if [ -f "$dir/etc/config" ]
|
|
then
|
|
source "$dir/etc/config"
|
|
fi
|
|
|
|
if [ -f "$dir/etc/projects" ]
|
|
then
|
|
source "$dir/etc/projects"
|
|
fi
|
|
|
|
function use {
|
|
echo
|
|
echoMainTitle "Sumedia Project Manager"
|
|
echoSmall "Manager: $project_manager_dir"
|
|
echoSmall "Workspaces: $workspaces_dir"
|
|
echo
|
|
echoSubTitle "Usage:"
|
|
echo
|
|
echo "project-manager [command] [command-args]"
|
|
echo "project-manager [plugin:command] [command-args]"
|
|
echo
|
|
echo "--help Prints this message"
|
|
echo "--help [command] Prints the help message for a command"
|
|
echo "--help [plugin:command] Prints the help message for a command"
|
|
echo "--list-commands List all commands"
|
|
echo "--list-commands [plugin] List all plugin commands"
|
|
echo "--list-plugins List all plugins"
|
|
echo
|
|
}
|
|
|
|
function list {
|
|
local dir=$1
|
|
|
|
echo >&2
|
|
echoSubTitle "List $dir" >&2
|
|
echo >&2
|
|
|
|
dir=($(ls -t "$project_manager_dir/$dir"))
|
|
for script in "${dir[@]}"
|
|
do
|
|
echo "- $script" >&2
|
|
done
|
|
echo >&2
|
|
}
|
|
|
|
if [ "$1" == "" ] && [ -f "$project_manager_dir/etc/config" ] && [ -f "$project_manager_dir/etc/projects" ]
|
|
then
|
|
use
|
|
exit
|
|
fi
|
|
|
|
help="$(getParameter "--help" false "$*")"
|
|
list_commands="$(getParameter "--list-commands" false "$*")"
|
|
list_plugins="$(getParameter "--list-plugins" false "$*")"
|
|
|
|
if [[ "$1" == *"--"* ]]; then key=2; else key=1; fi
|
|
param="$(eval "echo \"\$${key}\"")"
|
|
if [[ "$param" == *":"* ]]
|
|
then
|
|
command="$(echo "$param" | cut -f2 -d':')"
|
|
plugin="$(echo "$param" | cut -f1 -d':')"
|
|
else
|
|
command=$param
|
|
plugin=""
|
|
fi
|
|
|
|
if [ ! -f "$project_manager_dir/etc/config" ] || [ ! -f "$project_manager_dir/etc/projects" ]
|
|
then
|
|
command="install-project-manager"
|
|
plugin=""
|
|
fi
|
|
|
|
if [ "$help" == true ] || [ "$list_commands" == true ] || [ "$list_plugins" == "true" ]
|
|
then
|
|
|
|
if [ "$command" == "" ]
|
|
then
|
|
use
|
|
exit
|
|
elif [ "$command" != "" ] && [ "$plugin" != "" ] && [ "$help" == true ]
|
|
then
|
|
file="$project_manager_dir/plugins/$plugin/commands/$command"
|
|
if [ ! -f "$file" ]
|
|
then
|
|
echo
|
|
echoError "No such file or directory: $file"
|
|
echo
|
|
exit
|
|
else
|
|
source "$file" --help
|
|
exit
|
|
fi
|
|
elif [ "$command" != "" ] && [ "$help" == true ]
|
|
then
|
|
file="$project_manager_dir/bin/commands/$command"
|
|
if [ ! -f "$file" ]
|
|
then
|
|
echo
|
|
echoError "No such file or directory: $file"
|
|
echo
|
|
exit
|
|
else
|
|
source "$file" --help
|
|
exit
|
|
fi
|
|
elif [ "$command" != "" ] && [ "$plugin" != "" ] && [ "$list_commands" == true ]
|
|
then
|
|
list "plugins/$plugin/commands"
|
|
elif [ "$command" != "" ] && [ "$list_commands" == true ]
|
|
then
|
|
list "bin/commands"
|
|
elif [ "$list_plugins" == true ]
|
|
then
|
|
list "plugins"
|
|
fi
|
|
|
|
else
|
|
|
|
if [ "$plugin" != "" ]
|
|
then
|
|
file="$project_manager_dir/plugins/$plugin/commands/$command"
|
|
else
|
|
file="$project_manager_dir/bin/commands/$command"
|
|
fi
|
|
|
|
if [ ! -f "$file" ]
|
|
then
|
|
echo
|
|
echoError "No such file or directory: $file"
|
|
echo
|
|
exit
|
|
else
|
|
source "$file" "${@:2}"
|
|
fi
|
|
|
|
echo
|
|
echoSubTitle "Running postscripts ..."
|
|
postScript "$project_manager_dir/bin/postscripts/project-manager"
|
|
|
|
echo
|
|
echoSuccess "Project Manager done"
|
|
echo
|
|
|
|
fi
|