diff --git a/readme.markdown b/readme.markdown index 185835be..9c1f9243 100644 --- a/readme.markdown +++ b/readme.markdown @@ -733,7 +733,7 @@ installing your package (on macOS): ### Nim compiler The Nim compiler cannot read .nimble files. Its knowledge of Nimble is -limited to the ``nimblePaths`` feature which allows it to use packages installed +limited to the ``nimblePath`` feature which allows it to use packages installed in Nimble's package directory when compiling your software. This means that it cannot resolve dependencies, and it can only use the latest version of a package when compiling. @@ -746,6 +746,27 @@ This means that you can safely compile using the compiler when developing your software, but you should use Nimble to build the package before publishing it to ensure that the dependencies you specified are correct. +### Compile with `nim` after changing the nimble directory + +The Nim compiler has been preconfigured to look at the default nimble directory while compiling, +so no extra step is required to use nimble managed packages in your code. +However, if you are using a custom `nimbleDir`, you need to specify the +`--nimblePath:PATH` option. For example, +if your `nimble` directory is located at `/some/custom/path/nimble`, this should work: + +``` +nim c --nimblePath:/some/custom/path/nimble/pkgs main.nim +``` + +Some code editors rely on `nim check` to check for errors under the hood (e.g. VScode), +and the editor extension may not allow users to pass custom option to `nim check`, which +will cause `nim check` to scream `Error: cannot open file:`. In this case, +you will have to use [Nim compiler's configuration files](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files). Simply add the line: +``` +nimblePath = "/some/custom/path/nimble/pkgs" +``` +to the `nim.cfg` located in any directory listed in the [documentation](https://nim-lang.org/docs/nimc.html#compiler-usage-configuration-files), this should resolve the problem. + ### Versions Versions of cloned packages via Git or Mercurial are determined through the diff --git a/src/nimble.nim b/src/nimble.nim index 807abdc8..fe165d7f 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -1002,7 +1002,17 @@ proc test(options: Options) = optsCopy.action.compileOptions = @[] optsCopy.action.compileOptions.add("-r") optsCopy.action.compileOptions.add("--path:.") + let + binFileName = file.path.changeFileExt(ExeExt) + existsBefore = existsFile(binFileName) + execBackend(optsCopy) + + let + existsAfter = existsFile(binFileName) + canRemove = not existsBefore and existsAfter + if canRemove: + removeFile(binFileName) display("Success:", "All tests passed", Success, HighPriority) diff --git a/src/nimblepkg/cli.nim b/src/nimblepkg/cli.nim index ab9f494b..d8d52d51 100644 --- a/src/nimblepkg/cli.nim +++ b/src/nimblepkg/cli.nim @@ -13,6 +13,7 @@ # - Normal for MediumPriority. import logging, terminal, sets, strutils, os +import ./common when defined(windows): import winlean @@ -44,6 +45,7 @@ const styles: array[DebugPriority .. HighPriority, set[Style]] = [{styleDim}, {styleDim}, {}, {styleBright}] + proc newCLI(): CLI = result = CLI( level: HighPriority, @@ -190,17 +192,16 @@ proc promptListInteractive(question: string, args: openarray[string]): string = # The selection loop while not selected: + setForegroundColor(fgDefault) # Loop through the options for i, arg in args: # Check if the option is the current if i == current: - setForegroundColor(fgWhite) - writeStyled(" " & arg, {styleBright}) + writeStyled("> " & arg & " <", {styleBright}) else: - setForegroundColor(fgWhite) - writeStyled(" " & arg, {styleDim}) + writeStyled(" " & arg & " ", {styleDim}) # Move the cursor back to the start - for s in 0..<(arg.len + 1): + for s in 0..<(arg.len + 4): cursorBackward(stdout) # Move down for the next item cursorDown(stdout) @@ -218,6 +219,9 @@ proc promptListInteractive(question: string, args: openarray[string]): string = of '\r': selected = true break + of '\3': + showCursor(stdout) + raise newException(NimbleError, "Keyboard interrupt") else: discard # Erase all lines of the selection