Skip to content

Commit

Permalink
nimble, patches, cli: vendor parseopt3 dependency (#780)
Browse files Browse the repository at this point in the history
Rationale:

- Although there are benefits to maintaining a patch rather than an
  in-repo forked dependency, the patching process added complexity and
  fragility. And it seems like it might have to become more complex and
  fragile when we start using `nimble lock` with Nim 2.0.

- Help to unblock the Nim 2.0 version bump, which caused the patching
  process to fail in CI on Windows only.

- It's OK if we have to vendor possible future forked code (e.g. of
  jsony or commonmark), rather than maintaining patches.

- A reader of our nimble file can no longer think that configlet fully
  uses cligen.

We do have an integration test in tests/test_binary to assert that
configlet has the desired CLI option parsing behavior.
  • Loading branch information
ee7 authored Aug 8, 2023
1 parent 49a8a51 commit 7471af3
Show file tree
Hide file tree
Showing 4 changed files with 417 additions and 69 deletions.
6 changes: 0 additions & 6 deletions configlet.nimble
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import patches/patch

proc getVersionStart: string =
# Returns the `major.minor.patch` version in the `configlet.version` file
# (that is, omitting any pre-release version information).
Expand All @@ -19,13 +17,9 @@ bin = @["configlet"]

# Dependencies
requires "nim >= 1.6.12"
requires "cligen#8d4e5fb58917eb681d3babd8561ddd175f01df3d" # 1.6.13 (2023-07-29)
requires "jsony#ea811bec7fa50f5abd3088ba94cda74285e93f18" # 1.1.5 (2023-02-09)
requires "parsetoml#6e5e16179fa2db60f2f37d8b1af4128aaa9c8aaf" # 0.7.1 (2023-08-06)
requires "supersnappy#e4df8cb5468dd96fc5a4764028e20c8a3942f16a" # 2.1.3 (2022-06-12)

task test, "Runs the test suite":
exec "nim r ./tests/all_tests.nim"

before build:
ensureThatNimblePackagesArePatched()
61 changes: 0 additions & 61 deletions patches/patch.nim

This file was deleted.

5 changes: 3 additions & 2 deletions src/cli.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import std/[os, parseutils, strformat, strutils, terminal]
import pkg/[cligen/parseopt3, supersnappy]
import pkg/supersnappy
import patched_libs/parseopt3

type
ActionKind* = enum
Expand Down Expand Up @@ -365,7 +366,7 @@ func formatOpt(kind: CmdLineKind, key: string, val = ""): string =
## Returns a string that describes an option, given its `kind`, `key` and
## optionally `val`. This is useful for displaying in error messages.
runnableExamples:
import pkg/cligen/parseopt3
import patched_libs/parseopt3
assert formatOpt(cmdShortOption, "h") == "'-h'"
assert formatOpt(cmdLongOption, "help") == "'--help'"
assert formatOpt(cmdShortOption, "v", "quiet") == "'-v': 'quiet'"
Expand Down
Loading

0 comments on commit 7471af3

Please sign in to comment.