From 0c7e29054fedd14c08e7332bafaf58bb92d89004 Mon Sep 17 00:00:00 2001 From: Drew Short Date: Tue, 16 Jan 2018 23:43:09 -0600 Subject: [PATCH] Moved to the switch syntax --- src/spm/spm.moon | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/spm/spm.moon b/src/spm/spm.moon index 1c5ae41..e34325a 100644 --- a/src/spm/spm.moon +++ b/src/spm/spm.moon @@ -344,7 +344,7 @@ installPackage = (requestedPackage, installPath, doUpdate) -> for filePath, requestedInstallPath in pairs(packageInfo.files) installedPath - if string.find(requestedInstallPath, "^//") + if string.find(requestedInstallPath, "^//") localInstalledPath = string.sub(requestedInstallPath, 2) if not fs.exists(localInstalledPath) fs.makeDirectory(localInstalledPath) @@ -475,19 +475,18 @@ updatePackage = (requestedPackage) -> else installPackage(args[2], nil, true) -if args[1] == "list" - tPacks = listPackages(args[2]) - printPackages(tPacks) -elseif args[1] == "info" - provideInfo(args[2]) -elseif args[1] == "install" or args[1] == "add" - installPackage(args[2], args[3], false) -elseif args[1] == "update" or args[1] == "upgrade" - updatePackage(args[2]) -elseif args[1] == "uninstall" or args[1] == "remove" - uninstallPackage(args[2]) -elseif args[1] == "copy" - copyPackage(args[2], args[3]) -else - printUsage() - return \ No newline at end of file +switch args[1] + when "list" + printPackages(listPackages(args[2])) + when "info" + provideInfo(args[2]) + when "install" or "add" + installPackage(args[2], args[3], false) + when "update" or "upgrade" + updatePackage(args[2]) + when "uninstall" or "remove" + uninstallPackage(args[2]) + when "copy" + copyPackage(args[2], args[3]) + else + printUsage() \ No newline at end of file