dom96 / choosenim

Tool for easily installing and managing multiple versions of the Nim programming language.
BSD 3-Clause "New" or "Revised" License
679 stars 67 forks source link

choosenim self tries to download Nim with choosenim version #322

Open dlesnoff opened 1 year ago

dlesnoff commented 1 year ago

I tried to run (by mistake)

choosenim self

which gave:

Downloading Nim 0.8.4 from nim-lang.org

      Info: Binary build unavailable, building from source

       Tip: 2 messages have been suppressed, use --verbose to show them.
     Error: /__w/choosenim/choosenim/src/choosenim.nim(350) choosenim
        ... /__w/choosenim/choosenim/src/choosenim.nim(340) performAction
        ... /__w/choosenim/choosenim/src/choosenim.nim(124) choose
        ... /__w/choosenim/choosenim/src/choosenim.nim(111) chooseVersion
        ... /__w/choosenim/choosenim/src/choosenim.nim(24) installVersion
        ... /__w/choosenim/choosenim/src/choosenimpkg/download.nim(316) download
        ... Version 0.8.4 does not exist.

It tried to download the Nim 0.8.4 version with my choosenim version: 0.8.4 This is not a problem since this Nim version does not exist, but it could become problematic if choosenim version matches an existing Nim version.

Expected output

Either an error or self becomes an alias of update self

SpotlightKid commented 11 months ago

Seems to be an easy fix:

(added self to command check and ordered of clauses alphabetically)

diff --git a/src/choosenim.nim b/src/choosenim.nim
index 7493878..fba9c81 100644
--- a/src/choosenim.nim
+++ b/src/choosenim.nim
@@ -328,14 +328,16 @@ proc performAction(params: CliParams) =
   report(initEvent(ActionEvent), params)

   case params.command.normalize
-  of "update":
-    update(params)
+  of "remove":
+    remove(params)
+  of "self":
+    updateSelf(params)
   of "show":
     show(params)
+  of "update":
+    update(params)
   of "versions":
     versions(params)
-  of "remove":
-    remove(params)
   else:
     choose(params)