diff --git a/changelog.md b/changelog.md index cf7c18a8b05e..f39f68856ab4 100644 --- a/changelog.md +++ b/changelog.md @@ -43,6 +43,7 @@ - Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom`. UDP functionality. +- `paramCount` & `paramStr` are now defined in os.nim instead of nimscript.nim for nimscript/nimble. - `dollars.$` now works for unsigned ints with `nim js` ## Language changes diff --git a/compiler/scriptconfig.nim b/compiler/scriptconfig.nim index 13ab03426a49..994a2d3429cf 100644 --- a/compiler/scriptconfig.nim +++ b/compiler/scriptconfig.nim @@ -141,10 +141,12 @@ proc setupVM*(module: PSym; cache: IdentCache; scriptName: string; setResult(a, options.existsConfigVar(conf, a.getString 0)) cbconf nimcacheDir: setResult(a, options.getNimcacheDir(conf).string) - cbconf paramStr: - setResult(a, os.paramStr(int a.getInt 0)) - cbconf paramCount: - setResult(a, os.paramCount()) + result.registerCallback "stdlib.os." & astToStr(paramStr), + proc (a: VmArgs) = + setResult(a, os.paramStr(int a.getInt 0)) + result.registerCallback "stdlib.os." & astToStr(paramCount), + proc (a: VmArgs) = + setResult(a, os.paramCount()) cbconf cmpIgnoreStyle: setResult(a, strutils.cmpIgnoreStyle(a.getString 0, a.getString 1)) cbconf cmpIgnoreCase: diff --git a/koch.nim b/koch.nim index ac7e34a07b5d..9193cb43edac 100644 --- a/koch.nim +++ b/koch.nim @@ -10,7 +10,7 @@ # const - NimbleStableCommit = "4007b2a778429a978e12307bf13a038029b4c4d9" # master + NimbleStableCommit = "6f2b1ace922e565f7f48a69648e16a002a5d15e3" # master when not defined(windows): const diff --git a/lib/pure/os.nim b/lib/pure/os.nim index 2c3e91be8943..d6f6aca5f53a 100644 --- a/lib/pure/os.nim +++ b/lib/pure/os.nim @@ -2707,7 +2707,23 @@ when defined(nimdoc): ## else: ## # Do something else! -elif defined(nintendoswitch) or weirdTarget: +elif defined(nimscript): + proc paramStr*(i: int): string = + ## Retrieves the ``i``'th command line parameter. + discard + + proc paramCount*(): int = + ## Retrieves the number of command line parameters. + discard + +elif defined(js): + proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} = + raise newException(OSError, "paramStr is not implemented on JavaScript") + + proc paramCount*(): int {.tags: [ReadIOEffect].} = + raise newException(OSError, "paramCount is not implemented on JavaScript") + +elif defined(nintendoswitch): proc paramStr*(i: int): TaintedString {.tags: [ReadIOEffect].} = raise newException(OSError, "paramStr is not implemented on Nintendo Switch") diff --git a/lib/system/nimscript.nim b/lib/system/nimscript.nim index f2a843652e7e..e0c400f05367 100644 --- a/lib/system/nimscript.nim +++ b/lib/system/nimscript.nim @@ -56,14 +56,6 @@ proc rawExec(cmd: string): int {.tags: [ExecIOEffect], raises: [OSError].} = proc warningImpl(arg, orig: string) = discard proc hintImpl(arg, orig: string) = discard -proc paramStr*(i: int): string = - ## Retrieves the ``i``'th command line parameter. - builtin - -proc paramCount*(): int = - ## Retrieves the number of command line parameters. - builtin - proc switch*(key: string, val="") = ## Sets a Nim compiler command line switch, for ## example ``switch("checks", "on")``.