File tree Expand file tree Collapse file tree 1 file changed +14
-5
lines changed
Expand file tree Collapse file tree 1 file changed +14
-5
lines changed Original file line number Diff line number Diff line change 11module IsAvailable
22
3+ @doc """ A function that gets the status of a package at the link https://juliapackages.com/p/ """ ->
34function isavailable (name:: String )
45 url = " https://juliapackages.com/p/" * lowercase (name)
56 try
@@ -12,17 +13,25 @@ function isavailable(name::String)
1213 end
1314end
1415
16+ @doc """ A function that gets the status of several packages in a list""" ->
1517function app (names:: Array{String, 1} )
1618 for name in names
1719 if isavailable (name)
1820 print (name* " is available. Do you wanna to install it? [type y(yes) or n(no)] " )
1921 answer = readline ()
20- if lowercase (answer) == " y"
21- Pkg. add (name)
22- elseif lowercase (answer) == " n"
22+ validAnswers = [" yes" , " no" , " y" , " n" ]
23+ while lowercase (answer) ∉ validAnswers
24+ print (" Please, type some valid option: [y] yes and [n] no. " )
25+ answer = readline ()
26+ end
27+ if lowercase (answer) ∈ [" yes" , " y" ]
28+ try
29+ Pkg. add (name)
30+ catch
31+ print (" Oops! I did it again. Check out the name of the package... It may be wrong" )
32+ end
33+ elseif lowercase (answer) ∈ [" no" , " n" ]
2334 print (" Okay... Bye!" )
24- else
25- print (" Oops! I did it again. Check out the name of the package... It may be wrong" )
2635 end
2736 end
2837 end
You can’t perform that action at this time.
0 commit comments