Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #! /bin/bash
- #Usage:
- #There are 3 argument structures:
- #-a <name : string> <type : string> <compress : bool> <delete: bool> <destination : string> <address : string>
- #-m <name :string> <current_dir : string> <new_dir : string>
- #-r <name : string> <directory : string>
- #list of sources to download.
- repo_list="repo_list.txt"
- error() {
- echo "error: $@" 1>&2
- exit 1
- }
- assert_cmd() {
- command -v "$1" &>/dev/null || error "command $1 does not exist"
- }
- verify_add() {
- printf "%s\n" "$@" "" >> "${repo_list}"
- }
- verify_backup() {
- # ??? dude what ???
- #files.
- if [ -f "$2"+"$1"+".*" ]; then
- rm -rf "$2"+="$1"+=".*"
- fi
- #folders.
- if [ -d "$2"+"$1"+".*" ]; then
- rm -rf "$2"+"$1"
- fi
- }
- verify_repository() {
- case "$1" in
- git)
- assert_cmd git
- git ls-remote --exit-code --heads "$2" master || return
- ;;
- svn)
- assert_cmd svn
- # ...
- ;;
- *)
- error "invalid repository type $1"
- ;;
- esac
- }
- # etc ...
- while getopts amr opt; do
- case "${opt}" in
- a)
- (( $# < 7 )) && error "missing command line arguments"
- # these commands don't fail
- verify_add "$1" "$3" "$6" "$7"
- verify_backup "$2" "$6"
- # this one might
- verify_repository "$3" "$7" || error "cannot verify repository"
- # ...
- ;;
- [mr])
- error "not yet implemented"
- ;;
- *)
- error "unknown option"
- ;;
- esac
- done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement