This repository was archived by the owner on Sep 5, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig
More file actions
137 lines (111 loc) · 3.37 KB
/
config
File metadata and controls
137 lines (111 loc) · 3.37 KB
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#rainbow
#!/usr/bin/env bash
#tab_size:2
#===============================================================================
# Lux Config
# QodeParty (c) 2018
#===============================================================================
#--------------------------------------------------------------
# Vars - these will be unset on exit
#--------------------------------------------------------------
__bin="$PWD/bin"
__lib="$PWD/lib"
__ch='\xE2\x9C\x94'
__bx='\xE2\x9C\x97'
__ll='\xCE\xBB'
__ul=$(tput smul)
__rul=$(tput rmul)
__g=$(tput setaf 2)
__gr=$(tput setaf 241)
__y=$(tput setaf 11)
__o=$(tput setaf 9)
__bl=$(tput setaf 12)
__x=$(tput sgr0)
#--------------------------------------------------------------
# Funcs - these will be unset on exit
#--------------------------------------------------------------
function luxconf_cleanup(){
local arr=( ll ul rul g gr y o bl ch bx x bin lib)
for i in ${!arr[@]}; do
__="${arr[$i]}"
this="__${__}"
unset $this
done
unset -f luxconf_cleanup
unset -f luxconf_usage
unset -f luxconf_inst
unset -f luxconf_uninst
return 0
}
#----------
function luxconf_usage(){
[ "$0" != "-bash" ] && __iss="\t${__o}Warn: config file must be sourced!${__x}\n" || __iss=
__msg="$(cat <<-EOF
\n${__bl}${__ll}Lux Config${__x}\n
${__iss}
\t${__x}Usage:
\t ${__bl}source ./config install ${__x}
\t ${__bl}source ./config uninstall ${__x}
\t ${__bl}source ./config help ${__x}\n\n
EOF
)";
printf "${__msg}"
}
#----------
function luxconf_inst(){
__msg="$(cat <<-EOF
\n${__bl}${__ll}Lux CLI${__x}
\n\t${__o}${__bx} Removed!${__x} ${__ul}lux/bin${__x} was completely scrubbed from your \$PATH. \n
\t${__x}To re-install:\n
\t ${__g}source ./config install ${__x}\n\n
EOF
)";
printf "${__msg}"
}
#----------
function luxconf_uninst(){
__msg="$(cat <<-EOF
\n${__bl}${__ll}Lux CLI${__x}
\n\t${__g}${__ch} Added!${__x} ${__ul}lux/bin${__x} was temporarily appended to your \$PATH.
\n\tNow you can do stuff with the Lux CLI. Try one of these commands:\n
\t ${__y}lux link ${__x}${__gr}# add LUX to your profile ${__x}
\t ${__y}lux build ${__x}${__gr}# build LUX.css
\t ${__y}lux help ${__x}${__gr}# view usage info\n
\t${__x}To uninstall:\n
\t ${__o}source ./config uninstall ${__x}\n\n
EOF
)";
printf "${__msg}"
}
#--------------------------------------------------------------
# Driver - file must be sourced
#--------------------------------------------------------------
if [ "$0" = "-bash" ]; then
#uninstall
if [[ "${@}" =~ "un" ]]; then
if [[ "$PATH" =~ "$__bin" ]]; then
./bin/lux unlink
printf -v PATH '%s\n' "${PATH//:${__bin}/}"
#printf -v PATH '%s\n' "${PATH//:${__lib}/}"
luxconf_inst
else
printf "${__o}${__bx} Lux CLI is not on your \$PATH ${__x}\n"
fi
#install
elif [[ "${@}" =~ "in" ]]; then
if [[ ! "$PATH" =~ "$__bin" ]]; then
export PATH="$PATH:${__bin}:"
./bin/lux link
luxconf_uninst
else
printf "${__g}${__ch} Lux CLI is already on your \$PATH ${__x}\n"
fi
#help
else
luxconf_usage
fi
#remove namespace pollution
luxconf_cleanup
else
luxconf_usage
fi