-
Notifications
You must be signed in to change notification settings - Fork 0
/
cl.fish
134 lines (120 loc) · 3.26 KB
/
cl.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
# Defined in /Users/admin/.config/fish/functions/cl.fish @ line 2
function cl --argument repoToClone
if begin test -z "$repoToClone"
or [ "$repoToClone" = 'help' ]
or [ "$repoToClone" = '-h' ]
or [ "$repoToClone" = '--help' ]
end
if test -z "$repoToClone"
set_color red
echo -e '\n - ERROR: Not Enough Arguments -\n\n'
end
# Custom help/man page
clPrompt
else if test (count $argv) -eq 1
set currPWD (eval pwd)
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
exa -1
echo ' '
else
set FLAG_OR_NEWNAME $argv[2]
set newRepo (string split / "$repoToClone")[-1]
getopts $FLAG_OR_NEWNAME | while read -l key options
switch $key
case _
set newRepoName $FLAG_OR_NEWNAME
set_color cyan
echo -e "\n - New local repo will be `$newRepoName` \n"
set_color normal
git clone https://github.com/$repoToClone.git $newRepoName
cd $newRepoName
set currPWD (eval pwd)
if test (count $argv) -gt 2
set OPTIONS_OR_FLAG $argv[3]
getopts $OPTIONS_OR_FLAG | while read -l selected flags
switch $selected
case _
echo -e 'ERROR: unknown option or default'
case i
if test -e package-lock.json
set_color green
echo -e "\n - Installing Dependencies with NPM...\n"
set_color normal
spin "npm install > /dev/null"
else
set_color green
echo -e "\n - Installing Dependencies with Yarn...\n"
set_color normal
spin "yarn > /dev/null"
end
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
else
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
exa -1
echo ' '
return
end
case i
git clone https://github.com/$repoToClone.git
cd $newRepo
if test -e package-lock.json
set_color green
echo -e "\n - Installing Dependencies with NPM...\n"
set_color normal
spin "npm install > /dev/null"
else
set_color green
echo -e "\n - Installing Dependencies with Yarn...\n"
set_color normal
spin "yarn > /dev/null"
end
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