Skip to content

Commit

Permalink
cabal-doctest: Fix handling of options with optional arguments
Browse files Browse the repository at this point in the history
(e.g. `--allow-newer=False`)
  • Loading branch information
sol committed Jul 27, 2024
1 parent 16d8efe commit 157aa00
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cabal-doctest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
- run: cabal path
- run: cabal update
- run: cabal install -f cabal-doctest
- run: cabal doctest
- run: cabal doctest --allow-newer=False

- run: cabal doctest -w ghc-9.6
- run: cabal doctest -w ghc-8.6.5
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.markdown
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Changes in 0.22.8
- cabal-doctest: Fix handling of options with optional arguments

Changes in 0.22.7
- cabal-doctest: Accept component
- cabal-doctest: Get rid of separate `cabal build` step
Expand Down
6 changes: 5 additions & 1 deletion src/Cabal/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,8 @@ documentedOptions = map toOptDescr Repl.options

discardReplOptions :: [String] -> [String]
discardReplOptions args = case getOpt Permute options args of
(xs, _, _) -> concat [name : maybeToList value | Argument name value <- xs, Set.notMember name replOnlyOptions]
(xs, _, _) -> [renderArgument name value | Argument name value <- xs, Set.notMember name replOnlyOptions]
where
renderArgument name = \ case
Nothing -> name
Just value -> name <> "=" <> value
2 changes: 1 addition & 1 deletion test/Cabal/OptionsSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ spec = do
, "--repl-options", "foo"
, "--repl-options=foo"
, "--allow-newer"
] `shouldBe` ["--with-compiler", "ghc-9.10", "--disable-optimization", "--allow-newer"]
] `shouldBe` ["--with-compiler=ghc-9.10", "--disable-optimization", "--allow-newer"]

0 comments on commit 157aa00

Please sign in to comment.