summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhuw <>2020-11-21 05:41:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2020-11-21 05:41:00 (GMT)
commit575f921c0c30bc1b9b5fa5a2d0ceadefc3816d9c (patch)
treeab8f2c27133e480b4d20bbc3c0eaa605cd8ab1fa
parentce8d0e2f5612225dcd1f85a65b3455db99544839 (diff)
version 0.16.1.0HEAD0.16.1.0master
-rwxr-xr-xCHANGELOG.md8
-rw-r--r--optparse-applicative.cabal12
-rw-r--r--src/Options/Applicative/Builder/Completer.hs8
-rw-r--r--tests/test.hs11
4 files changed, 25 insertions, 14 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 9ae320b..282c522 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,11 @@
+## Version 0.16.1.0 (21 Nov 2020)
+
+- Guard `process` dependency behind an on by default flag.
+ This allows one to shrink the dependency tree significantly
+ by turning off the ability to use bash completion actions.
+
+- Remove `bytestring` dependency from the test suite.
+
## Version 0.16.0.0 (14 Aug 2020)
- Add `Options.Applicative.NonEmpty.some1` function, which
diff --git a/optparse-applicative.cabal b/optparse-applicative.cabal
index 5193fdd..732acd8 100644
--- a/optparse-applicative.cabal
+++ b/optparse-applicative.cabal
@@ -1,5 +1,5 @@
name: optparse-applicative
-version: 0.16.0.0
+version: 0.16.1.0
synopsis: Utilities and combinators for parsing command line options
description:
optparse-applicative is a haskell library for parsing options
@@ -60,6 +60,11 @@ source-repository head
type: git
location: https://github.com/pcapriotti/optparse-applicative.git
+flag process
+ description:
+ Depend on the process package for Bash autocompletion
+ default: True
+
library
hs-source-dirs: src
ghc-options: -Wall
@@ -92,9 +97,11 @@ library
build-depends: base == 4.*
, transformers >= 0.2 && < 0.6
, transformers-compat >= 0.3 && < 0.7
- , process >= 1.0 && < 1.7
, ansi-wl-pprint >= 0.6.8 && < 0.7
+ if flag(process)
+ build-depends: process >= 1.0 && < 1.7
+
if !impl(ghc >= 8)
build-depends: semigroups >= 0.10 && < 0.20
, fail == 4.9.*
@@ -117,7 +124,6 @@ test-suite tests
, Examples.Hello
build-depends: base
- , bytestring >= 0.9 && < 0.11
, optparse-applicative
, QuickCheck >= 2.8 && < 2.15
diff --git a/src/Options/Applicative/Builder/Completer.hs b/src/Options/Applicative/Builder/Completer.hs
index fea9970..f4d5809 100644
--- a/src/Options/Applicative/Builder/Completer.hs
+++ b/src/Options/Applicative/Builder/Completer.hs
@@ -1,3 +1,5 @@
+{-# LANGUAGE CPP #-}
+
module Options.Applicative.Builder.Completer
( Completer
, mkCompleter
@@ -10,7 +12,9 @@ import Control.Applicative
import Prelude
import Control.Exception (IOException, try)
import Data.List (isPrefixOf)
+#ifdef MIN_VERSION_process
import System.Process (readProcess)
+#endif
import Options.Applicative.Types
@@ -31,10 +35,14 @@ listCompleter = listIOCompleter . pure
-- <http://www.gnu.org/software/bash/manual/html_node/Programmable-Completion-Builtins.html#Programmable-Completion-Builtins>
-- for a complete list.
bashCompleter :: String -> Completer
+#ifdef MIN_VERSION_process
bashCompleter action = Completer $ \word -> do
let cmd = unwords ["compgen", "-A", action, "--", requote word]
result <- tryIO $ readProcess "bash" ["-c", cmd] ""
return . lines . either (const []) id $ result
+#else
+bashCompleter = const $ Completer $ const $ return []
+#endif
tryIO :: IO a -> IO (Either IOException a)
tryIO = try
diff --git a/tests/test.hs b/tests/test.hs
index a66d37c..3c8bf6a 100644
--- a/tests/test.hs
+++ b/tests/test.hs
@@ -12,8 +12,6 @@ import qualified Examples.Formatting as Formatting
import Control.Applicative
import Control.Monad
-import Data.ByteString (ByteString)
-import qualified Data.ByteString.Char8 as BS8
import Data.List hiding (group)
import Data.List.NonEmpty (NonEmpty ((:|)))
import Data.Semigroup hiding (option)
@@ -768,15 +766,6 @@ prop_suggest = once $
in counterexample msg
$ isInfixOf "Did you mean one of these?\n first\n fst" msg
-prop_bytestring_reader :: Property
-prop_bytestring_reader = once $
- let t = "testValue"
- p :: Parser ByteString
- p = argument str idm
- i = info p idm
- result = run i ["testValue"]
- in assertResult result $ \xs -> BS8.pack t === xs
-
prop_grouped_some_option_ellipsis :: Property
prop_grouped_some_option_ellipsis = once $
let x :: Parser String