all repos — nifty @ fb3f1b6aec53a432d8c0182b761099979d0cf133

A tiny (pseudo) package manager and script runner.

Added tasklists to help, no longer printing warnings in case of missing commands.
h3rald h3rald@h3rald.com
Sat, 19 Sep 2020 11:29:24 +0200
commit

fb3f1b6aec53a432d8c0182b761099979d0cf133

parent

603c2078d088114c7f43529916695f5461372a07

M Nifty_UserGuide.mdNifty_UserGuide.md

@@ -428,7 +428,7 @@

The following sections describe the default system commands. Unlike [custom commands](#Default-custom-commands), system commands _cannot_ be customized and do not require external programs to run. {#command||help||help [<command>]|| -Display help on the specified command (or all commands). +Display help on the specified command (or all tasklists and commands). #} {#command||info||info <package>||
M src/nifty.nimsrc/nifty.nim

@@ -3,6 +3,7 @@ json,

os, parseopt, logging, + algorithm, strutils, sequtils

@@ -245,9 +246,11 @@ echo "$1:\t$2" % [k, $v]

of "help": echo "" if args.len < 2: - for k, v in prj.help.pairs: - printGreen " nifty $1" % v["_syntax"].getStr - echo "\n $1\n" % v["_description"].getStr + var sortedKeys = toSeq(prj.help.keys) + sortedKeys.sort(cmp[string]) + for k in sortedKeys: + printGreen " nifty $1" % prj.help[k]["_syntax"].getStr + echo "\n $1\n" % prj.help[k]["_description"].getStr else: let cmd = args[1] let help = prj.help[cmd]
M src/niftypkg/config.nimsrc/niftypkg/config.nim

@@ -1,5 +1,5 @@

const pkgTitle* = "nifty" - pkgVersion* = "1.2.0" + pkgVersion* = "1.2.1" pkgAuthor* = "Fabio Cevasco" pkgDescription* = "A decentralized (pseudo) package manager and script runner."
M src/niftypkg/nifty.jsonsrc/niftypkg/nifty.json

@@ -1,5 +1,6 @@

{ "storage": "$1", + "tasklists": {}, "commands": { "install":
M src/niftypkg/project.nimsrc/niftypkg/project.nim

@@ -52,6 +52,15 @@ proc help*(prj: var NiftyProject): JsonNode =

result = systemHelp.parseJson if prj.configured: prj.load + for k, v in prj.tasklists.pairs: + let syntax = "$$$1" % k + let description = "Executes: $1" % v.elems.mapIt(it.getStr).join(", ") + result["$"&k] = (""" + { + "_syntax": "$1", + "_description": "$2" + } + """ % [syntax, description]).parseJson for k, v in prj.commands.pairs: if v.hasKey("_syntax") and v.hasKey("_description"): result[k] = ("""

@@ -138,7 +147,7 @@ pwd.createDir()

pwd.setCurrentDir() result = execShellCmd cmd else: - warn "Command '$1' not available for package '$2'" % [command, alias] + debug "Command '$1' not available for package '$2'" % [command, alias] setCurrentDir(prj.dir) proc executeRec*(prj: var NiftyProject, command, alias: string) =