-
Notifications
You must be signed in to change notification settings - Fork 1
/
crater
executable file
·59 lines (50 loc) · 1.76 KB
/
crater
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
#!/usr/bin/env bash
app_url="https://crater.myterminal.me"
command_name=${1}
case ${command_name} in
version | --version | -v)
echo "Still under development!"
;;
search)
available_sources=$(/bin/bash -c "$(curl -s ${app_url}/list-sources)")
search_term=${2}
url="${app_url}/search?s=${available_sources}&t=${search_term}"
/bin/bash -c "$(curl -s ${url})"
;;
list)
available_sources=$(/bin/bash -c "$(curl -s ${app_url}/list-sources)")
url="${app_url}/list?s=${available_sources}"
/bin/bash -c "$(curl -s ${url})"
;;
install)
available_sources=$(/bin/bash -c "$(curl -s ${app_url}/list-sources)")
arguments=${@:2}
package_names=$(echo ${arguments} | tr ' ' ',')
url="${app_url}/install?s=${available_sources}&p=${package_names}"
/bin/bash -c "$(curl -s ${url})"
;;
uninstall)
available_sources=$(/bin/bash -c "$(curl -s ${app_url}/list-sources)")
arguments=${@:2}
package_names=$(echo ${arguments} | tr ' ' ',')
url="${app_url}/uninstall?s=${available_sources}&p=${package_names}"
/bin/bash -c "$(curl -s ${url})"
;;
update)
available_sources=$(/bin/bash -c "$(curl -s ${app_url}/list-sources)")
arguments=${@:2}
package_names=$(echo ${arguments} | tr ' ' ',')
url="${app_url}/update?s=${available_sources}&p=${package_names}"
/bin/bash -c "$(curl -s ${url})"
;;
*)
echo "Please specify one of the following options:"
echo " help / --help / -h"
echo " version / --version / -v"
echo " search"
echo " list"
echo " install"
echo " uninstall"
echo " update"
;;
esac