-
Notifications
You must be signed in to change notification settings - Fork 5
/
osx-screencast.sh
executable file
·76 lines (65 loc) · 1.49 KB
/
osx-screencast.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
source `which ${BASH_SOURCE[0]}-dependencies`
source `which ${BASH_SOURCE[0]}-record`
source `which ${BASH_SOURCE[0]}-export`
## outputs usage
osx_screenshot_usage () {
echo "usage: osx-screenshot [-hV]"
echo " or: osx-screenshot record [-h] [-a application]"
echo " or: osx-screenshot export [-h] [-f fps] [-s scale] [-d delay] <src> <dest>"
return 0
}
## outputs version
osx_screenshot_version () {
echo "0.0.1"
}
## main
osx_screenshot () {
local cmd=""
local arg="${1}"
## enure dependencies exist or bail
osx_screenshot_dependencies || return $?
if [ -z "${arg}" ]; then
osx_screenshot_usage
return 1
fi
## parse opts
case "${arg}" in
-h|--help)
osx_screenshot_usage
return 0
;;
-V|--version)
osx_screenshot_version
return 0
;;
*)
## dynamically create command from originating
## script caller
cmd="osx_screenshot_${arg}"
shift
if [ "-" = "${arg:0:1}" ]; then ## unknown flags
echo >&2 "error: Unknown option \`${arg}'"
osx_screenshot_usage
return 1
else ## proxy commands
if type "${cmd}" > /dev/null 2>&1; then
( "${cmd}" "${@}" )
return $?
else
echo >&2 "error: Unknown command \`${arg}'"
osx_screenshot_usage
return 1
fi
fi
;;
esac
return 0
}
## export
if [[ ${BASH_SOURCE[0]} != $0 ]]; then
export -f osx_screenshot
else
osx_screenshot "${@}"
exit $?
fi