all repos — min @ 9af8b3ba97f2d16f18b6dbfff31bed3beb138a26

A small but practical concatenative programming language.

Implemented list command.
h3rald h3rald@h3rald.com
Thu, 30 Nov 2023 14:10:28 +0100
commit

9af8b3ba97f2d16f18b6dbfff31bed3beb138a26

parent

5f64830f186d4ae43cd948deb2304f6b276033e9

2 files changed, 23 insertions(+), 3 deletions(-)

jump to
M min.nimmin.nim

@@ -160,7 +160,8 @@ init Sets up the current directory as a managed min module.

install [<module> <version>] Install the specified managed min module or all dependent modules. uninstall [<module> <version>] Uninstall the specified managed min module or all dependent modules. update [<module> <version>] Update the specified managed min module or all dependent modules. - search [...terms...] Search for a module matching the specified terms. + search [...terms...] Search for a managed min module matching the specified terms. + list List all managed min modules installed in the local directory or globally. Options: -a, --asset-path Specify a directory containing the asset files to include in the compiled executable (if -c is set)

@@ -296,6 +297,11 @@ var str = ""

if args.len > 1: str = args[1 .. ^1].join(" ") executeMmmCmd(proc () = MMM.search(str)) + elif file == "list": + if GLOBAL: + executeMmmCmd(proc () = MMM.list(MMM.globalDir)) + else: + executeMmmCmd(proc () = MMM.list(MMM.localDir)) minFile fn, op elif SIMPLEREPL: minSimpleRepl()
M minpkg/core/mmm.nimminpkg/core/mmm.nim

@@ -16,8 +16,8 @@ type

MinModuleManager* = object registry: string modules = %[] - globalDir: string - localDir: string + globalDir*: string + localDir*: string MMMError = ref object of CatchableError MMMAlreadyInstalledError = ref object of MMMError

@@ -302,3 +302,17 @@ notice " Description: $#" % [m["description"].getStr]

notice " Author: $#" % [m["author"].getStr] notice " License: $#" % [m["license"].getStr] notice " Dependencies: $#" % [m["deps"].formatDeps] + +proc list*(MMM: var MinModuleManager, dir: string, level = 0) = + debug "Directory: " & dir + if not dir.dirExists: + return + for name in dir.walkDir: + debug "Module directory: " & name.path + if name.kind == pcDir or name.kind == pcLinkToDir: + for version in (name.path).walkDir: + debug "Module version directory: " & version.path + if name.kind == pcDir or name.kind == pcLinkToDir: + notice " ".repeat(level) & "$#@$#" % [name.path.lastPathPart, version.path.lastPathPart] + MMM.list version.path/"mmm", level+1 +