Dotfiles/bin/.bin/project-management/project-copy
2019-10-23 20:31:04 +01:00

60 lines
1.1 KiB
Bash
Executable file

#!/usr/bin/env bash
function print_help(){
echo -e "copy <target> <files> [..<files>]\t\tCopies files to a target in the project"
echo -e "\t--target <target_dir>\tCopy files to a target directory in the project"
echo -e "\t--bin\tShortcut to copy to bin folder (inside \$PATH)"
echo -e "\t--www\tShortcut to copy to the www directory"
}
function copy(){
local current="$(get_current --path)"
local target="$1"
shift
local files="$@"
local destination= "$current/$target"
if [[ "$target" == "--NONE" ]]; then
local destination= "$current/"
fi
if [[ -n "$destination" ]]; then
mkdir -p "$destination"
cp -r "$files" "$destination"
fi
}
if [ -n "$1" ]; then
case "$1" in
-h|--help)
print_help | column -t -s" "
exit 0
;;
--parent-help)
print_help
exit 0
;;
--target)
target="$2"
shift
shift
copy "$target" "$@"
exit 0
;;
--www)
shift
copy "www" "$@"
exit 0
;;
--bin)
shift
copy "bin" "$@"
exit 0
;;
*)
copy "--NONE" "$@"
exit 0
;;
esac
else
read_prompt | xargs project-new
fi