-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcopy-clone.fish
164 lines (146 loc) · 6.03 KB
/
copy-clone.fish
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# Defined in /Users/admin/.config/fish/functions/cl.fish @ line 2
function cl --argument repoToClone REST
if begin test -z "$repoToClone"
or test "$repoToClone" = 'help'
end
if test -z "$repoToClone"
set_color red
echo -e '\n - ERROR: Not Enough Arguments -\n\n'
else if test "$repoToClone" = 'help'
echo -e '\n ___________________________________________________________________\n'
echo -e ' \e[4m\e[37mCustom Command\e[39m\e[0m'
echo -e '\n \e[32mcl\e[96mone and setup\e[39m\e[0m\n'
set_color normal
echo -e '\e[90m \e[1m* Run command in a directory *\e[0m'
echo -e '\e[90m \e[1m* where the repo should live *\e[39m\e[0m\n'
end
set_color blue
echo -e ' \e[4mUsage:\e[0m\n'
set_color normal
echo -e ' `cl` [repository to clone] [options]\n\n'
set_color cyan
echo -e ' \e[4mInfo:\e[0m'
set_color normal
echo -e ' Valid shorthand required for [repository to clone] argument.'
set_color red
echo -e ' https://github.com/repo-owner/repo-name.git'
set_color normal
echo -e ' Must be written as...'
set_color green
echo -e ' repo-owner/repo-name\n'
set_color blue
echo -e ' \e[4mOptions:\e[0m\n'
set_color normal
echo -e ' -r: Run any command(s) after cloning'
echo -e ' -i: Install modules with NPM'
echo -e ' -y: Install modules with Yarn'
echo -e ' -o: Open repository in VSCode'
echo -e ' -p: Read `package.json` in terminal\n'
echo -e ' Select any number of options in one flag\n\n'
set_color blue
echo -e ' \e[4mExample:\e[0m\n'
set_color normal
echo -e ' \e[33m$\e[39m \e[32mcl\e[39m SomeGithub/SomeRepo myrepo -iop\n'
set_color red
echo -e ' \e[39m==>\e[31m Remote Repo Cloned Locally,'
set_color magenta
echo -e ' Install Node Modules,'
set_color red
echo -e ' Open Project in IDE,'
set_color magenta
echo -e ' Inspect "package.json"...\n'
set_color normal
echo -e ' ___________________________________________________________________\n\n'
return
end
if test -z "$REST"
set currPWD (eval pwd)
#echo 'no second arg passed'
set newRepo (string split / "$repoToClone")[-1]
git clone https://github.com/$repoToClone.git
cd $newRepo
set_color cyan
echo -e "\n New Repo Setup In:"
set_color normal
echo -e "$currPWD \n"
set_color cyan
echo -e ' With Contents:'
set_color normal
ls -1
echo ' '
else
set newRepo (string split / "$repoToClone")[-1]
getopts $REST | while read -l key options
switch $key
case _
set_color cyan
echo -e "\n - New local repo will be `$newNameOrFlag` \n"
set_color normal
git clone https://github.com/$repoToClone.git $newNameOrFlag
cd $newNameOrFlag
set currPWD (eval pwd)
getopts $flag | while read -l selected flags
switch $selected
case _
echo -e 'ERROR: unknown option or default'
case r
set_color green
echo -e "\n - Running"
case i
set_color green
echo -e '\n - Installing Node Modules...\n'
set_color normal
npm install
case o
set_color green
echo -e '\n - Opening Repository in VSCode...\n'
set_color normal
code .
case p
set_color green
echo -e '\n - Viewing `package.json` in Terminal...\n'
set_color normal
micro './package.json'
case '*'
echo -e 'ERROR: unknown option or default'
return
end
end
set_color cyan
echo -e '\n New Repo Setup In:'
set_color normal
echo -e " $currPWD"
set_color cyan
echo -e '\n With Contents:'
set_color normal
ls -1
echo ' '
return
case i
git clone https://github.com/$repoToClone.git
cd $newRepo
set_color green
echo -e '\n - Installing Node Modules...\n'
set_color normal
npm install
case o
set_color green
echo -e '\n - Opening Repository in VSCode...\n'
set_color normal
code .
case p
git clone https://github.com/$repoToClone.git
cd $newRepo
set_color green
echo -e '\n - Viewing `package.json` in Terminal...\n'
set_color normal
micro './package.json'
case '*'
set_color red
echo -e 'ERROR: Caught Execption...Flag not recognized.\n'
set_color normal
return
end
end
end
end