opt-env-conf-test 0.0.0.2 → 0.0.0.3
raw patch · 24 files changed
+837/−179 lines, 24 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- OptEnvConf.Test: goldenSettingsNixOptionsSpec :: forall a. HasCallStack => HasParser a => FilePath -> Spec
+ OptEnvConf.Test: goldenSettingsNixOptionsSpec :: (HasCallStack, HasParser a) => FilePath -> Spec
- OptEnvConf.Test: goldenSettingsReferenceDocumentationSpec :: forall a. HasCallStack => HasParser a => FilePath -> String -> Spec
+ OptEnvConf.Test: goldenSettingsReferenceDocumentationSpec :: (HasCallStack, HasParser a) => FilePath -> String -> Spec
- OptEnvConf.Test: parserLintSpec :: forall a. HasCallStack => Parser a -> Spec
+ OptEnvConf.Test: parserLintSpec :: HasCallStack => Parser a -> Spec
- OptEnvConf.Test: settingsLintSpec :: forall a. HasCallStack => HasParser a => Spec
+ OptEnvConf.Test: settingsLintSpec :: (HasCallStack, HasParser a) => Spec
- OptEnvConf.Test: settingsParserCompletionDescriptionTest :: forall a. HasParser a => Int -> [String] -> [String] -> IO ()
+ OptEnvConf.Test: settingsParserCompletionDescriptionTest :: HasParser a => Int -> [String] -> [String] -> IO ()
- OptEnvConf.Test: settingsParserCompletionTest :: forall a. HasParser a => Int -> [String] -> [Completion String] -> IO ()
+ OptEnvConf.Test: settingsParserCompletionTest :: HasParser a => Int -> [String] -> [Completion String] -> IO ()
Files
- CHANGELOG.md +6/−0
- opt-env-conf-test.cabal +2/−1
- src/OptEnvConf/Test.hs +1/−1
- test/OptEnvConf/CheckSpec.hs +77/−0
- test/OptEnvConf/ErrorSpec.hs +2/−2
- test/OptEnvConf/RunSpec.hs +111/−7
- test_resources/docs/big-config/show.txt +19/−4
- test_resources/docs/enable-disable-optional/show.txt +36/−6
- test_resources/docs/enable-disable/show.txt +36/−6
- test_resources/docs/greet/show.txt +42/−8
- test_resources/docs/hidden/show.txt +6/−1
- test_resources/docs/many-args/show.txt +6/−1
- test_resources/docs/optional/show.txt +6/−1
- test_resources/docs/same-help/show.txt +51/−10
- test_resources/docs/secret/show.txt +211/−90
- test_resources/docs/some-args/show.txt +7/−1
- test_resources/docs/sub-commands/show.txt +24/−5
- test_resources/docs/sub-settings/show.txt +25/−5
- test_resources/docs/sum-type/show.txt +31/−6
- test_resources/docs/three-commands/show.txt +49/−9
- test_resources/docs/verbose/show.txt +7/−1
- test_resources/docs/with-default/show.txt +10/−2
- test_resources/docs/yes-no-optional/show.txt +36/−6
- test_resources/docs/yes-no/show.txt +36/−6
CHANGELOG.md view
@@ -1,5 +1,11 @@ # Changelog +## [0.0.0.3] - 2025-11-20++### Added++* Compabitility with `opt-env-conf >=0.13`+ ## [0.0.0.2] - 2025-03-12 ### Added
opt-env-conf-test.cabal view
@@ -5,7 +5,7 @@ -- see: https://github.com/sol/hpack name: opt-env-conf-test-version: 0.0.0.2+version: 0.0.0.3 synopsis: A testing companion package for opt-env-conf homepage: https://github.com/NorfairKing/opt-env-conf#readme bug-reports: https://github.com/NorfairKing/opt-env-conf/issues@@ -378,6 +378,7 @@ other-modules: OptEnvConf.APISpec OptEnvConf.ArgsSpec+ OptEnvConf.CheckSpec OptEnvConf.CompleterSpec OptEnvConf.CompletionSpec OptEnvConf.EnvMapSpec
src/OptEnvConf/Test.hs view
@@ -90,7 +90,7 @@ parserTest :: (Show a, Eq a) => Parser a -> [String] -> [(String, String)] -> Maybe JSON.Object -> a -> IO () parserTest parser args envVars mObject expected = do- errOrActual <- runParserOn Nothing parser (parseArgs args) (EnvMap.parse envVars) mObject+ errOrActual <- runParserOn allCapabilities Nothing parser (parseArgs args) (EnvMap.parse envVars) mObject case errOrActual of Left errs -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors errs Right actual -> actual `shouldBe` expected
+ test/OptEnvConf/CheckSpec.hs view
@@ -0,0 +1,77 @@+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE OverloadedStrings #-}++module OptEnvConf.CheckSpec (spec) where++import Data.GenValidity.Aeson ()+import OptEnvConf+import OptEnvConf.Args as Args+import OptEnvConf.Args.Gen ()+import OptEnvConf.Check+import qualified OptEnvConf.EnvMap as EnvMap+import OptEnvConf.EnvMap.Gen ()+import OptEnvConf.Terminal (getTerminalCapabilitiesFromHandle)+import System.IO+import Test.Syd++spec :: Spec+spec = sequential $+ doNotRandomiseExecutionOrder $+ describe "runSettingsCheckOn" $ do+ let string :: Reader String+ string = str+ it "is succesful on the trivial parser" $ do+ let p = pure ()+ stderrTc <- getTerminalCapabilitiesFromHandle stderr+ checkResult <- runSettingsCheckOn allCapabilities stderrTc p Args.emptyArgs EnvMap.empty Nothing+ checkResult+ `shouldSatisfy` ( \case+ CheckSucceeded () -> True+ _ -> False+ )++ it "fails when a required setting is missing" $ do+ let p = setting [argument, reader string] :: Parser String+ stderrTc <- getTerminalCapabilitiesFromHandle stderr+ checkResult <- runSettingsCheckOn allCapabilities stderrTc p Args.emptyArgs EnvMap.empty Nothing+ checkResult+ `shouldSatisfy` ( \case+ CheckFailed _ -> True+ _ -> False+ )++ it "says incapable when a required capability is missing" $ do+ let p = checkWithRequiredCapability readSecretCapability $ checkMapEither (const (Left "failed")) $ setting [argument, reader string] :: Parser String+ stderrTc <- getTerminalCapabilitiesFromHandle stderr+ checkResult <- runSettingsCheckOn (disableCapability (Capability "read-secret") allCapabilities) stderrTc p ["arg"] EnvMap.empty Nothing+ checkResult+ `shouldSatisfy` ( \case+ CheckIncapable _ -> True+ _ -> False+ )++ it "says failed when a required capability is available" $ do+ let p = checkWithRequiredCapability readSecretCapability $ checkMapEither (const (Left "failed")) $ setting [argument, reader string] :: Parser String+ stderrTc <- getTerminalCapabilitiesFromHandle stderr+ checkResult <- runSettingsCheckOn allCapabilities stderrTc p ["arg"] EnvMap.empty Nothing+ checkResult+ `shouldSatisfy` ( \case+ CheckFailed _ -> True+ _ -> False+ )++ it "says failed when a required capability is missing but another setting failed" $ do+ let p :: Parser (String, String)+ p =+ (,)+ <$> checkWithRequiredCapability readSecretCapability (checkMapEither (const (Left "failed")) $ setting [argument, reader string])+ <*> checkMapEither (const (Left "failed")) (setting [argument, reader string])++ stderrTc <- getTerminalCapabilitiesFromHandle stderr+ checkResult <- runSettingsCheckOn (disableCapability (Capability "read-secret") allCapabilities) stderrTc p ["arg1", "arg2"] EnvMap.empty Nothing+ checkResult+ `shouldSatisfy` ( \case+ CheckFailed _ -> True+ _ -> False+ )
test/OptEnvConf/ErrorSpec.hs view
@@ -201,7 +201,7 @@ it (unwords ["renders the", fp, "error the same as before"]) $ let path = "test_resources/error/" <> fp <> ".txt" in goldenChunksFile path $ do- errOrResult <- runParserOn Nothing p (parseArgs args) EnvMap.empty Nothing+ errOrResult <- runParserOn allCapabilities Nothing p (parseArgs args) EnvMap.empty Nothing case errOrResult of Right a -> expectationFailure $ unlines ["Should not have been able to parse, but did and got:", show a] Left errs -> pure $ renderErrors errs@@ -212,7 +212,7 @@ it (unwords ["renders the", fp, "error the same as before"]) $ let path = "test_resources/error/" <> fp <> ".txt" in goldenChunksFile path $ do- errOrResult <- runParserOn Nothing p emptyArgs (EnvMap.parse e) Nothing+ errOrResult <- runParserOn allCapabilities Nothing p emptyArgs (EnvMap.parse e) Nothing case errOrResult of Right a -> expectationFailure $ unlines ["Should not have been able to parse, but did and got:", show a] Left errs -> pure $ renderErrors errs
test/OptEnvConf/RunSpec.hs view
@@ -1,11 +1,13 @@ {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-}+{-# OPTIONS_GHC -Wno-orphans #-} module OptEnvConf.RunSpec (spec) where import Autodocodec import Control.Applicative+import Control.Concurrent import Data.Aeson as JSON (Object, Value (Null), toJSON) import qualified Data.Aeson.Key as Key import qualified Data.Aeson.KeyMap as KeyMap@@ -136,6 +138,82 @@ let expected = succ i shouldParse p Args.emptyArgs e mConf expected + describe "RequireCapability" $ do+ it "can run the check parser if the capability is available" $+ forAllValid $ \capabilitiesPrototype ->+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \result ->+ forAllValid $ \capName -> do+ let p :: Parser Int+ p = checkWithRequiredCapability capName $ checkMapEither (const (Left "failed")) (pure (result :: Int))+ let cap = Capability (T.pack capName)+ let capabilities = enableCapability cap capabilitiesPrototype+ shouldFail' p capabilities Args.emptyArgs e mConf $ \case+ ParseErrorCheckFailed False "failed" :| [] -> True+ _ -> False++ it "cannot run the check parser if the capability is not available" $+ forAllValid $ \capabilitiesPrototype ->+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \result ->+ forAllValid $ \capName -> do+ let p :: Parser Int+ p = checkWithRequiredCapability capName $ checkMapEither (const (Left "failed")) (pure (result :: Int))+ let cap = Capability (T.pack capName)+ let capabilities = disableCapability cap capabilitiesPrototype+ shouldFail' p capabilities Args.emptyArgs e mConf $ \case+ ParseErrorMissingCapability _ :| [] -> True+ _ -> False++ it "still runs the below parser when a capability is missing for the check parser" $+ forAllValid $ \capabilitiesPrototype ->+ forAllValid $ \capName ->+ forAllValid $ \result ->+ forAllValid $ \e ->+ forAllValid $ \mConf -> do+ var <- newMVar 0+ let p = checkWithRequiredCapability capName (mapIO pure (mapIO (swapMVar var) (pure (result :: Int))))+ let cap = Capability (T.pack capName)+ let capabilities = disableCapability cap capabilitiesPrototype+ errOrRes <- runParserOn capabilities Nothing p Args.emptyArgs e mConf+ case errOrRes of+ Left errs -> do+ NE.map parseErrorMessage errs+ `shouldSatisfy` ( \case+ ParseErrorMissingCapability c :| [] | c == cap -> True+ _ -> False+ )+ readMVar var `shouldReturn` result -- instead of 1+ Right _ -> expectationFailure "The parser should not have succeeded."++ it "can run the setting parser if the capability is available" $+ forAllValid $ \capabilitiesPrototype ->+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \capName -> do+ let p :: Parser Int+ p = setting [argument, reader auto, requiredCapability capName] :: Parser Int+ let cap = Capability (T.pack capName)+ let capabilities = enableCapability cap capabilitiesPrototype+ shouldFail' p capabilities Args.emptyArgs e mConf $ \case+ ParseErrorMissingArgument _ :| [] -> True+ _ -> False++ it "cannot run the setting parser if the capability is available" $+ forAllValid $ \capabilitiesPrototype ->+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \capName -> do+ let p :: Parser Int+ p = setting [argument, reader auto, requiredCapability capName] :: Parser Int+ let cap = Capability (T.pack capName)+ let capabilities = disableCapability cap capabilitiesPrototype+ shouldFail' p capabilities Args.emptyArgs e mConf $ \case+ ParseErrorMissingCapability _ :| [] -> True+ _ -> False+ describe "WithConfig" $ do it "can replace the config object" $ forAllValid $ \e ->@@ -870,7 +948,7 @@ argParseSpec args p expected = withFrozenCallStack $ do it (unwords ["parses args", show args, "as", show expected]) $ do let argMap = parseArgs args- errOrRes <- runParserOn Nothing p argMap EnvMap.empty Nothing+ errOrRes <- runParserOn allCapabilities Nothing p argMap EnvMap.empty Nothing context (showParserABit p) $ case errOrRes of Left errs ->@@ -888,7 +966,7 @@ envParseSpec envVars p expected = withFrozenCallStack $ do it (unwords ["parses environment", show envVars, "as", show expected]) $ do let envMap = EnvMap.parse envVars- errOrRes <- runParserOn Nothing p emptyArgs envMap Nothing+ errOrRes <- runParserOn allCapabilities Nothing p emptyArgs envMap Nothing case errOrRes of Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err Right actual -> actual `shouldBe` expected@@ -899,7 +977,7 @@ confParseSpec :: (HasCallStack) => (Show a, Eq a) => Maybe JSON.Object -> Parser a -> a -> Spec confParseSpec mConf p expected = withFrozenCallStack $ do it (unwords ["parses configuration", show mConf, "as", show expected]) $ do- errOrRes <- runParserOn Nothing p emptyArgs EnvMap.empty mConf+ errOrRes <- runParserOn allCapabilities Nothing p emptyArgs EnvMap.empty mConf case errOrRes of Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err Right actual -> actual `shouldBe` expected@@ -912,8 +990,19 @@ Maybe JSON.Object -> a -> IO ()-shouldParse p args e mConf expected = do- errOrRes <- runParserOn Nothing p args e mConf+shouldParse p = shouldParse' p allCapabilities++shouldParse' ::+ (Show a, Eq a) =>+ Parser a ->+ Capabilities ->+ Args ->+ EnvMap ->+ Maybe JSON.Object ->+ a ->+ IO ()+shouldParse' p capabilities args e mConf expected = do+ errOrRes <- runParserOn capabilities Nothing p args e mConf context (showParserABit p) $ case errOrRes of Left errs -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors errs Right actual -> actual `shouldBe` expected@@ -926,8 +1015,23 @@ Maybe JSON.Object -> (NonEmpty ParseErrorMessage -> Bool) -> IO ()-shouldFail p args e mConf isExpected = do- errOrRes <- runParserOn Nothing p args e mConf+shouldFail p = shouldFail' p allCapabilities++shouldFail' ::+ (Show a) =>+ Parser a ->+ Capabilities ->+ Args ->+ EnvMap ->+ Maybe JSON.Object ->+ (NonEmpty ParseErrorMessage -> Bool) ->+ IO ()+shouldFail' p capabilities args e mConf isExpected = do+ errOrRes <- runParserOn capabilities Nothing p args e mConf case errOrRes of Left errs -> NE.map parseErrorMessage errs `shouldSatisfy` isExpected Right actual -> expectationFailure $ show actual++instance GenValid Capabilities++instance GenValid Capability
test_resources/docs/big-config/show.txt view
@@ -4,11 +4,13 @@ (Check Nothing False+ (fromList []) _ (Alt (Check Nothing False+ (fromList []) _ (Setting Nothing@@ -18,12 +20,21 @@ False Nothing True- (Just ("CONFIG_FILE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "CONFIG_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ (Just "Path to the configuration file")+ (Just _)+ (fromList []))))+ (Check Nothing False (fromList []) _ (Pure _)))) (Setting Nothing (Setting@@ -66,5 +77,9 @@ _ _ (OptionalKeyCodec "sub" Nothing (StringCodec Nothing)))))) :| [])) Nothing+ []+ False Nothing- (Just "big configuration object")))+ (Just "big configuration object")+ Nothing+ (fromList [])))
test_resources/docs/enable-disable-optional/show.txt view
@@ -7,6 +7,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -19,12 +20,17 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "Example of an enable/disable switch"))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -37,12 +43,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -55,12 +66,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -70,14 +86,24 @@ False Nothing False- (Just ("EXAMPLE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "EXAMPLE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "Example of an enable/disable switch"))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))) (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -97,6 +123,10 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "Example of an enable/disable switch"))))))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))))))) (Pure _))
test_resources/docs/enable-disable/show.txt view
@@ -6,6 +6,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -18,12 +19,17 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "Example of an enable/disable switch"))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -36,12 +42,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -54,12 +65,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -69,15 +85,25 @@ False Nothing False- (Just ("EXAMPLE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "EXAMPLE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "Example of an enable/disable switch"))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -97,6 +123,10 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "Example of an enable/disable switch"))))+ (Just "Example of an enable/disable switch")+ Nothing+ (fromList [])))) (Pure _))))))
test_resources/docs/greet/show.txt view
@@ -4,11 +4,13 @@ (Check Nothing False+ (fromList []) _ (Alt (Check Nothing False+ (fromList []) _ (Setting Nothing@@ -18,17 +20,27 @@ False Nothing True- (Just ("GREET_CONFIG_FILE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "GREET_CONFIG_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ (Just "Path to the configuration file")+ (Just _)+ (fromList []))))+ (Check Nothing False (fromList []) _ (Pure _)))) (Ap (Ap (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -38,8 +50,13 @@ False Nothing True- (Just ("GREET_GREETING" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "GREET_GREETING"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("greeting" :| []) BimapCodec@@ -51,8 +68,12 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) (Just _)+ [ "Greetings" ]+ False (Just "GREETING")- (Just "Greeting to use"))))+ (Just "Greeting to use")+ Nothing+ (fromList [])))) (Setting Nothing (Setting@@ -64,8 +85,12 @@ Nothing Nothing (Just _)+ []+ False (Just "SUBJECT")- (Just "Who to greet"))))+ (Just "Who to greet")+ Nothing+ (fromList [])))) (Setting Nothing (Setting@@ -74,8 +99,13 @@ False (Just _) False- (Just ("GREET_POLITE" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "GREET_POLITE"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("polite" :| []) BimapCodec@@ -84,5 +114,9 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) (Just _)+ []+ False (Just "ANY")- (Just "Whether to be polite"))))+ (Just "Whether to be polite")+ Nothing+ (fromList []))))
@@ -1,6 +1,7 @@ Check Nothing True+ (fromList []) _ (Setting Nothing@@ -13,5 +14,9 @@ Nothing Nothing (Just _)+ []+ True (Just "STR")- (Just "Example of a hidden setting")))+ (Just "Example of a hidden setting")+ Nothing+ (fromList [])))
test_resources/docs/many-args/show.txt view
@@ -1,4 +1,5 @@ Many+ Nothing (Setting Nothing (Setting@@ -10,5 +11,9 @@ Nothing Nothing Nothing+ []+ False (Just "ARGUMENT")- (Just "Argument")))+ (Just "Argument")+ Nothing+ (fromList [])))
test_resources/docs/optional/show.txt view
@@ -2,6 +2,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -14,6 +15,10 @@ Nothing Nothing Nothing+ []+ False (Just "ARGUMENT")- (Just "Argument"))))+ (Just "Argument")+ Nothing+ (fromList [])))) (Pure _)
test_resources/docs/same-help/show.txt view
@@ -7,6 +7,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -16,8 +17,11 @@ False Nothing True- (Just ("INT" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "INT" , envVarSettingAllowPrefix = True } :|+ []))+ (Just (ConfigValSetting ("int" :| []) BimapCodec@@ -37,11 +41,16 @@ }))) :| [])) Nothing+ []+ False (Just "INT")- (Just "int or string"))))+ (Just "int or string")+ Nothing+ (fromList [])))) (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -51,8 +60,13 @@ False Nothing True- (Just ("STRING" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "STRING"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("string" :| []) BimapCodec@@ -64,8 +78,12 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ []+ False (Just "STR")- (Just "int or string")))))+ (Just "int or string")+ Nothing+ (fromList []))))) (Alt (Setting Nothing@@ -78,8 +96,12 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "int or string")))+ (Just "int or string")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -92,8 +114,12 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing))+ Nothing+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -106,8 +132,12 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing))+ Nothing+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -117,11 +147,18 @@ False Nothing False- (Just ("OTHER" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "OTHER" , envVarSettingAllowPrefix = True } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "int or string")))+ (Just "int or string")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -141,6 +178,10 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "int or string")))+ (Just "int or string")+ Nothing+ (fromList []))) (Pure _)))))))
test_resources/docs/secret/show.txt view
@@ -9,10 +9,12 @@ (Check Nothing False+ (fromList [ "read-secret" ]) _ (Check Nothing False+ (fromList []) _ (Setting Nothing@@ -22,8 +24,13 @@ False Nothing True- (Just ("FIRST_SECRET_FILE" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "FIRST_SECRET_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("first-secret-file" :| []) BimapCodec@@ -35,12 +42,17 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ []+ False (Just "FILE_PATH")- (Just "First example secret")))))+ (Just "First example secret")+ (Just _)+ (fromList []))))) (Alt (Check Nothing True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -53,30 +65,45 @@ Nothing Nothing Nothing+ []+ False (Just "SECRET")- (Just "Second example secret, bare or in a file"))))+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList [])))) (Alt (Check Nothing False+ (fromList [ "read-secret" ]) _- (Setting+ (Check Nothing+ False+ (fromList [])+ _ (Setting- [ DashedLong ('s' :| "econd-secret-file") ]- [ _ , _ ]- False Nothing- True- Nothing- Nothing- Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file"))))+ (Setting+ [ DashedLong ('s' :| "econd-secret-file") ]+ [ _ , _ ]+ False+ Nothing+ True+ Nothing+ Nothing+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList []))))) (Alt (Check Nothing True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -86,33 +113,30 @@ False Nothing False- (Just ("SECOND_SECRET" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "SECOND_SECRET"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "SECRET")- (Just "Second example secret, bare or in a file"))))+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList [])))) (Alt (Check Nothing False+ (fromList [ "read-secret" ]) _- (Setting- Nothing- (Setting- []- [ _ , _ ]- False- Nothing- False- (Just ("SECOND_SECRET_FILE" :| []))- Nothing- Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file"))))- (Alt (Check Nothing- True+ False+ (fromList []) _ (Setting Nothing@@ -122,24 +146,25 @@ False Nothing False- Nothing (Just- (ConfigValSetting- ("second-secret" :| [])- BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (BimapCodec _ _ (StringCodec Nothing))) :|+ (EnvVarSetting+ { envVarSettingVar = "SECOND_SECRET_FILE"+ , envVarSettingAllowPrefix = True+ } :| [])) Nothing- (Just "SECRET")- (Just "Second example secret, bare or in a file"))))+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList [])))))+ (Alt (Check Nothing- False+ True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -152,7 +177,7 @@ Nothing (Just (ConfigValSetting- ("second-secret-file" :| [])+ ("second-secret" :| []) BimapCodec _ _@@ -162,12 +187,54 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file"))))))))))+ []+ False+ (Just "SECRET")+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList []))))+ (Check+ Nothing+ False+ (fromList [ "read-secret" ])+ _+ (Check+ Nothing+ False+ (fromList [])+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("second-secret-file" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file")+ Nothing+ (fromList []))))))))))) (Alt (Check Nothing True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -180,29 +247,44 @@ Nothing Nothing Nothing+ []+ False (Just "SECRET")- (Just "Second example secret, bare or in a file, only option"))))+ (Just "Second example secret, bare or in a file, only option")+ Nothing+ (fromList [])))) (Check Nothing False+ (fromList [ "read-secret" ]) _- (Setting+ (Check Nothing+ False+ (fromList [])+ _ (Setting- [ DashedLong ('s' :| "econd-secret-file") ]- [ _ , _ ]- False Nothing- True- Nothing- Nothing- Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file, only option"))))))+ (Setting+ [ DashedLong ('s' :| "econd-secret-file") ]+ [ _ , _ ]+ False+ Nothing+ True+ Nothing+ Nothing+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file, only option")+ Nothing+ (fromList []))))))) (Alt (Check Nothing True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -212,32 +294,57 @@ False Nothing False- (Just ("second-secret" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "second-secret"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "SECRET")- (Just "Second example secret, bare or in a file, only env"))))+ (Just "Second example secret, bare or in a file, only env")+ Nothing+ (fromList [])))) (Check Nothing False+ (fromList [ "read-secret" ]) _- (Setting+ (Check Nothing+ False+ (fromList [])+ _ (Setting- []- [ _ , _ ]- False Nothing- False- (Just ("second-secret_FILE" :| []))- Nothing- Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file, only env"))))))+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ (Just+ (EnvVarSetting+ { envVarSettingVar = "second-secret_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ Nothing+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file, only env")+ Nothing+ (fromList []))))))) (Alt (Check Nothing True+ (fromList [ "read-secret" ]) _ (Setting Nothing@@ -260,32 +367,46 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ []+ False (Just "SECRET")- (Just "Second example secret, bare or in a file, only conf"))))+ (Just "Second example secret, bare or in a file, only conf")+ Nothing+ (fromList [])))) (Check Nothing False+ (fromList [ "read-secret" ]) _- (Setting+ (Check Nothing+ False+ (fromList [])+ _ (Setting- []- [ _ , _ ]- False Nothing- False- Nothing- (Just- (ConfigValSetting- ("second-secret-file" :| [])- BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (BimapCodec _ _ (StringCodec Nothing))) :|- []))- Nothing- (Just "FILE_PATH")- (Just "Second example secret, bare or in a file, only conf"))))))+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("second-secret-file" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ []+ False+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file, only conf")+ Nothing+ (fromList [])))))))
test_resources/docs/some-args/show.txt view
@@ -1,8 +1,10 @@ Check Nothing True+ (fromList []) _ (Some+ Nothing (Setting Nothing (Setting@@ -14,5 +16,9 @@ Nothing Nothing Nothing+ []+ False (Just "ARGUMENT")- (Just "Argument"))))+ (Just "Argument")+ Nothing+ (fromList []))))
test_resources/docs/sub-commands/show.txt view
@@ -4,11 +4,13 @@ (Check Nothing False+ (fromList []) _ (Alt (Check Nothing False+ (fromList []) _ (Setting Nothing@@ -18,12 +20,21 @@ False Nothing True- (Just ("CONFIG_FILE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "CONFIG_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ (Just "Path to the configuration file")+ (Just _)+ (fromList []))))+ (Check Nothing False (fromList []) _ (Pure _)))) (Commands Nothing Nothing@@ -33,6 +44,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -42,8 +54,11 @@ False Nothing True- (Just ("NAME" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "NAME" , envVarSettingAllowPrefix = True } :|+ []))+ (Just (ConfigValSetting ("name" :| []) BimapCodec@@ -55,8 +70,12 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ [ "john" ]+ False (Just "NAME")- (Just "name"))))+ (Just "name")+ Nothing+ (fromList [])))) , Command "sub" "command with subcommands"
test_resources/docs/sub-settings/show.txt view
@@ -4,11 +4,13 @@ (Check Nothing False+ (fromList []) _ (Alt (Check Nothing False+ (fromList []) _ (Setting Nothing@@ -18,12 +20,21 @@ False Nothing True- (Just ("CONFIG_FILE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "CONFIG_FILE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ (Just "Path to the configuration file")+ (Just _)+ (fromList []))))+ (Check Nothing False (fromList []) _ (Pure _)))) (Setting Nothing (Setting@@ -32,8 +43,13 @@ False Nothing True- (Just ("FOO_BAR_QUUX" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "FOO_BAR_QUUX"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("foo" :| [ "bar" , "quux" ]) BimapCodec@@ -45,5 +61,9 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ []+ False (Just "STR")- (Just "Example with sub-settings")))+ (Just "Example with sub-settings")+ Nothing+ (fromList [])))
test_resources/docs/sum-type/show.txt view
@@ -14,8 +14,12 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "a")))+ (Just "a")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -28,8 +32,12 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "b")))+ (Just "b")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -39,11 +47,20 @@ False Nothing False- (Just ("sum-type" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "sum-type"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "SUM_TYPE")- (Just "example")))+ (Just "example")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -66,8 +83,12 @@ (BimapCodec _ _ (StringCodec Nothing))) :| [])) Nothing+ []+ False Nothing- (Just "example")))+ (Just "example")+ Nothing+ (fromList []))) (Setting Nothing (Setting@@ -79,5 +100,9 @@ Nothing Nothing (Just _)+ []+ False Nothing- (Just "example")))))))+ (Just "example")+ Nothing+ (fromList [])))))))
test_resources/docs/three-commands/show.txt view
@@ -11,6 +11,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -23,8 +24,12 @@ Nothing Nothing Nothing+ []+ False (Just "STR")- (Just "argument"))))+ (Just "argument")+ Nothing+ (fromList [])))) , Command "two" "second"@@ -32,6 +37,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -41,8 +47,13 @@ False Nothing True- (Just ("NUMBER" :| [])) (Just+ (EnvVarSetting+ { envVarSettingVar = "NUMBER"+ , envVarSettingAllowPrefix = True+ } :|+ []))+ (Just (ConfigValSetting ("number" :| []) BimapCodec@@ -62,8 +73,12 @@ }))) :| [])) Nothing+ [ "5" ]+ False (Just "INT")- (Just "number"))))+ (Just "number")+ Nothing+ (fromList [])))) (Alt (Setting Nothing@@ -76,8 +91,12 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "enable extra")))+ (Just "enable extra")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -90,8 +109,12 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing))+ Nothing+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -104,8 +127,12 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing))+ Nothing+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -115,11 +142,20 @@ False Nothing False- (Just ("ENABLE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "ENABLE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "enable extra")))+ (Just "enable extra")+ Nothing+ (fromList []))) (Alt (Setting Nothing@@ -140,8 +176,12 @@ PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "enable extra")))+ (Just "enable extra")+ Nothing+ (fromList []))) (Pure _))))))) , Command "three-very-long-command-name" "third" (Pure _) ])
test_resources/docs/verbose/show.txt view
@@ -1,8 +1,10 @@ Check Nothing True+ (fromList []) _ (Many+ Nothing (Setting Nothing (Setting@@ -14,5 +16,9 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "Verbosity level. Use multiple to increase verbosity"))))+ (Just "Verbosity level. Use multiple to increase verbosity")+ Nothing+ (fromList []))))
test_resources/docs/with-default/show.txt view
@@ -10,8 +10,12 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "first")))+ (Just "first")+ Nothing+ (fromList []))) (Setting Nothing (Setting@@ -23,5 +27,9 @@ Nothing Nothing (Just _)+ []+ False Nothing- (Just "second")))+ (Just "second")+ Nothing+ (fromList [])))
test_resources/docs/yes-no-optional/show.txt view
@@ -7,6 +7,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -19,12 +20,17 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "Example of a yes/no switch"))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -37,12 +43,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -55,12 +66,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -70,14 +86,24 @@ False Nothing False- (Just ("EXAMPLE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "EXAMPLE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "Example of a yes/no switch"))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))) (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -97,6 +123,10 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "Example of a yes/no switch"))))))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))))))) (Pure _))
test_resources/docs/yes-no/show.txt view
@@ -6,6 +6,7 @@ (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -18,12 +19,17 @@ Nothing Nothing Nothing+ []+ False Nothing- (Just "Example of a yes/no switch"))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -36,12 +42,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -54,12 +65,17 @@ Nothing Nothing Nothing+ []+ True Nothing- Nothing)))+ Nothing+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -69,15 +85,25 @@ False Nothing False- (Just ("EXAMPLE" :| []))+ (Just+ (EnvVarSetting+ { envVarSettingVar = "EXAMPLE"+ , envVarSettingAllowPrefix = True+ } :|+ [])) Nothing Nothing+ []+ False (Just "BOOL")- (Just "Example of a yes/no switch"))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))) (Alt (Check Nothing True+ (fromList []) _ (Setting Nothing@@ -97,6 +123,10 @@ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :| [])) Nothing+ []+ False Nothing- (Just "Example of a yes/no switch"))))+ (Just "Example of a yes/no switch")+ Nothing+ (fromList [])))) (Pure _))))))