nekopkg.nim
unknown
nim
2 years ago
1.9 kB
8
Indexable
Never
import parsecfg import os import httpclient import zippy/ziparchives var pkg_base* = loadConfig("$HOME/.nekopkg/base.ini") const standard_base* = "http://raw.githubusercontent.com/blaze-arch/nekopkg_base/main/base.ini" const install_directory* = "./test/" const localbase_packages* = "$HOME/.nekopkg/installed_packages/" proc install_pkg*(pkgname: string) = if (fileExists(localbase_packages & pkgname)): echo "Package already installed (^ω^)" echo "Do you wanna reinstall this package?? [Y/N]" let command = stdin.readLine() if (command == "Y" or command == "y"): echo "Reinstalling package..." else: quit(QuitSuccess) var client = newHttpClient() try: discard pkg_base.getSectionValue(pkgname, "link") except: echo "Package does not exist!" quit(QuitFailure) let package_link = pkg_base.getSectionValue(pkgname, "link") try: discard client.getContent(package_link) except: echo "Can't download package!" echo "Check internet connection" quit(QuitFailure) writeFile(pkgname, client.getContent(package_link)) try: extractAll(pkgname, "./tmp/") echo "Extracting package, please wait..." except: echo "Error! Can't extract package! :(" quit(QuitFailure) try: copyDir("./tmp/", install_directory) removeDir("./tmp/") copyFile("./" & pkgname, install_directory & pkgname) except: echo "Error! Can't install package! :(" echo "You are not run nekopkg from root?" quit(QuitFailure) echo "Package Installed! ( ̄▽ ̄)" quit(QuitSuccess) proc find_pkgs*(search_string: string) = echo "In development, sorry :(" proc update_pkg_base*() = var client = newHttpClient() writeFile("$HOME/.nekopkg/base.ini", client.getContent(standard_base) # invalid indecation