all repos — min @ c117e1e523c2c549128c8ed21e4124433787ee8e

A small but practical concatenative programming language.

Started implementing min init command.
h3rald h3rald@h3rald.com
Tue, 28 Nov 2023 15:27:39 +0100
commit

c117e1e523c2c549128c8ed21e4124433787ee8e

parent

a15cce5b8cd12577828cfacd4131d56694b2a01e

4 files changed, 47 insertions(+), 13 deletions(-)

jump to
M .gitignore.gitignore

@@ -11,6 +11,7 @@ libdyntools*

dyntools.nim *.zip packages/ +**/*/mmm site/assets/downloads/ site/output/ site/temp/
M min.nimmin.nim

@@ -244,21 +244,24 @@ logging.error "[help] No symbol to lookup was specified."

quit(9) minStr("\"$#\" help" % [args[1]]) quit(0) - elif file == "install": + elif file == "init": + MMM.setup() MMM.init() + quit(0) + elif file == "install": logging.error "[install] Not implemented." quit(100) - elif file == "remote": - logging.error "[install] Not implemented." + elif file == "remove": + logging.error "[remove] Not implemented." quit(100) elif file == "update": - logging.error "[install] Not implemented." + logging.error "[update] Not implemented." quit(100) elif file == "info": - logging.error "[install] Not implemented." + logging.error "[info] Not implemented." quit(100) elif file == "search": - logging.error "[install] Not implemented." + logging.error "[search] Not implemented." quit(100) minFile fn, op elif SIMPLEREPL:
M minpkg/core/mmm.nimminpkg/core/mmm.nim

@@ -18,17 +18,17 @@ globalDir: string

localDir: string -proc init*(MMM: var MinModuleManager) = +proc setup*(MMM: var MinModuleManager) = MMM.registry = MMMREGISTRY MMM.globalDir = HOME / "mmm" - MMM.localDir = os.getCurrentDir() / "mmm" + MMM.localDir = getCurrentDir() / "mmm" var updatedLocal = 0 let mmmJson = MMM.globalDir / "mmm.json" - if not os.dirExists(MMM.globalDir): - os.createDir(MMM.globalDir) - if not os.dirExists(MMM.localDir): - os.createDir(MMM.localDir) - if os.fileExists(mmmJson): + if not dirExists(MMM.globalDir): + createDir(MMM.globalDir) + if not dirExists(MMM.localDir): + createDir(MMM.localDir) + if fileExists(mmmJson): try: let data = parseFile(mmmJson) updatedLocal = data["updated"].getInt

@@ -62,4 +62,24 @@ error "Invalid local registry data ($#)" % [mmmJson]

else: logging.debug "Local registry up-to-date: $#" % [$updatedLocal] +proc init*(MMM: var MinModuleManager) = + let pwd = getCurrentDir() + if dirExists(pwd / "mmm.json"): + error "The current directory already contains a managed module (mmm.json already exists)" + logging.debug "Creating mmm.json file" + let json = """ +{ + "name": "$#", + "method": "git", + "url": "", + "author": "", + "description": "", + "license": "", + "deps": {} +} + """ % [pwd.lastPathPart] + writeFile(pwd / "mmm.json", json) + if not dirExists(pwd / "mmm"): + logging.debug "Creating mmm directory" + createDir(pwd / "mmm")
A site/mmm.json

@@ -0,0 +1,10 @@

+{ + "name": "site", + "method": "git", + "url": "", + "author": "", + "description": "", + "license": "", + "deps": {} +} +