Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
genotrance committed Dec 13, 2018
2 parents 3d7227c + 119be48 commit 220ebae
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 6 deletions.
23 changes: 22 additions & 1 deletion readme.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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:<the_package>`. 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
Expand Down
10 changes: 10 additions & 0 deletions src/nimble.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
14 changes: 9 additions & 5 deletions src/nimblepkg/cli.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# - Normal for MediumPriority.

import logging, terminal, sets, strutils, os
import ./common

when defined(windows):
import winlean
Expand Down Expand Up @@ -44,6 +45,7 @@ const
styles: array[DebugPriority .. HighPriority, set[Style]] =
[{styleDim}, {styleDim}, {}, {styleBright}]


proc newCLI(): CLI =
result = CLI(
level: HighPriority,
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 220ebae

Please sign in to comment.