opt-env-conf-test 0.0.0.0 → 0.0.0.2
raw patch · 312 files changed
+6505/−1835 lines, 312 filesdep +autodocodecdep +path-iodep ~opt-env-confPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
Dependencies added: autodocodec, path-io
Dependency ranges changed: opt-env-conf
API changes (from Hackage documentation)
+ OptEnvConf.Test: goldenParserNixOptionsSpec :: HasCallStack => Parser a -> FilePath -> Spec
+ OptEnvConf.Test: goldenSettingsNixOptionsSpec :: forall a. HasCallStack => HasParser a => FilePath -> Spec
+ OptEnvConf.Test: parserArgsTest :: (Show a, Eq a) => Parser a -> [String] -> a -> IO ()
+ OptEnvConf.Test: parserCompletionDescriptionTest :: Parser a -> Int -> [String] -> [String] -> IO ()
+ OptEnvConf.Test: parserCompletionTest :: Parser a -> Int -> [String] -> [Completion String] -> IO ()
+ OptEnvConf.Test: parserConfTest :: (Show a, Eq a) => Parser a -> Object -> a -> IO ()
+ OptEnvConf.Test: parserEnvTest :: (Show a, Eq a) => Parser a -> [(String, String)] -> a -> IO ()
+ OptEnvConf.Test: parserTest :: (Show a, Eq a) => Parser a -> [String] -> [(String, String)] -> Maybe Object -> a -> IO ()
+ OptEnvConf.Test: pureGoldenNixOptions :: FilePath -> Parser a -> GoldenTest Text
+ OptEnvConf.Test: settingsParserArgsTest :: (Show a, Eq a, HasParser a) => [String] -> a -> IO ()
+ OptEnvConf.Test: settingsParserCompletionDescriptionTest :: forall a. HasParser a => Int -> [String] -> [String] -> IO ()
+ OptEnvConf.Test: settingsParserCompletionTest :: forall a. HasParser a => Int -> [String] -> [Completion String] -> IO ()
+ OptEnvConf.Test: settingsParserConfTest :: (Show a, Eq a, HasParser a) => Object -> a -> IO ()
+ OptEnvConf.Test: settingsParserEnvTest :: (Show a, Eq a, HasParser a) => [(String, String)] -> a -> IO ()
+ OptEnvConf.Test: settingsParserTest :: (Show a, Eq a, HasParser a) => [String] -> [(String, String)] -> Maybe Object -> a -> IO ()
Files
- CHANGELOG.md +20/−0
- app/Main.hs +0/−114
- opt-env-conf-test.cabal +178/−30
- src/OptEnvConf/Test.hs +91/−1
- test/OptEnvConf/APISpec.hs +244/−45
- test/OptEnvConf/ArgsSpec.hs +90/−24
- test/OptEnvConf/CompleterSpec.hs +79/−0
- test/OptEnvConf/CompletionSpec.hs +209/−7
- test/OptEnvConf/ErrorSpec.hs +40/−4
- test/OptEnvConf/HelpSpec.hs +167/−0
- test/OptEnvConf/LintSpec.hs +60/−7
- test/OptEnvConf/ReaderSpec.hs +29/−1
- test/OptEnvConf/RunSpec.hs +498/−195
- test/OptEnvConf/TestUtils.hs +9/−0
- test/OptEnvConf/ToplevelSpec.hs +58/−0
- test_resources/completion/bash-completion-script.bash +0/−1
- test_resources/docs/args/config-docs.txt +0/−1
- test_resources/docs/args/config.txt +0/−0
- test_resources/docs/args/docs.txt +0/−12
- test_resources/docs/args/env-docs.txt +0/−1
- test_resources/docs/args/env.txt +0/−0
- test_resources/docs/args/help.txt +0/−15
- test_resources/docs/args/man.txt +0/−26
- test_resources/docs/args/opt-docs.txt +0/−10
- test_resources/docs/args/opt-long.txt +0/−3
- test_resources/docs/args/opt-short.txt +0/−1
- test_resources/docs/args/reference.txt +0/−18
- test_resources/docs/args/show.txt +0/−18
- test_resources/docs/args/version.txt +0/−1
- test_resources/docs/big-config/config-docs.txt +10/−7
- test_resources/docs/big-config/config.txt +7/−3
- test_resources/docs/big-config/docs.txt +55/−39
- test_resources/docs/big-config/env-docs.txt +33/−21
- test_resources/docs/big-config/help.txt +9/−6
- test_resources/docs/big-config/man.txt +19/−12
- test_resources/docs/big-config/nix-options.nix +18/−0
- test_resources/docs/big-config/opt-docs.txt +17/−10
- test_resources/docs/big-config/opt-long.txt +1/−3
- test_resources/docs/big-config/opt-short.txt +1/−1
- test_resources/docs/big-config/reference.txt +20/−13
- test_resources/docs/big-config/show.txt +42/−36
- test_resources/docs/empty/docs.txt +1/−1
- test_resources/docs/empty/help.txt +1/−2
- test_resources/docs/empty/man.txt +3/−4
- test_resources/docs/empty/nix-options.nix +2/−0
- test_resources/docs/empty/opt-long.txt +0/−2
- test_resources/docs/empty/opt-short.txt +1/−1
- test_resources/docs/empty/reference.txt +4/−5
- test_resources/docs/enable-disable-optional/config-docs.txt +10/−0
- test_resources/docs/enable-disable-optional/config.txt +4/−0
- test_resources/docs/enable-disable-optional/docs.txt +55/−0
- test_resources/docs/enable-disable-optional/env-docs.txt +11/−0
- test_resources/docs/enable-disable-optional/env.txt +1/−0
- test_resources/docs/enable-disable-optional/help.txt +18/−0
- test_resources/docs/enable-disable-optional/man.txt +38/−0
- test_resources/docs/enable-disable-optional/nix-options.nix +8/−0
- test_resources/docs/enable-disable-optional/opt-docs.txt +16/−0
- test_resources/docs/enable-disable-optional/opt-long.txt +1/−0
- test_resources/docs/enable-disable-optional/opt-short.txt +1/−0
- test_resources/docs/enable-disable-optional/reference.txt +30/−0
- test_resources/docs/enable-disable-optional/show.txt +102/−0
- test_resources/docs/enable-disable-optional/version.txt +1/−0
- test_resources/docs/enable-disable/config-docs.txt +2/−8
- test_resources/docs/enable-disable/docs.txt +48/−50
- test_resources/docs/enable-disable/env-docs.txt +11/−8
- test_resources/docs/enable-disable/env.txt +1/−2
- test_resources/docs/enable-disable/help.txt +1/−6
- test_resources/docs/enable-disable/man.txt +5/−12
- test_resources/docs/enable-disable/nix-options.nix +8/−0
- test_resources/docs/enable-disable/opt-docs.txt +14/−20
- test_resources/docs/enable-disable/opt-long.txt +1/−4
- test_resources/docs/enable-disable/opt-short.txt +1/−1
- test_resources/docs/enable-disable/reference.txt +6/−13
- test_resources/docs/enable-disable/show.txt +9/−30
- test_resources/docs/greet/config-docs.txt +12/−7
- test_resources/docs/greet/config.txt +3/−0
- test_resources/docs/greet/docs.txt +65/−54
- test_resources/docs/greet/env-docs.txt +4/−1
- test_resources/docs/greet/env.txt +3/−3
- test_resources/docs/greet/help.txt +8/−5
- test_resources/docs/greet/man.txt +20/−14
- test_resources/docs/greet/nix-options.nix +13/−0
- test_resources/docs/greet/opt-docs.txt +48/−38
- test_resources/docs/greet/opt-long.txt +4/−6
- test_resources/docs/greet/opt-short.txt +1/−1
- test_resources/docs/greet/reference.txt +21/−15
- test_resources/docs/greet/show.txt +18/−15
- test_resources/docs/hidden/docs.txt +1/−1
- test_resources/docs/hidden/help.txt +1/−2
- test_resources/docs/hidden/man.txt +3/−4
- test_resources/docs/hidden/nix-options.nix +2/−0
- test_resources/docs/hidden/opt-long.txt +0/−2
- test_resources/docs/hidden/opt-short.txt +1/−1
- test_resources/docs/hidden/reference.txt +4/−5
- test_resources/docs/many-args/config-docs.txt +1/−0
- test_resources/docs/many-args/config.txt +0/−0
- test_resources/docs/many-args/docs.txt +17/−0
- test_resources/docs/many-args/env-docs.txt +1/−0
- test_resources/docs/many-args/env.txt +0/−0
- test_resources/docs/many-args/help.txt +14/−0
- test_resources/docs/many-args/man.txt +25/−0
- test_resources/docs/many-args/nix-options.nix +2/−0
- test_resources/docs/many-args/opt-docs.txt +14/−0
- test_resources/docs/many-args/opt-long.txt +1/−0
- test_resources/docs/many-args/opt-short.txt +1/−0
- test_resources/docs/many-args/reference.txt +17/−0
- test_resources/docs/many-args/show.txt +14/−0
- test_resources/docs/many-args/version.txt +1/−0
- test_resources/docs/optional/config-docs.txt +1/−1
- test_resources/docs/optional/docs.txt +17/−12
- test_resources/docs/optional/env-docs.txt +1/−1
- test_resources/docs/optional/help.txt +1/−2
- test_resources/docs/optional/man.txt +4/−5
- test_resources/docs/optional/nix-options.nix +2/−0
- test_resources/docs/optional/opt-docs.txt +14/−10
- test_resources/docs/optional/opt-long.txt +1/−3
- test_resources/docs/optional/opt-short.txt +1/−1
- test_resources/docs/optional/reference.txt +5/−6
- test_resources/docs/same-help/config-docs.txt +30/−0
- test_resources/docs/same-help/config.txt +12/−0
- test_resources/docs/same-help/docs.txt +100/−0
- test_resources/docs/same-help/env-docs.txt +44/−0
- test_resources/docs/same-help/env.txt +3/−0
- test_resources/docs/same-help/help.txt +30/−0
- test_resources/docs/same-help/man.txt +62/−0
- test_resources/docs/same-help/nix-options.nix +18/−0
- test_resources/docs/same-help/opt-docs.txt +44/−0
- test_resources/docs/same-help/opt-long.txt +3/−0
- test_resources/docs/same-help/opt-short.txt +1/−0
- test_resources/docs/same-help/reference.txt +54/−0
- test_resources/docs/same-help/show.txt +146/−0
- test_resources/docs/same-help/version.txt +1/−0
- test_resources/docs/secret/config-docs.txt +50/−0
- test_resources/docs/secret/config.txt +20/−0
- test_resources/docs/secret/docs.txt +224/−0
- test_resources/docs/secret/env-docs.txt +65/−0
- test_resources/docs/secret/env.txt +5/−0
- test_resources/docs/secret/help.txt +46/−0
- test_resources/docs/secret/man.txt +90/−0
- test_resources/docs/secret/nix-options.nix +18/−0
- test_resources/docs/secret/opt-docs.txt +74/−0
- test_resources/docs/secret/opt-long.txt +5/−0
- test_resources/docs/secret/opt-short.txt +1/−0
- test_resources/docs/secret/reference.txt +82/−0
- test_resources/docs/secret/show.txt +291/−0
- test_resources/docs/secret/version.txt +1/−0
- test_resources/docs/some-args/config-docs.txt +1/−0
- test_resources/docs/some-args/config.txt +0/−0
- test_resources/docs/some-args/docs.txt +33/−0
- test_resources/docs/some-args/env-docs.txt +1/−0
- test_resources/docs/some-args/env.txt +0/−0
- test_resources/docs/some-args/help.txt +17/−0
- test_resources/docs/some-args/man.txt +33/−0
- test_resources/docs/some-args/nix-options.nix +2/−0
- test_resources/docs/some-args/opt-docs.txt +28/−0
- test_resources/docs/some-args/opt-long.txt +2/−0
- test_resources/docs/some-args/opt-short.txt +1/−0
- test_resources/docs/some-args/reference.txt +25/−0
- test_resources/docs/some-args/show.txt +18/−0
- test_resources/docs/some-args/version.txt +1/−0
- test_resources/docs/sub-commands/config-docs.txt +14/−7
- test_resources/docs/sub-commands/config.txt +1/−0
- test_resources/docs/sub-commands/docs.txt +40/−30
- test_resources/docs/sub-commands/env-docs.txt +51/−44
- test_resources/docs/sub-commands/env.txt +2/−2
- test_resources/docs/sub-commands/help.txt +5/−27
- test_resources/docs/sub-commands/man.txt +13/−10
- test_resources/docs/sub-commands/nix-options.nix +8/−0
- test_resources/docs/sub-commands/opt-docs.txt +28/−19
- test_resources/docs/sub-commands/opt-long.txt +3/−5
- test_resources/docs/sub-commands/opt-short.txt +1/−1
- test_resources/docs/sub-commands/reference.txt +14/−11
- test_resources/docs/sub-commands/show.txt +17/−40
- test_resources/docs/sub-settings/config-docs.txt +20/−0
- test_resources/docs/sub-settings/config.txt +4/−0
- test_resources/docs/sub-settings/docs.txt +38/−0
- test_resources/docs/sub-settings/env-docs.txt +14/−0
- test_resources/docs/sub-settings/env.txt +2/−0
- test_resources/docs/sub-settings/help.txt +22/−0
- test_resources/docs/sub-settings/man.txt +44/−0
- test_resources/docs/sub-settings/nix-options.nix +22/−0
- test_resources/docs/sub-settings/opt-docs.txt +28/−0
- test_resources/docs/sub-settings/opt-long.txt +2/−0
- test_resources/docs/sub-settings/opt-short.txt +1/−0
- test_resources/docs/sub-settings/reference.txt +36/−0
- test_resources/docs/sub-settings/show.txt +49/−0
- test_resources/docs/sub-settings/version.txt +1/−0
- test_resources/docs/sum-type/config-docs.txt +10/−0
- test_resources/docs/sum-type/config.txt +4/−0
- test_resources/docs/sum-type/docs.txt +80/−0
- test_resources/docs/sum-type/env-docs.txt +13/−0
- test_resources/docs/sum-type/env.txt +1/−0
- test_resources/docs/sum-type/help.txt +24/−0
- test_resources/docs/sum-type/man.txt +45/−0
- test_resources/docs/sum-type/nix-options.nix +8/−0
- test_resources/docs/sum-type/opt-docs.txt +29/−0
- test_resources/docs/sum-type/opt-long.txt +2/−0
- test_resources/docs/sum-type/opt-short.txt +1/−0
- test_resources/docs/sum-type/reference.txt +37/−0
- test_resources/docs/sum-type/show.txt +83/−0
- test_resources/docs/sum-type/version.txt +1/−0
- test_resources/docs/three-commands/config-docs.txt +29/−33
- test_resources/docs/three-commands/config.txt +2/−1
- test_resources/docs/three-commands/docs.txt +89/−85
- test_resources/docs/three-commands/env-docs.txt +19/−15
- test_resources/docs/three-commands/env.txt +2/−3
- test_resources/docs/three-commands/help.txt +5/−31
- test_resources/docs/three-commands/man.txt +17/−20
- test_resources/docs/three-commands/nix-options.nix +13/−0
- test_resources/docs/three-commands/opt-docs.txt +57/−58
- test_resources/docs/three-commands/opt-long.txt +5/−8
- test_resources/docs/three-commands/opt-short.txt +1/−1
- test_resources/docs/three-commands/reference.txt +18/−21
- test_resources/docs/three-commands/show.txt +31/−61
- test_resources/docs/verbose/config-docs.txt +1/−1
- test_resources/docs/verbose/docs.txt +18/−13
- test_resources/docs/verbose/env-docs.txt +1/−1
- test_resources/docs/verbose/help.txt +1/−2
- test_resources/docs/verbose/man.txt +4/−5
- test_resources/docs/verbose/nix-options.nix +2/−0
- test_resources/docs/verbose/opt-docs.txt +15/−11
- test_resources/docs/verbose/opt-long.txt +1/−3
- test_resources/docs/verbose/opt-short.txt +1/−1
- test_resources/docs/verbose/reference.txt +5/−6
- test_resources/docs/with-default/config-docs.txt +1/−0
- test_resources/docs/with-default/config.txt +0/−0
- test_resources/docs/with-default/docs.txt +30/−0
- test_resources/docs/with-default/env-docs.txt +1/−0
- test_resources/docs/with-default/env.txt +0/−0
- test_resources/docs/with-default/help.txt +18/−0
- test_resources/docs/with-default/man.txt +30/−0
- test_resources/docs/with-default/nix-options.nix +2/−0
- test_resources/docs/with-default/opt-docs.txt +26/−0
- test_resources/docs/with-default/opt-long.txt +2/−0
- test_resources/docs/with-default/opt-short.txt +1/−0
- test_resources/docs/with-default/reference.txt +22/−0
- test_resources/docs/with-default/show.txt +27/−0
- test_resources/docs/with-default/version.txt +1/−0
- test_resources/docs/yes-no-optional/config-docs.txt +10/−0
- test_resources/docs/yes-no-optional/config.txt +4/−0
- test_resources/docs/yes-no-optional/docs.txt +55/−0
- test_resources/docs/yes-no-optional/env-docs.txt +11/−0
- test_resources/docs/yes-no-optional/env.txt +1/−0
- test_resources/docs/yes-no-optional/help.txt +18/−0
- test_resources/docs/yes-no-optional/man.txt +38/−0
- test_resources/docs/yes-no-optional/nix-options.nix +8/−0
- test_resources/docs/yes-no-optional/opt-docs.txt +16/−0
- test_resources/docs/yes-no-optional/opt-long.txt +1/−0
- test_resources/docs/yes-no-optional/opt-short.txt +1/−0
- test_resources/docs/yes-no-optional/reference.txt +30/−0
- test_resources/docs/yes-no-optional/show.txt +102/−0
- test_resources/docs/yes-no-optional/version.txt +1/−0
- test_resources/docs/yes-no/config-docs.txt +2/−8
- test_resources/docs/yes-no/docs.txt +48/−50
- test_resources/docs/yes-no/env-docs.txt +11/−8
- test_resources/docs/yes-no/env.txt +1/−2
- test_resources/docs/yes-no/help.txt +1/−6
- test_resources/docs/yes-no/man.txt +5/−12
- test_resources/docs/yes-no/nix-options.nix +8/−0
- test_resources/docs/yes-no/opt-docs.txt +14/−20
- test_resources/docs/yes-no/opt-long.txt +1/−4
- test_resources/docs/yes-no/opt-short.txt +1/−1
- test_resources/docs/yes-no/reference.txt +6/−13
- test_resources/docs/yes-no/show.txt +9/−30
- test_resources/error/all-or-nothing-relevant.txt +3/−1
- test_resources/error/all-or-nothing.txt +3/−1
- test_resources/error/leftover-argument.txt +1/−0
- test_resources/error/leftover-option.txt +1/−0
- test_resources/error/leftover-switch.txt +1/−0
- test_resources/error/missing-argument.txt +1/−1
- test_resources/error/missing-option.txt +1/−1
- test_resources/error/missing-options.txt +2/−2
- test_resources/error/read-int-argument.txt +1/−1
- test_resources/error/read-int-option.txt +1/−1
- test_resources/error/read-int-options.txt +2/−2
- test_resources/error/required-command.txt +2/−1
- test_resources/error/some-none.txt +1/−1
- test_resources/error/typo-option.txt +1/−0
- test_resources/error/typo-switch.txt +1/−0
- test_resources/error/unfolding-tombstone-option.txt +1/−1
- test_resources/error/unfolding-tombstone-switch.txt +1/−1
- test_resources/error/unrecognised-arg.txt +1/−0
- test_resources/error/unrecognised-command.txt +2/−1
- test_resources/error/unrecognised-option.txt +1/−0
- test_resources/error/unrecognised-switch.txt +1/−0
- test_resources/help/create.txt +11/−0
- test_resources/help/read.txt +8/−0
- test_resources/help/sub-bar.txt +8/−0
- test_resources/help/sub-foo.txt +8/−0
- test_resources/help/sub.txt +12/−0
- test_resources/help/toplevel-pure-with-invalid-port.txt +57/−0
- test_resources/help/toplevel-pure.txt +57/−0
- test_resources/help/wrong-command.txt +57/−0
- test_resources/lint/config-without-load.txt +3/−2
- test_resources/lint/dash-in-long.txt +1/−1
- test_resources/lint/dash-in-short.txt +1/−1
- test_resources/lint/many-conf.txt +5/−0
- test_resources/lint/many-env.txt +5/−0
- test_resources/lint/no-commands.txt +1/−1
- test_resources/lint/no-dashed-for-option.txt +1/−1
- test_resources/lint/no-dashed-for-switch.txt +1/−1
- test_resources/lint/no-metavar-for-argument.txt +1/−1
- test_resources/lint/no-metavar-for-env.txt +2/−2
- test_resources/lint/no-metavar-for-option.txt +2/−2
- test_resources/lint/no-option-or-switch-for-dashed.txt +5/−0
- test_resources/lint/no-reader-for-argument.txt +1/−1
- test_resources/lint/no-reader-for-env.txt +4/−4
- test_resources/lint/no-reader-for-option.txt +2/−2
- test_resources/lint/some-conf.txt +5/−0
- test_resources/lint/some-env.txt +5/−0
- test_resources/lint/unknown-default-command.txt +5/−0
- test_resources/lint/unreadable-example.txt +1/−1
CHANGELOG.md view
@@ -1,5 +1,25 @@ # Changelog +## [0.0.0.2] - 2025-03-12++### Added++* Completions test helpers+++## [0.0.0.1] - 2024-08-08++### Added++* `settingsParserArgsTest`+* `parserArgsTest`+* `settingsParserEnvTest`+* `parserEnvTest`+* `settingsParserConfTest`+* `parserConfTest`+* `settingsParserTest`+* `parserTest`+ ## [0.0.0.0] - 2024-07-08 First version
− app/Main.hs
@@ -1,114 +0,0 @@-{-# LANGUAGE ApplicativeDo #-}-{-# LANGUAGE RecordWildCards #-}--module Main where--import Data.Text (Text)-import OptEnvConf-import Paths_opt_env_conf_test (version)--main :: IO ()-main = do- s <-- runSettingsParser- version- "Example opt-env-conf-based application"- print (s :: Instructions)--data Instructions = Instructions !Settings !Dispatch- deriving (Show)--instance HasParser Instructions where- settingsParser =- withLocalYamlConfig $- Instructions- <$> settingsParser- <*> settingsParser--data Dispatch- = DispatchCreate !String- | DispatchRead- | DispatchUpdate !String !String- | DispatchDelete- deriving (Show)--instance HasParser Dispatch where- settingsParser =- commands- [ command "create" "Create" $- DispatchCreate- <$> setting- [ help "The item to create",- reader str,- argument,- metavar "STR"- ],- command "read" "Read" $ pure DispatchRead,- command "update" "Update" $- DispatchUpdate- <$> setting- [ help "The item identifier of the item to update",- reader str,- argument,- metavar "STR"- ]- <*> setting- [ help "The contents of the item to update",- reader str,- argument,- metavar "STR"- ],- command "delete" "Delete" $ pure DispatchDelete- ]--data Settings = Settings- { settingLogLevel :: String,- settingPaymentSettings :: Maybe PaymentSettings- }- deriving (Show)--instance HasParser Settings where- settingsParser = do- settingLogLevel <-- setting- [ help "minimal severity of log messages",- reader str,- metavar "LOG_LEVEL",- name "log-level",- value "DEBUG"- ]- settingPaymentSettings <- optional $ subSettings "payment"- pure Settings {..}--data PaymentSettings = PaymentSettings- { paymentSetPublicKey :: String,- paymentSetSecretKey :: Text,- paymentSetCurrency :: Maybe String- }- deriving (Show)--instance HasParser PaymentSettings where- settingsParser = do- paymentSetPublicKey <-- setting- [ help "Public key",- reader str,- name "public-key",- metavar "PUBLIC_KEY"- ]- paymentSetSecretKey <-- mapIO readSecretTextFile $- filePathSetting- [ help "Secret key",- name "secret-key",- metavar "SECRET_KEY_FILE"- ]- paymentSetCurrency <-- optional $- setting- [ help "Currency",- reader str,- name "currency",- metavar "CURRENCY"- ]- pure PaymentSettings {..}
opt-env-conf-test.cabal view
@@ -1,13 +1,17 @@ cabal-version: 1.12 --- This file has been generated from package.yaml by hpack version 0.36.0.+-- This file has been generated from package.yaml by hpack version 0.36.1. -- -- see: https://github.com/sol/hpack name: opt-env-conf-test-version: 0.0.0.0+version: 0.0.0.2 synopsis: A testing companion package for opt-env-conf-copyright: Copyright: (c) 2024 Tom Sydney Kerckhove+homepage: https://github.com/NorfairKing/opt-env-conf#readme+bug-reports: https://github.com/NorfairKing/opt-env-conf/issues+author: Tom Sydney Kerckhove+maintainer: syd@cs-syd.eu+copyright: Copyright: (c) 2024-2025 Tom Sydney Kerckhove license: OtherLicense license-file: LICENSE.md build-type: Simple@@ -16,19 +20,6 @@ test_resources/completion/bash-completion-script.bash test_resources/completion/fish-completion-script.fish test_resources/completion/zsh-completion-script.zsh- test_resources/docs/args/config-docs.txt- test_resources/docs/args/config.txt- test_resources/docs/args/docs.txt- test_resources/docs/args/env-docs.txt- test_resources/docs/args/env.txt- test_resources/docs/args/help.txt- test_resources/docs/args/man.txt- test_resources/docs/args/opt-docs.txt- test_resources/docs/args/opt-long.txt- test_resources/docs/args/opt-short.txt- test_resources/docs/args/reference.txt- test_resources/docs/args/show.txt- test_resources/docs/args/version.txt test_resources/docs/big-config/config-docs.txt test_resources/docs/big-config/config.txt test_resources/docs/big-config/docs.txt@@ -36,6 +27,7 @@ test_resources/docs/big-config/env.txt test_resources/docs/big-config/help.txt test_resources/docs/big-config/man.txt+ test_resources/docs/big-config/nix-options.nix test_resources/docs/big-config/opt-docs.txt test_resources/docs/big-config/opt-long.txt test_resources/docs/big-config/opt-short.txt@@ -49,12 +41,27 @@ test_resources/docs/empty/env.txt test_resources/docs/empty/help.txt test_resources/docs/empty/man.txt+ test_resources/docs/empty/nix-options.nix test_resources/docs/empty/opt-docs.txt test_resources/docs/empty/opt-long.txt test_resources/docs/empty/opt-short.txt test_resources/docs/empty/reference.txt test_resources/docs/empty/show.txt test_resources/docs/empty/version.txt+ test_resources/docs/enable-disable-optional/config-docs.txt+ test_resources/docs/enable-disable-optional/config.txt+ test_resources/docs/enable-disable-optional/docs.txt+ test_resources/docs/enable-disable-optional/env-docs.txt+ test_resources/docs/enable-disable-optional/env.txt+ test_resources/docs/enable-disable-optional/help.txt+ test_resources/docs/enable-disable-optional/man.txt+ test_resources/docs/enable-disable-optional/nix-options.nix+ test_resources/docs/enable-disable-optional/opt-docs.txt+ test_resources/docs/enable-disable-optional/opt-long.txt+ test_resources/docs/enable-disable-optional/opt-short.txt+ test_resources/docs/enable-disable-optional/reference.txt+ test_resources/docs/enable-disable-optional/show.txt+ test_resources/docs/enable-disable-optional/version.txt test_resources/docs/enable-disable/config-docs.txt test_resources/docs/enable-disable/config.txt test_resources/docs/enable-disable/docs.txt@@ -62,6 +69,7 @@ test_resources/docs/enable-disable/env.txt test_resources/docs/enable-disable/help.txt test_resources/docs/enable-disable/man.txt+ test_resources/docs/enable-disable/nix-options.nix test_resources/docs/enable-disable/opt-docs.txt test_resources/docs/enable-disable/opt-long.txt test_resources/docs/enable-disable/opt-short.txt@@ -75,6 +83,7 @@ test_resources/docs/greet/env.txt test_resources/docs/greet/help.txt test_resources/docs/greet/man.txt+ test_resources/docs/greet/nix-options.nix test_resources/docs/greet/opt-docs.txt test_resources/docs/greet/opt-long.txt test_resources/docs/greet/opt-short.txt@@ -88,12 +97,27 @@ test_resources/docs/hidden/env.txt test_resources/docs/hidden/help.txt test_resources/docs/hidden/man.txt+ test_resources/docs/hidden/nix-options.nix test_resources/docs/hidden/opt-docs.txt test_resources/docs/hidden/opt-long.txt test_resources/docs/hidden/opt-short.txt test_resources/docs/hidden/reference.txt test_resources/docs/hidden/show.txt test_resources/docs/hidden/version.txt+ test_resources/docs/many-args/config-docs.txt+ test_resources/docs/many-args/config.txt+ test_resources/docs/many-args/docs.txt+ test_resources/docs/many-args/env-docs.txt+ test_resources/docs/many-args/env.txt+ test_resources/docs/many-args/help.txt+ test_resources/docs/many-args/man.txt+ test_resources/docs/many-args/nix-options.nix+ test_resources/docs/many-args/opt-docs.txt+ test_resources/docs/many-args/opt-long.txt+ test_resources/docs/many-args/opt-short.txt+ test_resources/docs/many-args/reference.txt+ test_resources/docs/many-args/show.txt+ test_resources/docs/many-args/version.txt test_resources/docs/optional/config-docs.txt test_resources/docs/optional/config.txt test_resources/docs/optional/docs.txt@@ -101,12 +125,55 @@ test_resources/docs/optional/env.txt test_resources/docs/optional/help.txt test_resources/docs/optional/man.txt+ test_resources/docs/optional/nix-options.nix test_resources/docs/optional/opt-docs.txt test_resources/docs/optional/opt-long.txt test_resources/docs/optional/opt-short.txt test_resources/docs/optional/reference.txt test_resources/docs/optional/show.txt test_resources/docs/optional/version.txt+ test_resources/docs/same-help/config-docs.txt+ test_resources/docs/same-help/config.txt+ test_resources/docs/same-help/docs.txt+ test_resources/docs/same-help/env-docs.txt+ test_resources/docs/same-help/env.txt+ test_resources/docs/same-help/help.txt+ test_resources/docs/same-help/man.txt+ test_resources/docs/same-help/nix-options.nix+ test_resources/docs/same-help/opt-docs.txt+ test_resources/docs/same-help/opt-long.txt+ test_resources/docs/same-help/opt-short.txt+ test_resources/docs/same-help/reference.txt+ test_resources/docs/same-help/show.txt+ test_resources/docs/same-help/version.txt+ test_resources/docs/secret/config-docs.txt+ test_resources/docs/secret/config.txt+ test_resources/docs/secret/docs.txt+ test_resources/docs/secret/env-docs.txt+ test_resources/docs/secret/env.txt+ test_resources/docs/secret/help.txt+ test_resources/docs/secret/man.txt+ test_resources/docs/secret/nix-options.nix+ test_resources/docs/secret/opt-docs.txt+ test_resources/docs/secret/opt-long.txt+ test_resources/docs/secret/opt-short.txt+ test_resources/docs/secret/reference.txt+ test_resources/docs/secret/show.txt+ test_resources/docs/secret/version.txt+ test_resources/docs/some-args/config-docs.txt+ test_resources/docs/some-args/config.txt+ test_resources/docs/some-args/docs.txt+ test_resources/docs/some-args/env-docs.txt+ test_resources/docs/some-args/env.txt+ test_resources/docs/some-args/help.txt+ test_resources/docs/some-args/man.txt+ test_resources/docs/some-args/nix-options.nix+ test_resources/docs/some-args/opt-docs.txt+ test_resources/docs/some-args/opt-long.txt+ test_resources/docs/some-args/opt-short.txt+ test_resources/docs/some-args/reference.txt+ test_resources/docs/some-args/show.txt+ test_resources/docs/some-args/version.txt test_resources/docs/sub-commands/config-docs.txt test_resources/docs/sub-commands/config.txt test_resources/docs/sub-commands/docs.txt@@ -114,12 +181,41 @@ test_resources/docs/sub-commands/env.txt test_resources/docs/sub-commands/help.txt test_resources/docs/sub-commands/man.txt+ test_resources/docs/sub-commands/nix-options.nix test_resources/docs/sub-commands/opt-docs.txt test_resources/docs/sub-commands/opt-long.txt test_resources/docs/sub-commands/opt-short.txt test_resources/docs/sub-commands/reference.txt test_resources/docs/sub-commands/show.txt test_resources/docs/sub-commands/version.txt+ test_resources/docs/sub-settings/config-docs.txt+ test_resources/docs/sub-settings/config.txt+ test_resources/docs/sub-settings/docs.txt+ test_resources/docs/sub-settings/env-docs.txt+ test_resources/docs/sub-settings/env.txt+ test_resources/docs/sub-settings/help.txt+ test_resources/docs/sub-settings/man.txt+ test_resources/docs/sub-settings/nix-options.nix+ test_resources/docs/sub-settings/opt-docs.txt+ test_resources/docs/sub-settings/opt-long.txt+ test_resources/docs/sub-settings/opt-short.txt+ test_resources/docs/sub-settings/reference.txt+ test_resources/docs/sub-settings/show.txt+ test_resources/docs/sub-settings/version.txt+ test_resources/docs/sum-type/config-docs.txt+ test_resources/docs/sum-type/config.txt+ test_resources/docs/sum-type/docs.txt+ test_resources/docs/sum-type/env-docs.txt+ test_resources/docs/sum-type/env.txt+ test_resources/docs/sum-type/help.txt+ test_resources/docs/sum-type/man.txt+ test_resources/docs/sum-type/nix-options.nix+ test_resources/docs/sum-type/opt-docs.txt+ test_resources/docs/sum-type/opt-long.txt+ test_resources/docs/sum-type/opt-short.txt+ test_resources/docs/sum-type/reference.txt+ test_resources/docs/sum-type/show.txt+ test_resources/docs/sum-type/version.txt test_resources/docs/three-commands/config-docs.txt test_resources/docs/three-commands/config.txt test_resources/docs/three-commands/docs.txt@@ -127,6 +223,7 @@ test_resources/docs/three-commands/env.txt test_resources/docs/three-commands/help.txt test_resources/docs/three-commands/man.txt+ test_resources/docs/three-commands/nix-options.nix test_resources/docs/three-commands/opt-docs.txt test_resources/docs/three-commands/opt-long.txt test_resources/docs/three-commands/opt-short.txt@@ -140,12 +237,41 @@ test_resources/docs/verbose/env.txt test_resources/docs/verbose/help.txt test_resources/docs/verbose/man.txt+ test_resources/docs/verbose/nix-options.nix test_resources/docs/verbose/opt-docs.txt test_resources/docs/verbose/opt-long.txt test_resources/docs/verbose/opt-short.txt test_resources/docs/verbose/reference.txt test_resources/docs/verbose/show.txt test_resources/docs/verbose/version.txt+ test_resources/docs/with-default/config-docs.txt+ test_resources/docs/with-default/config.txt+ test_resources/docs/with-default/docs.txt+ test_resources/docs/with-default/env-docs.txt+ test_resources/docs/with-default/env.txt+ test_resources/docs/with-default/help.txt+ test_resources/docs/with-default/man.txt+ test_resources/docs/with-default/nix-options.nix+ test_resources/docs/with-default/opt-docs.txt+ test_resources/docs/with-default/opt-long.txt+ test_resources/docs/with-default/opt-short.txt+ test_resources/docs/with-default/reference.txt+ test_resources/docs/with-default/show.txt+ test_resources/docs/with-default/version.txt+ test_resources/docs/yes-no-optional/config-docs.txt+ test_resources/docs/yes-no-optional/config.txt+ test_resources/docs/yes-no-optional/docs.txt+ test_resources/docs/yes-no-optional/env-docs.txt+ test_resources/docs/yes-no-optional/env.txt+ test_resources/docs/yes-no-optional/help.txt+ test_resources/docs/yes-no-optional/man.txt+ test_resources/docs/yes-no-optional/nix-options.nix+ test_resources/docs/yes-no-optional/opt-docs.txt+ test_resources/docs/yes-no-optional/opt-long.txt+ test_resources/docs/yes-no-optional/opt-short.txt+ test_resources/docs/yes-no-optional/reference.txt+ test_resources/docs/yes-no-optional/show.txt+ test_resources/docs/yes-no-optional/version.txt test_resources/docs/yes-no/config-docs.txt test_resources/docs/yes-no/config.txt test_resources/docs/yes-no/docs.txt@@ -153,6 +279,7 @@ test_resources/docs/yes-no/env.txt test_resources/docs/yes-no/help.txt test_resources/docs/yes-no/man.txt+ test_resources/docs/yes-no/nix-options.nix test_resources/docs/yes-no/opt-docs.txt test_resources/docs/yes-no/opt-long.txt test_resources/docs/yes-no/opt-short.txt@@ -165,6 +292,9 @@ test_resources/error/check-failed-checkMaybe.txt test_resources/error/empty-choice.txt test_resources/error/empty.txt+ test_resources/error/leftover-argument.txt+ test_resources/error/leftover-option.txt+ test_resources/error/leftover-switch.txt test_resources/error/missing-argument.txt test_resources/error/missing-env.txt test_resources/error/missing-option.txt@@ -176,28 +306,51 @@ test_resources/error/read-int-options.txt test_resources/error/required-command.txt test_resources/error/some-none.txt+ test_resources/error/typo-option.txt+ test_resources/error/typo-switch.txt test_resources/error/unfolding-tombstone-option.txt test_resources/error/unfolding-tombstone-switch.txt test_resources/error/unreadable-var.txt test_resources/error/unreadable-vars.txt+ test_resources/error/unrecognised-arg.txt test_resources/error/unrecognised-command.txt+ test_resources/error/unrecognised-option.txt+ test_resources/error/unrecognised-switch.txt+ test_resources/help/create.txt+ test_resources/help/read.txt+ test_resources/help/sub-bar.txt+ test_resources/help/sub-foo.txt+ test_resources/help/sub.txt+ test_resources/help/toplevel-pure-with-invalid-port.txt+ test_resources/help/toplevel-pure.txt+ test_resources/help/wrong-command.txt test_resources/lint/config-without-load.txt test_resources/lint/dash-in-long.txt test_resources/lint/dash-in-short.txt test_resources/lint/empty-setting.txt+ test_resources/lint/many-conf.txt+ test_resources/lint/many-env.txt test_resources/lint/no-commands.txt test_resources/lint/no-dashed-for-option.txt test_resources/lint/no-dashed-for-switch.txt test_resources/lint/no-metavar-for-argument.txt test_resources/lint/no-metavar-for-env.txt test_resources/lint/no-metavar-for-option.txt+ test_resources/lint/no-option-or-switch-for-dashed.txt test_resources/lint/no-reader-for-argument.txt test_resources/lint/no-reader-for-env.txt test_resources/lint/no-reader-for-option.txt test_resources/lint/null-setting.txt test_resources/lint/only-default.txt+ test_resources/lint/some-conf.txt+ test_resources/lint/some-env.txt+ test_resources/lint/unknown-default-command.txt test_resources/lint/unreadable-example.txt +source-repository head+ type: git+ location: https://github.com/NorfairKing/opt-env-conf+ library exposed-modules: OptEnvConf.Args.Gen@@ -209,40 +362,33 @@ src/ ghc-options: -Wall build-depends:- base <5+ aeson+ , base <5 , genvalidity , genvalidity-containers- , opt-env-conf+ , opt-env-conf >=0.9.0.0 , safe-coloured-text , sydtest , text default-language: Haskell2010 -executable opt-env-conf-example- main-is: Main.hs- other-modules:- Paths_opt_env_conf_test- hs-source-dirs:- app- build-depends:- base <5- , opt-env-conf- , text- default-language: Haskell2010- test-suite opt-env-conf-test type: exitcode-stdio-1.0 main-is: Spec.hs other-modules: OptEnvConf.APISpec OptEnvConf.ArgsSpec+ OptEnvConf.CompleterSpec OptEnvConf.CompletionSpec OptEnvConf.EnvMapSpec OptEnvConf.ErrorSpec+ OptEnvConf.HelpSpec OptEnvConf.LintSpec OptEnvConf.NonDetSpec OptEnvConf.ReaderSpec OptEnvConf.RunSpec+ OptEnvConf.TestUtils+ OptEnvConf.ToplevelSpec Paths_opt_env_conf_test hs-source-dirs: test/@@ -252,6 +398,7 @@ build-depends: QuickCheck , aeson+ , autodocodec , base <5 , containers , genvalidity-aeson@@ -261,6 +408,7 @@ , opt-env-conf , opt-env-conf-test , path+ , path-io , pretty-show , safe-coloured-text , sydtest
src/OptEnvConf/Test.hs view
@@ -3,19 +3,50 @@ {-# LANGUAGE TypeApplications #-} module OptEnvConf.Test- ( settingsLintSpec,+ ( -- * Lint test+ settingsLintSpec, parserLintSpec, parserLintTest,++ -- * Parse tests+ settingsParserArgsTest,+ parserArgsTest,+ settingsParserEnvTest,+ parserEnvTest,+ settingsParserConfTest,+ parserConfTest,+ settingsParserTest,+ parserTest,++ -- * Completion tests+ settingsParserCompletionTest,+ settingsParserCompletionDescriptionTest,+ parserCompletionTest,+ parserCompletionDescriptionTest,++ -- * Reference documentation goldenSettingsReferenceDocumentationSpec, goldenParserReferenceDocumentationSpec, pureGoldenReferenceDocumentation,++ -- * Nix options+ goldenSettingsNixOptionsSpec,+ goldenParserNixOptionsSpec,+ pureGoldenNixOptions,+ module OptEnvConf, ) where +import Data.Aeson as JSON+import Data.Maybe import Data.Text (Text) import qualified Data.Text as T import GHC.Stack (HasCallStack, withFrozenCallStack) import OptEnvConf+import OptEnvConf.Args+import OptEnvConf.Completion+import OptEnvConf.EnvMap as EnvMap+import OptEnvConf.Error import OptEnvConf.Lint import Test.Syd import Text.Colour@@ -36,6 +67,52 @@ Just errs -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderLintErrors errs +settingsParserArgsTest :: (Show a, Eq a, HasParser a) => [String] -> a -> IO ()+settingsParserArgsTest = parserArgsTest settingsParser++parserArgsTest :: (Show a, Eq a) => Parser a -> [String] -> a -> IO ()+parserArgsTest parser args = parserTest parser args [] Nothing++settingsParserEnvTest :: (Show a, Eq a, HasParser a) => [(String, String)] -> a -> IO ()+settingsParserEnvTest = parserEnvTest settingsParser++parserEnvTest :: (Show a, Eq a) => Parser a -> [(String, String)] -> a -> IO ()+parserEnvTest parser envVars = parserTest parser [] envVars Nothing++settingsParserConfTest :: (Show a, Eq a, HasParser a) => JSON.Object -> a -> IO ()+settingsParserConfTest = parserConfTest settingsParser++parserConfTest :: (Show a, Eq a) => Parser a -> JSON.Object -> a -> IO ()+parserConfTest parser obj = parserTest parser [] [] (Just obj)++settingsParserTest :: (Show a, Eq a, HasParser a) => [String] -> [(String, String)] -> Maybe JSON.Object -> a -> IO ()+settingsParserTest = parserTest settingsParser++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+ case errOrActual of+ Left errs -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors errs+ Right actual -> actual `shouldBe` expected++settingsParserCompletionTest :: forall a. (HasParser a) => Int -> [String] -> [Completion String] -> IO ()+settingsParserCompletionTest = parserCompletionTest (settingsParser @a)++settingsParserCompletionDescriptionTest :: forall a. (HasParser a) => Int -> [String] -> [String] -> IO ()+settingsParserCompletionDescriptionTest = parserCompletionDescriptionTest (settingsParser @a)++parserCompletionTest :: Parser a -> Int -> [String] -> [Completion String] -> IO ()+parserCompletionTest p ix ws expected = do+ let arg = fromMaybe "" $ listToMaybe $ drop ix ws+ let completions = pureCompletionQuery p ix ws+ evaluatedCompletions <- evalCompletions arg completions+ evaluatedCompletions `shouldBe` expected++parserCompletionDescriptionTest :: Parser a -> Int -> [String] -> [String] -> IO ()+parserCompletionDescriptionTest p ix ws descriptions = do+ let completions = pureCompletionQuery p ix ws+ map completionDescription completions `shouldBe` map Just descriptions+ goldenSettingsReferenceDocumentationSpec :: forall a. (HasCallStack) => (HasParser a) => FilePath -> String -> Spec goldenSettingsReferenceDocumentationSpec path progname = withFrozenCallStack $ goldenParserReferenceDocumentationSpec (settingsParser @a) path progname @@ -50,3 +127,16 @@ renderChunksText With24BitColours $ renderReferenceDocumentation progname $ parserDocs parser++goldenSettingsNixOptionsSpec :: forall a. (HasCallStack) => (HasParser a) => FilePath -> Spec+goldenSettingsNixOptionsSpec path = withFrozenCallStack $ goldenParserNixOptionsSpec (settingsParser @a) path++goldenParserNixOptionsSpec :: (HasCallStack) => Parser a -> FilePath -> Spec+goldenParserNixOptionsSpec parser path = withFrozenCallStack $ do+ specify "produces the nix options as before" $+ pureGoldenNixOptions path parser++pureGoldenNixOptions :: FilePath -> Parser a -> GoldenTest Text+pureGoldenNixOptions path parser =+ pureGoldenTextFile path $+ renderParserNixOptions parser
test/OptEnvConf/APISpec.hs view
@@ -1,13 +1,17 @@+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} module OptEnvConf.APISpec (spec) where +import Autodocodec import Data.Map (Map) import Data.Text (Text) import Data.Version import GHC.Stack (HasCallStack, withFrozenCallStack) import OptEnvConf import OptEnvConf.Test+import OptEnvConf.TestUtils import Test.Syd import Text.Colour import Text.Show.Pretty as Pretty@@ -15,13 +19,21 @@ spec :: Spec spec = do exampleParserSpec "empty" "empty parser" emptyParser- exampleParserSpec "args" "args parser" argsParser+ exampleParserSpec "many-args" "many args parser" manyArgsParser+ exampleParserSpec "some-args" "some args parser" someArgsParser exampleParserSpec "optional" "optional argument" optionalParser exampleParserSpec "big-config" "example with a big configuration" bigConfigParser+ exampleParserSpec "sub-settings" "example with a sub settings" subSettingsParser exampleParserSpec "hidden" "example with hidden settings" hiddenParser exampleParserSpec "enable-disable" "enableDisableSwitch example" enableDisableParser exampleParserSpec "yes-no" "yesNoSwitch example" yesNoParser+ exampleParserSpec "enable-disable-optional" "enableDisableSwitch' example" enableDisableParser'+ exampleParserSpec "yes-no-optional" "yesNoSwitch' example" yesNoParser' exampleParserSpec "verbose" "verbosity example" verboseParser+ exampleParserSpec "same-help" "example where multiple options use the same help string" sameHelpParser+ exampleParserSpec "sum-type" "Sum type example" sumTypeParser+ exampleParserSpec "secret" "Secrets example" secretParser+ exampleParserSpec "with-default" "withDefault example" withDefaultParser exampleParserSpec "greet" "hello world example" greetParser exampleParserSpec "three-commands" "example with three commands" threeCommandsParser exampleParserSpec "sub-commands" "example with subcommands" subCommandsParser@@ -29,10 +41,9 @@ exampleParserSpec :: (HasCallStack) => FilePath -> String -> Parser a -> Spec exampleParserSpec dir progDesc p = withFrozenCallStack $ describe dir $ do let version = makeVersion [0, 0, 0]- let parser = internalParser version p it "passes the linter" $- parserLintTest parser+ parserLintTest p it "shows the parser in the same way" $ goldenStringFile ("test_resources/docs/" <> dir <> "/show.txt") $@@ -66,44 +77,171 @@ it "documents the help page in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/help.txt") $- renderHelpPage dir progDesc $- parserDocs parser+ renderHelpPage dir version progDesc $+ parserDocs p it "documents the short opt parser in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/opt-short.txt") $ renderShortOptDocs dir $- parserOptDocs parser+ parserOptDocs p it "documents the long opt parser in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/opt-long.txt") $ renderLongOptDocs $- parserOptDocs parser+ parserOptDocs p it "documents the env parser in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/env.txt") $ renderEnvDocs $- parserEnvDocs parser+ parserEnvDocs p it "documents the conf parser in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/config.txt") $ renderConfDocs $- parserConfDocs parser+ parserConfDocs p it "documents the man page in the same way" $ pureGoldenTextFile ("test_resources/docs/" <> dir <> "/man.txt") $ renderChunksText WithoutColours $ renderManPage dir version progDesc $- parserDocs parser+ parserDocs p it "renders the reference documentation in the same way" $ pureGoldenChunksFile ("test_resources/docs/" <> dir <> "/reference.txt") $ renderReferenceDocumentation dir $- parserDocs parser+ parserDocs p -pureGoldenChunksFile :: FilePath -> [Chunk] -> GoldenTest Text-pureGoldenChunksFile fp cs =- pureGoldenTextFile fp $ renderChunksText With24BitColours cs+ it "renders the Nix options the same way" $+ pureGoldenTextFile ("test_resources/docs/" <> dir <> "/nix-options.nix") $+ renderParserNixOptions p +sameHelpParser :: Parser (Either Int String, Bool)+sameHelpParser =+ withoutConfig $+ let h = help "int or string"+ in (,)+ <$> choice+ [ Left+ <$> setting+ [ h,+ name "int",+ reader auto,+ metavar "INT"+ ],+ Right+ <$> setting+ [ h,+ name "string",+ reader str,+ metavar "STR"+ ]+ ]+ <*> yesNoSwitch+ [ h,+ name "other",+ value True+ ]++data SumType+ = SumTypeA+ | SumTypeB+ deriving (Show)++instance HasCodec SumType where+ codec = bimapCodec parseSumType renderSumType codec++parseSumType :: String -> Either String SumType+parseSumType = \case+ "a" -> pure SumTypeA+ "b" -> pure SumTypeB+ s -> Left $ unwords ["Unknown 'SumType':", s]++renderSumType :: SumType -> String+renderSumType = \case+ SumTypeA -> "a"+ SumTypeB -> "b"++sumTypeParser :: Parser SumType+sumTypeParser =+ withoutConfig $+ let h = help "example"+ in choice+ [ setting+ [ help "a",+ switch SumTypeA,+ short 'a'+ ],+ setting+ [ help "b",+ switch SumTypeB,+ short 'b'+ ],+ setting+ [ h,+ reader $ eitherReader parseSumType,+ env "sum-type",+ metavar "SUM_TYPE"+ ],+ setting+ [ h,+ conf "sum-type"+ ],+ setting+ [ h,+ valueWithShown renderSumType SumTypeA+ ]+ ]++secretParser :: Parser (Text, Text, Text, Text, Text)+secretParser =+ withoutConfig $+ (,,,,)+ <$> secretTextFileSetting+ [ help "First example secret",+ name "first-secret-file"+ ]+ <*> secretTextFileOrBareSetting+ [ help "Second example secret, bare or in a file",+ name "second-secret"+ ]+ <*> secretTextFileOrBareSetting+ [ help "Second example secret, bare or in a file, only option",+ option,+ long "second-secret"+ ]+ <*> secretTextFileOrBareSetting+ [ help "Second example secret, bare or in a file, only env",+ env "second-secret"+ ]+ <*> secretTextFileOrBareSetting+ [ help "Second example secret, bare or in a file, only conf",+ conf "second-secret"+ ]++data FirstOrSecond = First | Second+ deriving (Show)++instance HasParser FirstOrSecond where+ settingsParser =+ -- This version has no default value, so we can add one with 'withDefault'+ choice+ [ setting+ [ help "first",+ switch First,+ short 'f',+ long "first"+ ],+ setting+ [ help "second",+ switch Second,+ short 's',+ long "second"+ ]+ ]++withDefaultParser :: Parser FirstOrSecond+withDefaultParser = withDefault Second settingsParser+ data Greet = Greet !String !String !Bool greetParser :: Parser Greet@@ -120,6 +258,7 @@ env "GREETING", conf "greeting", value "Hello",+ example "Greetings", help "Greeting to use" ] <*> setting@@ -141,31 +280,60 @@ help "Whether to be polite" ] -data BigConfig = BigConfig (Map String (Map String Int))+data BigConfig = BigConfig+ { bigConfigMap :: Map String (Map String Int),+ bigConfigSubObject :: Maybe Text+ } +instance HasCodec BigConfig where+ codec =+ object "BigConfig" $+ BigConfig+ <$> requiredField' "map" .= bigConfigMap+ <*> optionalField' "sub" .= bigConfigSubObject+ bigConfigParser :: Parser BigConfig bigConfigParser = withLocalYamlConfig $- BigConfig- <$> setting- [ conf "big",- help "multi-line config codec explanation, the same option twice."- ]--data Args = Args [String]+ setting+ [ conf "big",+ help "big configuration object"+ ] -argsParser :: Parser Args-argsParser =- Args- <$> many- ( setting+subSettingsParser :: Parser String+subSettingsParser =+ withLocalYamlConfig $+ subAll "foo" $+ subAll "bar" $+ setting [ reader str,- argument,- help "Argument",- metavar "ARGUMENT"+ name "quux",+ help "Example with sub-settings",+ metavar "STR" ]- ) +manyArgsParser :: Parser [String]+manyArgsParser =+ many+ ( setting+ [ reader str,+ argument,+ help "Argument",+ metavar "ARGUMENT"+ ]+ )++someArgsParser :: Parser [String]+someArgsParser =+ some+ ( setting+ [ reader str,+ argument,+ help "Argument",+ metavar "ARGUMENT"+ ]+ )+ data Optional = Optional (Maybe String) optionalParser :: Parser Optional@@ -198,30 +366,56 @@ enableDisableParser :: Parser EnableDisable enableDisableParser =- withLocalYamlConfig $+ withoutConfig $ EnableDisable <$> enableDisableSwitch- True [ long "example", help "Example of an enable/disable switch", env "EXAMPLE",- conf "example"+ conf "example",+ value True ] +enableDisableParser' :: Parser (Maybe EnableDisable)+enableDisableParser' =+ withoutConfig $+ fmap EnableDisable+ <$> optional+ ( enableDisableSwitch+ [ long "example",+ help "Example of an enable/disable switch",+ env "EXAMPLE",+ conf "example"+ ]+ )+ data YesNo = YesNo Bool yesNoParser :: Parser YesNo yesNoParser =- withLocalYamlConfig $+ withoutConfig $ YesNo <$> yesNoSwitch- True [ long "example", help "Example of a yes/no switch", env "EXAMPLE",- conf "example"+ conf "example",+ value True ] +yesNoParser' :: Parser (Maybe YesNo)+yesNoParser' =+ withoutConfig $+ fmap YesNo+ <$> optional+ ( yesNoSwitch+ [ long "example",+ help "Example of a yes/no switch",+ env "EXAMPLE",+ conf "example"+ ]+ )+ data Empty = Empty emptyParser :: Parser Empty@@ -235,7 +429,7 @@ threeCommandsParser :: Parser ThreeCommands threeCommandsParser =- withLocalYamlConfig $+ withoutConfig $ commands [ command "one" "first" $ One@@ -253,14 +447,16 @@ option, metavar "INT", name "number",- short 'n'+ short 'n',+ shownExample 5 ] <*> enableDisableSwitch- False [ help "enable extra",- name "enable"+ name "enable",+ value False ],- command "three" "third" (pure Three)+ command "three-very-long-command-name" "third" (pure Three),+ defaultCommand "one" ] data SubCommands@@ -277,9 +473,11 @@ [ help "name", reader str, metavar "NAME",- name "name"+ name "name",+ example "john" ],- command "sub" "command with subcommands" $ Sub <$> sub1Parser <*> sub2Parser+ command "sub" "command with subcommands" $+ Sub <$> sub1Parser <*> sub2Parser ] data Sub1 = A | B@@ -297,7 +495,8 @@ sub2Parser = commands [ command "c" "C" $ pure C,- command "d" "D" $ pure D+ command "d" "D" $ pure D,+ defaultCommand "c" ] verboseParser :: Parser Int
test/OptEnvConf/ArgsSpec.hs view
@@ -43,12 +43,87 @@ describe "consumeArgument" $ do it "does not consume anything if there is nothing to consume" $- consumeArgument [] `shouldBe` []- it "consumes any argument if there is only one" $- forAllValid $ \a ->- consumeArgument [Live a]- `shouldBe` [(renderArg a, [])]+ consumeArgument [] `shouldBe` [(Nothing, emptyArgs)]+ it "consumes a plain argument when there is one" $+ forAllValid $ \s ->+ let as = [Live (ArgPlain s)]+ in consumeArgument as+ `shouldBe` [(Just s, Args [Dead] []), (Nothing, as)]+ it "consumes a bare double-dash if it's the last argument" $+ forAllValid $ \befores ->+ let as = Args befores [Live ArgBareDoubleDash]+ in consumeArgument as+ `shouldBe` [ (Just "--", Args (befores ++ [Dead]) []),+ (Nothing, as)+ ]+ it "consumes any argument after a double-dash as an argument" $+ forAllValid $ \befores ->+ forAllValid $ \bareArg ->+ forAllValid $ \rest ->+ let as = Args befores (Live ArgBareDoubleDash : Live bareArg : rest)+ in consumeArgument as+ `shouldBe` [ (Just (renderArg bareArg), Args befores (Live ArgBareDoubleDash : Dead : rest)),+ (Nothing, as)+ ]+ it "skips dead arguments" $+ forAllValid $ \befores ->+ forAllValid $ \afters ->+ consumeArgument (Args befores (Dead : afters)) `shouldBe` consumeArgument (Args (befores ++ [Dead]) afters) + it "tries to consume dashed argument followed by a dead argument" $+ forAllValid $ \befores ->+ forAllValid $ \isLong ->+ forAllValid $ \cs ->+ let d = ArgDashed isLong cs+ args = Args befores [Live d, Dead]+ in consumeArgument args+ `shouldBe` [ (Nothing, Args (befores ++ [Live d, Dead]) []),+ (Just (renderArg d), Args (befores ++ [Dead]) [Dead])+ ]++ it "tries to consume dashed argument followed by a live argument" $+ forAllValid $ \befores ->+ forAllValid $ \isLong ->+ forAllValid $ \cs ->+ forAll (genValid `suchThat` (/= ArgBareDoubleDash)) $ \arg ->+ let d = ArgDashed isLong cs+ args = Args befores [Live d, Live arg]+ in context (ppShow args) $+ consumeArgument args+ `shouldBe` [ (Nothing, Args (befores ++ [Live d, Live arg]) []),+ -- Consuming the value (dashed is a switch) is+ -- more likely than consuming the dashed as an+ -- argument+ (Just (renderArg arg), Args (befores ++ [Live d, Dead]) []),+ (Just (renderArg d), Args (befores ++ [Dead]) [Live arg])+ ]+ it "tries to ignore this value that looks like an option value" $+ consumeArgument ["-p1", "--port", "2"]+ `shouldBe` [ (Nothing, Args ["-p1", "--port", "2"] []),+ (Just "2", Args ["-p1", "--port", Dead] []),+ (Just "--port", Args ["-p1", Dead] ["2"]),+ (Just "-p1", Args [Dead] ["--port", "2"])+ ]++ describe "consumeSwitch" $ do+ it "fails to consume if there are no dasheds" $+ forAllValid $ \as ->+ consumeSwitch [] as `shouldBe` Nothing+ it "fails to consume if there are no arguments" $+ forAllValid $ \ds ->+ consumeSwitch ds [] `shouldBe` Nothing++ it "does not consume a mismatched switch" $+ consumeSwitch ["--foo"] ["--bar"] `shouldBe` Nothing+ it "consumes a short switch if there are no other args" $+ consumeSwitch ["-v"] ["-v"] `shouldBe` Just [Dead]+ it "consumes a long switch if there are no other args" $+ consumeSwitch ["--verbose"] ["--verbose"] `shouldBe` Just [Dead]+ it "consumes a switch at the front first" $+ consumeSwitch ["-a", "-b"] ["-a", "-b"] `shouldBe` Just [Dead, "-b"]+ it "consumes a folded switch at the front first" $+ consumeSwitch ["-a", "-b"] ["-ab"] `shouldBe` Just ["-b"]+ describe "consumeOption" $ do it "fails to consume if there are no dasheds" $ forAllValid $ \as ->@@ -70,22 +145,13 @@ consumeOption ["--file"] ["--file=foo.txt"] `shouldBe` Just ("foo.txt", [Dead]) it "consumes a short option in shorthand notation" $ consumeOption ["-f"] ["-ffoo.txt"] `shouldBe` Just ("foo.txt", [Dead])-- describe "consumeSwitch" $ do- it "fails to consume if there are no dasheds" $- forAllValid $ \as ->- consumeSwitch [] as `shouldBe` Nothing- it "fails to consume if there are no arguments" $- forAllValid $ \ds ->- consumeSwitch ds [] `shouldBe` Nothing-- it "does not consume a mismatched switch" $- consumeSwitch ["--foo"] ["--bar"] `shouldBe` Nothing- it "consumes a short switch if there are no other args" $- consumeSwitch ["-v"] ["-v"] `shouldBe` Just [Dead]- it "consumes a long switch if there are no other args" $- consumeSwitch ["--verbose"] ["--verbose"] `shouldBe` Just [Dead]- it "consumes a switch at the front first" $- consumeSwitch ["-a", "-b"] ["-a", "-b"] `shouldBe` Just [Dead, "-b"]- it "consumes a folded switch at the front first" $- consumeSwitch ["-a", "-b"] ["-ab"] `shouldBe` Just ["-b"]+ it "consumes a short option before a long option" $+ consumeOption+ ["-p", "--port"]+ ["-p1", "--port", "2"]+ `shouldBe` Just ("1", [Dead, "--port", "2"])+ it "consumes a short option before a long option" $+ consumeOption+ ["-p", "--port"]+ [Dead, "--port", "2"]+ `shouldBe` Just ("2", [Dead, Dead])
+ test/OptEnvConf/CompleterSpec.hs view
@@ -0,0 +1,79 @@+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE OverloadedStrings #-}++module OptEnvConf.CompleterSpec (spec) where++import GHC.Stack (HasCallStack, withFrozenCallStack)+import OptEnvConf.Completer+import Path+import Path.IO+import Test.Syd++spec :: Spec+spec = do+ let setupExampleDir tdir = do+ -- File+ exampleFile1 <- resolveFile tdir "foo.txt"+ writeFile (fromAbsFile exampleFile1) ""+ -- Dir here+ exampleDir <- resolveDir tdir "bar"+ createDir exampleDir+ -- File in dir+ exampleFile2 <- resolveFile exampleDir "quux.txt"+ writeFile (fromAbsFile exampleFile2) ""+ -- Dir in dir+ deeperDir <- resolveDir exampleDir "deep"+ createDir deeperDir+ -- File in dir in dir+ exampleFile3 <- resolveFile deeperDir "gold.txt"+ writeFile (fromAbsFile exampleFile3) ""+ -- Hidden file+ hiddenFile <- resolveFile tdir ".hidden.txt"+ writeFile (fromAbsFile hiddenFile) ""+ -- Hidden dir+ hiddenDir <- resolveDir tdir ".hidden"+ createDir hiddenDir++ -- These are read-only tests so we only need one dir for all of them+ sequential . doNotRandomiseExecutionOrder+ $ aroundAll+ ( \func -> withSystemTempDir "opt-env-conf-test" $ \tdir -> do+ setupExampleDir tdir+ func tdir+ )+ $ do+ describe "filePath" $ do+ let c :: (HasCallStack) => String -> [String] -> TestDef '[Path Abs Dir] ()+ c s l =+ withFrozenCallStack $+ itWithOuter (unwords ["can complete", show s, "to", show l]) $ \tdir ->+ withCurrentDir tdir $+ unCompleter filePath s `shouldReturn` l++ c "" ["foo.txt", "bar/"]+ c "f" ["foo.txt"]+ c "b" ["bar/"]+ c "bar" ["bar/quux.txt", "bar/", "bar/deep/"]+ c "q" []+ c "." [".hidden.txt", ".hidden/"]+ c "./" ["./foo.txt", "./bar/"]+ c "././" ["././foo.txt", "././bar/"]+ c "./." ["./.hidden.txt", "./.hidden/"]+ c "./bar" ["./bar/quux.txt", "./bar/", "./bar/deep/"]++ describe "directoryPath" $ do+ let c :: (HasCallStack) => String -> [String] -> TestDef '[Path Abs Dir] ()+ c s l = withFrozenCallStack $+ itWithOuter (unwords ["can complete", show s, "to", show l]) $ \tdir ->+ withCurrentDir tdir $+ unCompleter directoryPath s `shouldReturn` l++ c "" ["bar/"]+ c "b" ["bar/"]+ c "f" []+ c "." [".hidden/"]+ c "./" ["./bar/"]+ c "./." ["./.hidden/"]+ c "././" ["././bar/"]+ c "./." ["./.hidden/"]+ c "./bar" ["./bar/", "./bar/deep/"]
test/OptEnvConf/CompletionSpec.hs view
@@ -1,10 +1,14 @@+{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE QuasiQuotes #-} module OptEnvConf.CompletionSpec (spec) where +import Control.Applicative+import OptEnvConf.Completer import OptEnvConf.Completion import OptEnvConf.Parser import OptEnvConf.Setting+import OptEnvConf.Test import Path import Test.Syd @@ -24,14 +28,212 @@ fishCompletionScript [absfile|/usr/bin/example-executable|] "example-executable" describe "pureCompletionQuery" $ do+ it "can complete a switch from nothing" $+ parserCompletionTest+ (setting [switch (), short 'e', long "example"])+ 0+ []+ ["--example"] -- Only the long version it "can complete a short switch from a single dash" $- pureCompletionQuery (setting [short 'e']) 1 ["-"]- `shouldBe` [Completion "-e" Nothing]+ parserCompletionTest+ (setting [switch (), short 'e'])+ 0+ ["-"]+ ["-e"]+ it "can complete a long switch from a single dash" $- pureCompletionQuery (setting [long "example"]) 1 ["-"]- `shouldBe` [Completion "--example" Nothing]+ parserCompletionTest+ (setting [switch (), long "example"])+ 0+ ["-"]+ ["--example"]+ it "can complete a long switch from a double dash" $- pureCompletionQuery (setting [long "example"]) 1 ["--"]- `shouldBe` [Completion "--example" Nothing]+ parserCompletionTest+ (setting [switch (), long "example"])+ 0+ ["--"]+ ["--example"] - pending "can complete a long switch with an equals sign"+ it "can complete a short option's dashed" $+ parserCompletionTest+ (setting [option, short 'e', completer $ listCompleter ["hi"]])+ 0+ []+ ["-e"]++ it "can complete a long option's dashed" $+ parserCompletionTest+ (setting [option, long "example", completer $ listCompleter ["hi"]])+ 0+ []+ ["--example"]++ it "can complete a short option with a separate arg" $+ parserCompletionTest+ (setting [option, short 'e', completer $ listCompleter ["hi"]])+ 1+ ["-e"]+ ["hi"]++ -- Don't think we want to support this.+ -- pending "can complete a short option in short-hand mode.++ it "can complete a long option" $+ parserCompletionTest+ (setting [option, long "example", completer $ listCompleter ["hi"]])+ 1+ ["--example"]+ ["hi"]++ -- Don't think we want to support this+ -- pending "can complete a long option with equals sign"++ it "can complete both switches of a tuple" $+ parserCompletionTest+ ((,) <$> setting [switch (), long "foo"] <*> setting [switch (), long "bar"])+ 0+ []+ ["--foo", "--bar"]++ it "can complete both switches of a tuple, with a prefix" $+ parserCompletionTest+ ((,) <$> setting [switch (), long "bar"] <*> setting [switch (), long "baz"])+ 0+ ["--b"]+ ["--bar", "--baz"]++ it "can complete both switches of an either" $+ parserCompletionTest+ (setting [switch (), long "foo"] <|> setting [switch (), long "bar"])+ 0+ []+ ["--foo", "--bar"]++ it "can complete both switches of an either wrapped in optionals" $+ parserCompletionTest+ (optional (setting [switch (), long "foo"]) <|> optional (setting [switch (), long "bar"]))+ 0+ []+ ["--foo", "--bar"]++ describe "commands" $ do+ let p =+ commands+ [ command "foo" "1" $ pure (),+ command "bar" "2" $ pure (),+ command "baz" "3" $ pure ()+ ]++ it "can complete a command argument" $+ parserCompletionTest+ p+ 0+ []+ [Completion "foo" (Just "1"), Completion "bar" (Just "2"), Completion "baz" (Just "3")]++ it "can complete a command argument when it's been partially provided" $+ parserCompletionTest+ p+ 0+ ["b"]+ [Completion "bar" (Just "2"), Completion "baz" (Just "3")]++ describe "completion after a command" $ do+ it "can complete a command with a switch" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [help "ex", switch (), short 'e', long "example"]])+ 1+ ["foo"]+ [Completion "--example" (Just "ex")] -- Only the long version+ it "can complete a command's short switch" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [switch (), short 'e']])+ 1+ ["foo", "-"]+ ["-e"]++ it "can complete a command's long switch from a single dash" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [switch (), long "example"]])+ 1+ ["foo", "-"]+ ["--example"]++ it "can complete a command's long switch from a double dash" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [switch (), long "example"]])+ 1+ ["foo", "--"]+ ["--example"]++ it "can complete a command's short option" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [option, short 'e', completer $ listCompleter ["hi"]]])+ 2+ ["foo", "-e"]+ ["hi"]++ it "can complete a command's long option" $+ parserCompletionTest+ (commands [command "foo" "1" $ setting [option, long "example", completer $ listCompleter ["hi"]]])+ 2+ ["foo", "--example"]+ ["hi"]++ it "can complete a file argument" $+ parserCompletionDescriptionTest+ (filePathSetting [help "file arg", argument])+ 0+ []+ ["file arg"]++ it "can complete a file option" $+ parserCompletionDescriptionTest+ (filePathSetting [help "file arg", option, long "file"])+ 1+ ["--file"]+ ["file arg"]++ it "can complete a directory argument" $+ parserCompletionDescriptionTest+ (directoryPathSetting [help "dir arg", argument])+ 0+ []+ ["dir arg"]++ it "can complete a directory option" $+ parserCompletionDescriptionTest+ (directoryPathSetting [help "dir arg", option, long "file"])+ 1+ ["--file"]+ ["dir arg"]++ it "no longer suggests a switch that has already been parsed" $+ parserCompletionTest+ ((,) <$> setting [switch (), long "foo"] <*> setting [switch (), long "bar"])+ 1+ ["--foo"]+ ["--bar"]++ it "no longer suggests an option that has already been parsed" $+ parserCompletionTest+ ( (,,)+ <$> setting [option, reader (str :: Reader String), long "foo"]+ <*> setting [option, reader (str :: Reader String), long "bar"]+ <*> setting [switch (), long "quux"]+ )+ 2+ ["--foo", "foo"]+ ["--bar", "--quux"]++ it "no longer suggests an argument that has already been parsed" $+ parserCompletionDescriptionTest+ ( (,,)+ <$> setting [argument, reader (str :: Reader String), help "hi", completer $ listCompleter ["hi"]]+ <*> setting [argument, reader (str :: Reader String), help "ho", completer $ listCompleter ["ho"]]+ <*> setting [switch (), long "bar", help "hu"]+ )+ 1+ ["foo"]+ ["ho", "hu"]
test/OptEnvConf/ErrorSpec.hs view
@@ -159,16 +159,52 @@ ) ["--foo", "'a'"] + parseArgsErrorSpec+ "unrecognised-arg"+ (pure 'a')+ ["arg"]+ parseArgsErrorSpec+ "unrecognised-option"+ (pure 'b')+ ["--foo", "bar"]+ parseArgsErrorSpec+ "unrecognised-switch"+ (pure 'c')+ ["--foo"]++ parseArgsErrorSpec+ "typo-option"+ (optional $ setting [help "often misspelt as baz", reader str, option, long "bar"] :: Parser (Maybe String))+ ["--baz", "arg"]++ parseArgsErrorSpec+ "typo-switch"+ (optional $ setting [help "often misspelt as baz", switch True, long "bar"] :: Parser (Maybe Bool))+ ["--baz"]++ parseArgsErrorSpec+ "leftover-switch"+ (pure 'a')+ ["--switch"]+ parseArgsErrorSpec+ "leftover-option"+ (pure 'b')+ ["--key", "val"]+ parseArgsErrorSpec+ "leftover-argument"+ (pure 'c')+ ["foo", "bar"]+ parseArgsErrorSpec :: (HasCallStack) => (Show a) => FilePath -> Parser a -> [String] -> Spec parseArgsErrorSpec fp p args = withFrozenCallStack $ it (unwords ["renders the", fp, "error the same as before"]) $ let path = "test_resources/error/" <> fp <> ".txt" in goldenChunksFile path $ do- errOrResult <- runParserOn p (parseArgs args) EnvMap.empty Nothing+ errOrResult <- runParserOn 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 $ eraseErrorSrcLocs errs+ Left errs -> pure $ renderErrors errs parseEnvErrorSpec :: (HasCallStack) => (Show a) => FilePath -> Parser a -> [(String, String)] -> Spec parseEnvErrorSpec fp p e =@@ -176,10 +212,10 @@ it (unwords ["renders the", fp, "error the same as before"]) $ let path = "test_resources/error/" <> fp <> ".txt" in goldenChunksFile path $ do- errOrResult <- runParserOn p emptyArgs (EnvMap.parse e) Nothing+ errOrResult <- runParserOn 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 $ eraseErrorSrcLocs errs+ Left errs -> pure $ renderErrors errs goldenChunksFile :: FilePath -> IO [Chunk] -> GoldenTest Text goldenChunksFile fp cs =
+ test/OptEnvConf/HelpSpec.hs view
@@ -0,0 +1,167 @@+{-# LANGUAGE ApplicativeDo #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}+{-# LANGUAGE TypeApplications #-}++module OptEnvConf.HelpSpec (spec) where++import Control.Applicative+import Data.GenValidity.Aeson ()+import Data.Text (Text)+import qualified Data.Text as T+import Data.Version+import Data.Word+import OptEnvConf+import OptEnvConf.Args as Args+import OptEnvConf.Args.Gen ()+import OptEnvConf.EnvMap.Gen ()+import OptEnvConf.Error+import OptEnvConf.TestUtils+import Test.Syd+import Text.Colour++spec :: Spec+spec = do+ -- Help parsing works at the top level+ helpSpec+ "toplevel-pure"+ []+ -- Help parsing needs to work even if provided settings are invalid+ helpSpec+ "toplevel-pure-with-invalid-port"+ ["--port", "notaport"]+ helpSpec+ "read"+ ["read"]+ helpSpec+ "create"+ ["create"]+ helpSpec+ "sub"+ ["sub"]+ helpSpec+ "sub-foo"+ ["sub", "foo"]+ helpSpec+ "sub-bar"+ ["sub", "bar"]+ -- Help parsing needs to work if you type in the wrong command too.+ helpSpec+ "wrong-command"+ ["quux"]++data Instructions = Instructions !Settings !Dispatch++instance HasParser Instructions where+ settingsParser =+ withLocalYamlConfig $+ Instructions+ <$> settingsParser+ <*> settingsParser++data Dispatch+ = DispatchRead+ | DispatchCreate !String+ | DispatchWithSub !Sub++instance HasParser Dispatch where+ settingsParser =+ commands+ [ command "read" "read command explanation" $ pure DispatchRead,+ command "create" "create command explanation" $+ DispatchCreate+ <$> setting+ [ help "The item to create",+ reader str,+ argument,+ metavar "STR"+ ],+ command "sub" "command with subcommand" $ DispatchWithSub <$> settingsParser+ ]++data Sub+ = SubFoo+ | SubBar++instance HasParser Sub where+ settingsParser =+ commands+ [ command "foo" "foo explanation" $ pure SubFoo,+ command "bar" "bar explanation" $ pure SubBar+ ]++data Settings = Settings+ { settingPort :: Word16,+ settingLogLevel :: String,+ settingPaymentSettings :: Maybe PaymentSettings+ }++instance HasParser Settings where+ settingsParser = do+ settingPort <-+ setting+ [ help "port to serve requests on",+ reader auto,+ metavar "PORT",+ name "port",+ value 8080+ ]+ settingLogLevel <-+ setting+ [ help "minimal severity of log messages",+ reader str,+ metavar "LOG_LEVEL",+ name "log-level",+ value "DEBUG"+ ]+ settingPaymentSettings <- optional $ subSettings "payment"+ pure Settings {..}++data PaymentSettings = PaymentSettings+ { paymentSetPublicKey :: String,+ paymentSetSecretKey :: Text,+ paymentSetCurrency :: Maybe String+ }++instance HasParser PaymentSettings where+ settingsParser = do+ paymentSetPublicKey <-+ setting+ [ help "Public key",+ reader str,+ name "public-key",+ metavar "PUBLIC_KEY"+ ]+ paymentSetSecretKey <-+ secretTextFileSetting+ [ help "Secret key",+ name "secret-key",+ metavar "SECRET_KEY_FILE"+ ]+ paymentSetCurrency <-+ optional $+ setting+ [ help "Currency",+ reader str,+ name "currency",+ metavar "CURRENCY"+ ]+ pure PaymentSettings {..}++helpSpec :: String -> [String] -> Spec+helpSpec file args =+ it (unwords ["this help page in the same way for args:", show args]) $ do+ let version = makeVersion [0, 0, 0]+ let argMap = Args.parseArgs args+ let parser = settingsParser @Instructions+ errOrDocs <- runHelpParser Nothing argMap parser+ case errOrDocs of+ Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err+ Right mCommandDoc -> do+ let progname = "example"+ pure $+ pureGoldenChunksFile ("test_resources/help/" <> file <> ".txt") $+ case mCommandDoc of+ Nothing -> renderHelpPage progname version "example program description" (parserDocs parser)+ Just (commandPath, commandDoc) -> renderCommandHelpPage progname commandPath commandDoc
test/OptEnvConf/LintSpec.hs view
@@ -21,13 +21,6 @@ ] ) goldenLintTest- "only-default"- ( setting- [ help "Only a default value",- value ()- ]- )- goldenLintTest "dash-in-short" ( setting [ help "Dash in a 'short'",@@ -80,6 +73,17 @@ Parser String ) goldenLintTest+ "no-option-or-switch-for-dashed"+ ( setting+ [ reader str,+ argument,+ long "hi",+ metavar "STR",+ help "Example"+ ] ::+ Parser String+ )+ goldenLintTest "no-metavar-for-option" ( setting [ reader str,@@ -133,6 +137,55 @@ metavar "INT" ] :: Parser Int+ )+ goldenLintTest+ "many-env"+ ( many $+ setting+ [ help "many with setting that always succeeds",+ reader auto,+ env "EXAMPLE",+ metavar "INT"+ ] ::+ Parser [Int]+ )+ goldenLintTest+ "many-conf"+ ( withLocalYamlConfig $+ many $+ setting+ [ help "many with setting that always succeeds",+ conf "example"+ ] ::+ Parser [Int]+ )+ goldenLintTest+ "some-env"+ ( some $+ setting+ [ help "some with setting that always succeeds",+ reader auto,+ env "EXAMPLE",+ metavar "INT"+ ] ::+ Parser [Int]+ )+ goldenLintTest+ "some-conf"+ ( withLocalYamlConfig $+ some $+ setting+ [ help "some with setting that always succeeds",+ conf "example"+ ] ::+ Parser [Int]+ )+ goldenLintTest+ "unknown-default-command"+ ( commands+ [ command "a" "a" $ pure 'a',+ defaultCommand "b"+ ] ) goldenLintTest :: (HasCallStack) => FilePath -> Parser a -> Spec
test/OptEnvConf/ReaderSpec.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedLists #-} {-# LANGUAGE OverloadedStrings #-} module OptEnvConf.ReaderSpec (spec) where@@ -25,4 +27,30 @@ parseCommaSeparated (renderCommaSeparated l) `shouldBe` l describe "commaSeparated" $ do- pure ()+ it "can parse these two ints" $+ runReader (commaSeparated auto) "1,2"+ `shouldBe` Right [1, 2 :: Int]++ describe "commaSeparatedList" $ do+ it "can parse these two ints" $+ runReader (commaSeparatedList auto) "3, 4"+ `shouldBe` Right [3, 4 :: Int]++ describe "commaSeparatedSet" $ do+ it "can parse these two ints" $+ runReader (commaSeparatedSet auto) "5, 6"+ `shouldBe` Right [5, 6 :: Int]++ describe "maybeReader" $+ it "can parse a bool using this example reader" $ do+ let r = maybeReader $ \case+ "true" -> Just True+ "false" -> Just False+ _ -> Nothing+ runReader r "true" `shouldBe` Right True+ runReader r "false" `shouldBe` Right False+ runReader r "yes" `shouldBe` Left "Unparseable value: \"yes\""++ describe "viaStringCodec" $+ it "can parse a string via its string codec" $+ runReader viaStringCodec "hi" `shouldBe` Right ("hi" :: String)
test/OptEnvConf/RunSpec.hs view
@@ -1,7 +1,10 @@ {-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedLists #-}+{-# LANGUAGE OverloadedStrings #-} module OptEnvConf.RunSpec (spec) where +import Autodocodec import Control.Applicative import Data.Aeson as JSON (Object, Value (Null), toJSON) import qualified Data.Aeson.Key as Key@@ -11,6 +14,7 @@ import qualified Data.List.NonEmpty as NE import Data.Text (Text) import qualified Data.Text as T+import Data.Tuple (swap) import GHC.Stack (HasCallStack, withFrozenCallStack) import OptEnvConf import OptEnvConf.Args as Args@@ -28,49 +32,44 @@ describe "runParser" $ do describe "pure" $ do it "can parse a pure value from anything" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \expected ->- shouldParse (pure expected) args e mConf (expected :: Int)+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \expected ->+ shouldParse (pure expected) Args.emptyArgs e mConf (expected :: Int) describe "fmap" $ do it "can parse a mapped value from anything" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let expected = succ i- shouldParse (fmap succ $ pure i) args e mConf (expected :: Int)+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let expected = succ i+ shouldParse (fmap succ $ pure i) Args.emptyArgs e mConf (expected :: Int) describe "<*>" $ do it "can parse two values with ap" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = (,) <$> pure (succ i) <*> pure i- let expected = (succ i, i :: Int)- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = (,) <$> pure (succ i) <*> pure i+ let expected = (succ i, i :: Int)+ shouldParse p Args.emptyArgs e mConf expected describe "Select" $ do it "can use the second parser with select" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = select (pure (Left i :: Either Int Int)) (pure succ)- let expected = succ i- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = select (pure (Left i :: Either Int Int)) (pure succ)+ let expected = succ i+ shouldParse p Args.emptyArgs e mConf expected it "can avoid the second parser with select" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = select (pure (Right i :: Either Int Int)) (pure succ)- let expected = i- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = select (pure (Right i :: Either Int Int)) (pure succ)+ let expected = i+ shouldParse p Args.emptyArgs e mConf expected describe "Empty" $ do it "can fail to parse an empty value" $@@ -84,29 +83,27 @@ describe "Alt" $ do it "can parse a Left value with Alt" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = (Left <$> pure i) <|> (Right <$> pure (succ i))- let expected = Left (i :: Int)- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = (Left <$> pure i) <|> (Right <$> pure (succ i))+ let expected = Left (i :: Int)+ shouldParse p Args.emptyArgs e mConf expected it "can parse a Right value with Alt" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = empty `ParserAlt` (Right <$> pure i)- let expected = Right (i :: Int) :: Either Int Int- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = empty `ParserAlt` (Right <$> pure i)+ let expected = Right (i :: Int) :: Either Int Int+ shouldParse p Args.emptyArgs e mConf expected describe "Many" $ do it "can pass many args" $ forAllValid $ \e -> forAllValid $ \mConf -> forAllValid $ \ls -> do- let args = emptyArgs {unArgs = map (Live . ArgPlain) ls}+ let args = parseArgs ls let p = many $ setting [reader str, argument] let expected = ls shouldParse p args e mConf expected@@ -115,7 +112,7 @@ it "fails to parse zero args" $ forAllValid $ \e -> forAllValid $ \mConf -> do- let args = emptyArgs {unArgs = []}+ let args = emptyArgs let p = some $ setting [reader str, argument] :: Parser [String] shouldFail p args e mConf $ \case ParseErrorMissingArgument _ :| [] -> True@@ -125,105 +122,113 @@ forAllValid $ \e -> forAllValid $ \mConf -> forAllValid $ \ls -> do- let args = emptyArgs {unArgs = map (Live . ArgPlain) (NE.toList ls)}+ let args = parseArgs (NE.toList ls) let p = some $ setting [reader str, argument] let expected = NE.toList ls shouldParse p args e mConf expected describe "MapIO" $ do it "can run an IO action on the result of a parser" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \i -> do- let p = mapIO (pure . succ) (pure (i :: Int))- let expected = succ i- shouldParse p args e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \i -> do+ let p = mapIO (pure . succ) (pure (i :: Int))+ let expected = succ i+ shouldParse p Args.emptyArgs e mConf expected describe "WithConfig" $ do it "can replace the config object" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \c1 ->- forAllValid $ \c2' ->- forAllValid $ \(key, val) -> do- let c2 = KeyMap.insert key (toJSON val) c2'- let p =- withConfig (pure (Just c2)) $- setting [conf (Key.toString key)]- let expected = val :: Text- shouldParse p args e (Just c1) expected+ forAllValid $ \e ->+ forAllValid $ \c1 ->+ forAllValid $ \c2' ->+ forAllValid $ \(key, val) -> do+ let c2 = KeyMap.insert key (toJSON val) c2'+ let p =+ withConfig (pure (Just c2)) $+ setting [conf (Key.toString key)]+ let expected = val :: Text+ shouldParse p Args.emptyArgs e (Just c1) expected + describe "withFirstYamlConfig" $ do+ it "can parse without any arguments" $+ forAllValid $ \e ->+ forAllValid $ \val -> do+ let p = withFirstYamlConfig (pure []) (pure val) :: Parser String+ shouldParse p Args.emptyArgs e Nothing val++ describe "withCombinedYamlConfig" $ do+ it "can parse without any arguments" $ do+ forAllValid $ \e ->+ forAllValid $ \val -> do+ let p = withCombinedYamlConfigs (pure []) (pure val) :: Parser String+ shouldParse p Args.emptyArgs e Nothing val+ describe "subArgs" $ do it "can prefix a switch parser" $- forAllValid $ \a' ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \prefix ->- forAllValid $ \(key, val) -> do- let prefixedKey = Args.prefixDashed prefix (DashedLong key)- let a = a' {unArgs = Live (Args.renderDashedArg prefixedKey) : unArgs a'}- let p =- subArgs prefix $- setting- [ reader str,- switch val,- long (NE.toList key)- ]- let expected = val :: String- shouldParse p a e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \prefix ->+ forAllValid $ \(key, val) -> do+ let prefixedKey = Args.prefixDashed prefix (DashedLong key)+ let a = Args.parseArgs [Args.renderDashed prefixedKey]+ let p =+ subArgs prefix $+ setting+ [ reader str,+ switch val,+ long (NE.toList key)+ ]+ let expected = val :: String+ shouldParse p a e mConf expected it "can prefix an option parser" $- forAllValid $ \a' ->- forAllValid $ \e ->- forAllValid $ \mConf ->- forAllValid $ \prefix ->- forAllValid $ \(key, val) -> do- let prefixedKey = Args.prefixDashed prefix (DashedLong key)- let a = a' {unArgs = Live (Args.renderDashedArg prefixedKey) : Live (ArgPlain val) : unArgs a'}- let p =- subArgs prefix $- setting- [ reader str,- option,- long (NE.toList key)- ]- let expected = val- shouldParse p a e mConf expected+ forAllValid $ \e ->+ forAllValid $ \mConf ->+ forAllValid $ \prefix ->+ forAllValid $ \(key, val) -> do+ let prefixedKey = Args.prefixDashed prefix (DashedLong key)+ let a = parseArgs [renderDashed prefixedKey, val]+ let p =+ subArgs prefix $+ setting+ [ reader str,+ option,+ long (NE.toList key)+ ]+ let expected = val+ shouldParse p a e mConf expected describe "subEnv" $ do it "can prefix an env var parser" $- forAllValid $ \args ->- forAllValid $ \e' ->- forAllValid $ \mConf ->- forAllValid $ \prefix ->- forAllValid $ \(key, val) -> do- let prefixedKey = prefix <> key- let e = EnvMap.insert prefixedKey val e'- let p = subEnv prefix $ setting [reader str, env key]- let expected = val- shouldParse p args e mConf expected+ forAllValid $ \e' ->+ forAllValid $ \mConf ->+ forAllValid $ \prefix ->+ forAllValid $ \(key, val) -> do+ let prefixedKey = prefix <> key+ let e = EnvMap.insert prefixedKey val e'+ let p = subEnv prefix $ setting [reader str, env key]+ let expected = val+ shouldParse p Args.emptyArgs e mConf expected describe "subConfig" $ do it "can prefix a conf val parser" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \c' ->- forAllValid $ \prefix ->- forAllValid $ \(key, val) -> do- let c = KeyMap.insert prefix (toJSON (KeyMap.singleton key (toJSON val))) c'- let p =- subConfig (Key.toString prefix) $- setting [conf (Key.toString key)]- let expected = val :: Text- shouldParse p args e (Just c) expected+ forAllValid $ \e ->+ forAllValid $ \c' ->+ forAllValid $ \prefix ->+ forAllValid $ \(key, val) -> do+ let c = KeyMap.insert prefix (toJSON (KeyMap.singleton key (toJSON val))) c'+ let p =+ subConfig (Key.toString prefix) $+ setting [conf (Key.toString key)]+ let expected = val :: Text+ shouldParse p Args.emptyArgs e (Just c) expected describe "Setting" $ do it "can parse a single arg" $ forAllValid $ \e -> forAllValid $ \mConf -> forAllValid $ \arg -> do- let args = emptyArgs {unArgs = [Live (ArgPlain arg)]}+ let args = Args.parseArgs [arg] let p = setting [reader str, argument] let expected = arg shouldParse p args e mConf expected@@ -233,12 +238,10 @@ forAllValid $ \mConf -> forAllValid $ \(l, r) -> do let args =- emptyArgs- { unArgs =- [ Live (Args.renderDashedArg (DashedLong l)),- Live (ArgPlain r)- ]- }+ parseArgs+ [ Args.renderDashed (DashedLong l),+ r+ ] let p = setting [reader str, option, long $ NE.toList l] let expected = r shouldParse p args e mConf expected@@ -247,79 +250,72 @@ forAllValid $ \e -> forAllValid $ \mConf -> forAllValid $ \(l, rs) -> do- let args =- emptyArgs- { unArgs =- concatMap- ( \v ->- [ Live (Args.renderDashedArg (DashedLong l)),- Live (ArgPlain v)- ]- )- rs- }+ let args = parseArgs $ concatMap (\v -> [Args.renderDashed (DashedLong l), v]) rs let p = many $ setting [reader str, option, long $ NE.toList l] let expected = rs :: [String] shouldParse p args e mConf expected it "can parse a single env var" $- forAllValid $ \args ->- forAllValid $ \e' ->- forAllValid $ \mConf ->- forAllValid $ \(key, val) -> do- let e = EnvMap.insert key val e'- let p = setting [reader str, env key]- let expected = val- shouldParse p args e mConf expected+ forAllValid $ \e' ->+ forAllValid $ \mConf ->+ forAllValid $ \(key, val) -> do+ let e = EnvMap.insert key val e'+ let p = setting [reader str, env key]+ let expected = val+ shouldParse p Args.emptyArgs e mConf expected it "can parse a single config value" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \c' ->- forAllValid $ \(key, val) -> do- let c = KeyMap.insert key (toJSON val) c'- let p = setting [conf (Key.toString key)]- let expected = val :: Text- shouldParse p args e (Just c) expected+ forAllValid $ \e ->+ forAllValid $ \c' ->+ forAllValid $ \(key, val) -> do+ let c = KeyMap.insert key (toJSON val) c'+ let p = setting [conf (Key.toString key)]+ let expected = val :: Text+ shouldParse p Args.emptyArgs e (Just c) expected it "parses Null as the default value" $- forAllValid $ \args ->- forAllValid $ \e ->- forAllValid $ \c' ->- forAllValid $ \key -> do- let c = KeyMap.insert key JSON.Null c'- let defaultVal = "hi"- let p = setting [conf (Key.toString key), value defaultVal]- let expected = defaultVal- shouldParse p args e (Just c) expected+ forAllValid $ \e ->+ forAllValid $ \c' ->+ forAllValid $ \key -> do+ let c = KeyMap.insert key JSON.Null c'+ let defaultVal = "hi" :: String+ let p = setting [conf (Key.toString key), value defaultVal]+ let expected = defaultVal+ shouldParse p Args.emptyArgs e (Just c) expected describe "Unit tests" $ do argParseSpec ["--foo", "bar"] (setting [reader str, option, long "foo"])- "bar"+ ("bar" :: String) argParseSpec ["--foo", "bar"] (many $ setting [reader str, option, long "foo"])- ["bar"]+ (["bar"] :: [String]) argParseSpec ["--foo", "bar", "--foo", "quux"] (many $ setting [reader str, option, long "foo"])- ["bar", "quux"]+ (["bar", "quux"] :: [String]) argParseSpec ["--foo", "bar", "-f", "quux"] (many $ setting [reader str, option, short 'f', long "foo"])- ["bar", "quux"]+ (["bar", "quux"] :: [String]) argParseSpec ["-f", "bar", "--foo", "quux"] (many $ setting [reader str, option, short 'f', long "foo"])- ["bar", "quux"]+ (["bar", "quux"] :: [String]) + argParseSpec+ ["--", "all", "-bare", "--arguments"]+ (many $ setting [reader str, argument])+ -- No double-dash!+ (["all", "-bare", "--arguments"] :: [String])+ -- Switch before argument argParseSpec ["--foo", "bar"] ((,) <$> setting [switch True, long "foo"] <*> setting [reader str, argument])- (True, "bar")+ (True, "bar" :: String) -- Note that this could also be parsed as (False, "--foo") with a -- leftover argument but somehow that's not what we want.@@ -328,13 +324,13 @@ argParseSpec ["--foo", "bar"] ((,) <$> setting [switch True, long "foo", value False] <*> setting [reader str, argument])- (True, "bar")+ (True, "bar" :: String) -- Switch before argument, but defined after argParseSpec ["--foo", "bar"] ((,) <$> setting [reader str, argument] <*> setting [switch True, long "foo"])- ("bar", True)+ ("bar" :: String, True) -- Dashed as argument -- This example shows that we can't just skip dasheds when looking for@@ -342,7 +338,7 @@ argParseSpec ["--foo", "bar"] ((,) <$> setting [reader str, argument] <*> setting [reader str, argument])- ("--foo", "bar")+ ("--foo" :: String, "bar" :: String) -- Dashed as value for an option -- This example shows that we can't "just" treat any argument with dashed@@ -351,7 +347,7 @@ argParseSpec ["--foo", "--bar"] (setting [reader str, option, long "foo"])- "--bar"+ ("--bar" :: String) -- Short dashed as a value for an option -- This example shows that we can't "just" unfold combined short options.@@ -359,8 +355,28 @@ argParseSpec ["--foo", "-dfu"] (setting [reader str, option, long "foo"])- "-dfu"+ ("-dfu" :: String) + -- Arguments can be parsed as-is+ argParseSpec+ ["delete"]+ ( commands+ [ command "add" "add" (pure "hi"),+ command "delete" "delete" (pure "ho")+ ]+ )+ ("ho" :: String)++ -- A command can have an argument+ argParseSpec+ ["add", "hi"]+ ( commands+ [ command "add" "add" $ setting [argument, reader str],+ command "other" "other" (pure "ho")+ ]+ )+ ("hi" :: String)+ -- Here an argument has a value that looks like a command name but -- should still be treated as an argument. argParseSpec@@ -372,7 +388,7 @@ command "arg" "command" (pure '2') ] )- ("command", '2')+ ("command" :: String, '2') -- Same as above but with an option instead of an argument argParseSpec@@ -384,8 +400,30 @@ command "arg" "command" (pure '2') ] )- ("command", '2')+ ("command" :: String, '2') + -- Commands can have a default+ argParseSpec+ []+ ( commands+ [ command "a" "a" (pure "a"),+ command "b" "b" (pure "b"),+ defaultCommand "b"+ ]+ )+ ("b" :: String)++ -- Commands can have a default with an argument+ argParseSpec+ ["c"]+ ( commands+ [ command "a" "a" (pure "a"),+ command "b" "b" $ setting [argument, reader str],+ defaultCommand "b"+ ]+ )+ ("c" :: String)+ -- Unfolding switches argParseSpecs ( length@@ -427,7 +465,7 @@ example ("file" :: String) ] )- [ (["-f", "foo"], (0, "foo")),+ [ (["-f", "foo"], (0, "foo" :: String)), (["-v", "-f", "foo"], (1, "foo")), (["-vf", "foo", "-v"], (2, "foo")), (["-vvf", "foo"], (2, "foo")),@@ -456,7 +494,7 @@ ) ) [ ([], ([], 0)),- (["--file", "foo", "-v"], (["foo"], 1)),+ (["--file", "foo", "-v"], (["foo" :: String], 1)), (["-vf", "foo"], (["foo"], 1)) ] -- Equals version of long option@@ -467,7 +505,7 @@ long "file" ] )- [ (["--file", "foo"], "foo"),+ [ (["--file", "foo"], "foo" :: String), (["--file=foo"], "foo") ] @@ -479,26 +517,128 @@ short 'f' ] )- [ (["-f", "foo"], "foo"),+ [ (["-f", "foo"], "foo" :: String), (["-ffoo"], "foo") ] + -- Optional Argument and optional switch+ let optionalArgOptionalSwitchExamples =+ [ (["foo", "-w"], (Just "foo", True)),+ (["-w", "foo"], (Just "foo", True)),+ (["foo", "--watch"], (Just "foo", True)),+ (["--watch", "foo"], (Just "foo", True)),+ (["foo"], (Just "foo", False)),+ (["--bar"], (Just "--bar", False)),+ (["-w"], (Nothing, True)),+ (["--watch"], (Nothing, True))+ ] argParseSpecs- (enableDisableSwitch True [long "example", env "EXAMPLE", conf "example"])+ ( (,)+ <$> optional (setting [reader str, argument])+ <*> setting [switch True, short 'w', long "watch", value False] ::+ Parser (Maybe String, Bool)+ )+ optionalArgOptionalSwitchExamples+ argParseSpecs+ ( swap+ <$> ( (,)+ <$> setting [switch True, short 'w', long "watch", value False]+ <*> optional (setting [reader str, argument])+ ) ::+ Parser (Maybe String, Bool)+ )+ optionalArgOptionalSwitchExamples++ let verbosityArgsExamples =+ [ ([], ([], 0)),+ (["-vvv"], ([], 3)),+ (["--"], (["--"], 0)),+ (["-v", "--"], (["--"], 1)),+ (["-vv", "--"], (["--"], 2)),+ (["--", "-v"], (["-v"], 0)),+ (["a", "-v", "b", "-v"], (["a", "b"], 2)),+ (["a", "--verbose", "-v", "b", "-v"], (["a", "b"], 3)),+ (["a", "--verbose", "-v", "-v", "b", "-v"], (["a", "b"], 4)),+ (["a", "--verbose", "-v", "-v", "b", "-v", "c"], (["a", "b", "c"], 4)),+ (["a", "--verbose", "-v", "-vv", "b", "-v", "c"], (["a", "b", "c"], 5)),+ (["a", "--verbose", "-v", "-vv", "-v", "b", "-v", "c"], (["a", "b", "c"], 6))+ ]+ argParseSpecs+ ( (,)+ <$> many (setting [reader str, argument])+ <*> (length <$> many (setting [switch (), short 'v', long "verbose"])) ::+ Parser ([String], Int)+ )+ verbosityArgsExamples+ argParseSpecs+ ( swap+ <$> ( (,)+ <$> (length <$> many (setting [switch (), short 'v', long "verbose"]))+ <*> many (setting [reader str, argument])+ ) ::+ Parser ([String], Int)+ )+ verbosityArgsExamples++ let optionsArgsExamples =+ [ ([], ([], [])),+ (["-p1"], ([], [1])),+ (["-p1", "--port", "2"], ([], [1, 2])),+ (["-p", "1", "-p", "2", "-p", "3"], ([], [1, 2, 3])),+ (["--port=2"], ([], [2])),+ (["--port=2", "-p3"], ([], [2, 3])),+ (["--port", "3"], ([], [3])),+ (["foo", "-p4"], (["foo"], [4])),+ (["bar", "--port=5"], (["bar"], [5])),+ (["quux", "--port", "6"], (["quux"], [6])),+ (["-p7", "foo"], (["foo"], [7])),+ (["--port=8", "bar"], (["bar"], [8])),+ (["--port", "9", "quux"], (["quux"], [9])),+ (["--", "-p1"], (["-p1"], [])),+ (["--", "-p", "2"], (["-p", "2"], [])),+ (["--", "--port=3"], (["--port=3"], [])),+ (["--", "--port", "4"], (["--port", "4"], []))+ ]+ argParseSpecs+ ( (,)+ <$> many (setting [reader str, argument])+ <*> many (setting [reader auto, option, short 'p', long "port"]) ::+ Parser ([String], [Int])+ )+ optionsArgsExamples+ argParseSpecs+ ( swap+ <$> ( (,)+ <$> many (setting [reader auto, option, short 'p', long "port"])+ <*> many (setting [reader str, argument])+ ) ::+ Parser ([String], [Int])+ )+ optionsArgsExamples++ argParseSpecs+ (enableDisableSwitch [long "example", env "EXAMPLE", conf "example", value True]) [ ([], True), (["--enable-example"], True), (["--disable-example"], False) ] argParseSpecs- (enableDisableSwitch False [long "example", env "EXAMPLE", conf "example"])+ (enableDisableSwitch [long "example", env "EXAMPLE", conf "example", value False]) [ ([], False), (["--enable-example"], True), (["--disable-example"], False) ] + argParseSpecs+ (optional $ enableDisableSwitch [long "example", env "EXAMPLE", conf "example"])+ [ ([], Nothing),+ (["--enable-example"], Just True),+ (["--disable-example"], Just False)+ ]+ envParseSpecs- (enableDisableSwitch True [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example"])+ (enableDisableSwitch [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example", value True]) [ ([], True), ([("EXAMPLE", "False")], False), ([("ALTERNATIVE", "False")], False),@@ -507,7 +647,7 @@ ] envParseSpecs- (enableDisableSwitch False [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example"])+ (enableDisableSwitch [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example", value False]) [ ([], False), ([("EXAMPLE", "True")], True), ([("ALTERNATIVE", "True")], True),@@ -516,6 +656,45 @@ ] argParseSpecs+ (yesNoSwitch [long "example", env "EXAMPLE", conf "example", value True])+ [ ([], True),+ (["--example"], True),+ (["--no-example"], False)+ ]++ argParseSpecs+ (yesNoSwitch [long "example", env "EXAMPLE", conf "example", value False])+ [ ([], False),+ (["--example"], True),+ (["--no-example"], False)+ ]++ argParseSpecs+ (optional $ yesNoSwitch [long "example", env "EXAMPLE", conf "example"])+ [ ([], Nothing),+ (["--example"], Just True),+ (["--no-example"], Just False)+ ]++ envParseSpecs+ (yesNoSwitch [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example", value True])+ [ ([], True),+ ([("EXAMPLE", "False")], False),+ ([("ALTERNATIVE", "False")], False),+ ([("EXAMPLE", "True")], True),+ ([("ALTERNATIVE", "True")], True)+ ]++ envParseSpecs+ (yesNoSwitch [long "example", env "EXAMPLE", env "ALTERNATIVE", conf "example", value False])+ [ ([], False),+ ([("EXAMPLE", "True")], True),+ ([("ALTERNATIVE", "True")], True),+ ([("EXAMPLE", "False")], False),+ ([("ALTERNATIVE", "False")], False)+ ]++ argParseSpecs ( commands [ command "one" "first" $ pure '1', command "two" "second" $ pure '2'@@ -528,12 +707,12 @@ argParseSpecs ((Left <$> setting [switch True, long "bash-completion-script"]) <|> (Right <$> setting [reader str, argument])) [ (["--bash-completion-script"], Left True),- (["arg"], Right "arg")+ (["arg"], Right ("arg" :: String)) ] argParseSpecs ((Left <$> setting [switch True, long "bash-completion-script"]) <|> (Right <$> optional (setting [reader str, argument]))) [ (["--bash-completion-script"], Left True),- (["arg"], Right (Just "arg"))+ (["arg"], Right (Just ("arg" :: String))) ] argParseSpecs@@ -549,6 +728,7 @@ [ ([], Nothing), (["--foo", "foo"], Just ("foo", Nothing)) ]+ -- Default values should not count as parsed: argParseSpecs ( choice@@ -577,30 +757,153 @@ [ (["--before", "'m'"], ('m', Nothing)) ] + -- source location does not matter+ argParseSpecs+ ( optional+ ( let foo = setting [reader str, option, long "foo"]+ in (,)+ <$> foo+ <*> optional+ ( subAll+ "bar"+ ( allOrNothing+ ( (,)+ <$> foo+ <*> setting [reader str, option, long "bar"]+ )+ )+ )+ ) ::+ Parser (Maybe (String, Maybe (String, String)))+ )+ [ ([], Nothing),+ (["--foo", "foo"], Just ("foo", Nothing))+ ]++ -- Failing after consuming args leaves the args unconsumed+ argParseSpecs+ ( choice+ [ (++)+ <$> many (setting [reader str, argument])+ <*> setting [switch ["ho"], long "--switch"],+ many $ setting [reader str, argument]+ ]+ )+ [ (["args", "here"], ["args", "here" :: String])+ ]++ -- Unrecognised args should be forgivable+ argParseSpecs+ ( let fallback = setting [reader str, option, long "foo"]+ withCommand = commands [command "run" "command in front" fallback]+ in withCommand <|> fallback+ )+ [ (["run", "--foo", "bar"], "bar" :: String),+ (["--foo", "bar"], "bar" :: String)+ ]++ -- Alt-ing commands concats the commands+ argParseSpecs+ ( let fallback = setting [reader str, option, long "foo"]+ withCommand1 = commands [command "run1" "command in front" fallback]+ withCommand2 = commands [command "run2" "command in front" fallback]+ in withCommand1 <|> withCommand2 <|> fallback+ )+ [ (["run1", "--foo", "bar"], "bar" :: String),+ (["run2", "--foo", "bar"], "bar" :: String),+ (["--foo", "bar"], "bar" :: String)+ ]++ -- Alt-ing commands concats the commands, even recursively+ argParseSpecs+ ( let fallback = setting [reader str, option, long "foo"]+ withCommand1 = commands [command "run1" "command in front" fallback]+ withCommand2 = commands [command "run2" "command in front" fallback]+ in withCommand1 <|> (withCommand2 <|> fallback)+ )+ [ (["run1", "--foo", "bar"], "bar" :: String),+ (["run2", "--foo", "bar"], "bar" :: String),+ (["--foo", "bar"], "bar" :: String)+ ]++ -- Required config value+ confParseSpecs+ (setting [conf "hi"] :: Parser String)+ [ (Just [("hi", "ho")], "ho")+ ]++ -- Optional config value+ confParseSpecs+ (optional $ setting [conf "hi"] :: Parser (Maybe String))+ [ (Nothing, Nothing),+ (Just [("hi", "ho")], Just "ho")+ ]++ -- Multiple possible codecs+ confParseSpecs+ ( setting+ [ confWith "hi" (Left <$> codec),+ confWith "foo" (Right <$> codec)+ ]+ )+ [ (Just [("hi", toJSON (5 :: Int))], Left 5),+ (Just [("foo", "bar")], Right "bar" :: Either Int String)+ ]++ argParseSpecs+ ( withDefault+ False+ ( setting+ [ argument,+ reader auto+ ]+ )+ )+ [ (["True"], True),+ ([], False)+ ]+ argParseSpecs :: (HasCallStack) => (Show a, Eq a) => Parser a -> [([String], a)] -> Spec argParseSpecs p table = withFrozenCallStack $ mapM_ (\(args, result) -> argParseSpec args p result) table argParseSpec :: (HasCallStack) => (Show a, Eq a) => [String] -> Parser a -> a -> Spec argParseSpec args p expected = withFrozenCallStack $ do- it (unwords ["parses", show args, "as", show expected]) $ do+ it (unwords ["parses args", show args, "as", show expected]) $ do let argMap = parseArgs args- errOrRes <- runParserOn p argMap EnvMap.empty Nothing- case errOrRes of- Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err- Right actual -> actual `shouldBe` expected+ errOrRes <- runParserOn Nothing p argMap EnvMap.empty Nothing+ context (showParserABit p) $+ case errOrRes of+ Left errs ->+ expectationFailure $+ unlines+ [ T.unpack $ renderChunksText With24BitColours $ renderErrors errs,+ ppShow errs+ ]+ Right actual -> actual `shouldBe` expected envParseSpecs :: (HasCallStack) => (Show a, Eq a) => Parser a -> [([(String, String)], a)] -> Spec envParseSpecs p table = withFrozenCallStack $ mapM_ (\(envs, result) -> envParseSpec envs p result) table envParseSpec :: (HasCallStack) => (Show a, Eq a) => [(String, String)] -> Parser a -> a -> Spec envParseSpec envVars p expected = withFrozenCallStack $ do- it (unwords ["parses", show envVars, "as", show expected]) $ do+ it (unwords ["parses environment", show envVars, "as", show expected]) $ do let envMap = EnvMap.parse envVars- errOrRes <- runParserOn p emptyArgs envMap Nothing+ errOrRes <- runParserOn Nothing p emptyArgs envMap Nothing case errOrRes of Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err Right actual -> actual `shouldBe` expected +confParseSpecs :: (HasCallStack) => (Show a, Eq a) => Parser a -> [(Maybe JSON.Object, a)] -> Spec+confParseSpecs p table = withFrozenCallStack $ mapM_ (\(mConf, result) -> confParseSpec mConf p result) table++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+ case errOrRes of+ Left err -> expectationFailure $ T.unpack $ renderChunksText With24BitColours $ renderErrors err+ Right actual -> actual `shouldBe` expected+ shouldParse :: (Show a, Eq a) => Parser a ->@@ -610,7 +913,7 @@ a -> IO () shouldParse p args e mConf expected = do- errOrRes <- runParserOn p args e mConf+ errOrRes <- runParserOn 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@@ -624,7 +927,7 @@ (NonEmpty ParseErrorMessage -> Bool) -> IO () shouldFail p args e mConf isExpected = do- errOrRes <- runParserOn p args e mConf+ errOrRes <- runParserOn Nothing p args e mConf case errOrRes of Left errs -> NE.map parseErrorMessage errs `shouldSatisfy` isExpected Right actual -> expectationFailure $ show actual
+ test/OptEnvConf/TestUtils.hs view
@@ -0,0 +1,9 @@+module OptEnvConf.TestUtils (pureGoldenChunksFile) where++import Data.Text (Text)+import Test.Syd+import Text.Colour++pureGoldenChunksFile :: FilePath -> [Chunk] -> GoldenTest Text+pureGoldenChunksFile fp cs =+ pureGoldenTextFile fp $ renderChunksText With24BitColours cs
+ test/OptEnvConf/ToplevelSpec.hs view
@@ -0,0 +1,58 @@+module OptEnvConf.ToplevelSpec where++import Data.Version+import OptEnvConf+import System.Environment+import System.Exit+import Test.Syd++spec :: Spec+spec = do+ let dummyVersion = makeVersion [0, 0, 0]+ let dummyProgDesc = "dummy"+ let dummyParser = pure 'a'+ let dummyRun = runParser dummyVersion dummyProgDesc dummyParser+ sequential $ do+ it "can fail fast when too many unrecognsied arguments are given" $+ withArgs ["-option1", "option", "--option2", "option", "--option3", "option", "--option4", "option"] $+ dummyRun `shouldThrow` (== ExitFailure 1)++ describe "--help" $ do+ it "can show help text with --help" $+ withArgs ["--help"] $+ dummyRun `shouldThrow` (== ExitSuccess)+ it "can show help text with --help even when there are more args" $+ withArgs ["--help", "more", "args", "here"] $+ dummyRun `shouldThrow` (== ExitSuccess)+ it "can show help text with -h" $+ withArgs ["-h"] $+ dummyRun `shouldThrow` (== ExitSuccess)+ it "can show help text with --help even when there are more args" $+ withArgs ["-h", "more", "args", "here"] $+ dummyRun `shouldThrow` (== ExitSuccess)++ describe "--version" $ do+ it "can show version info with --version" $+ withArgs ["--version"] $+ dummyRun `shouldThrow` (== ExitSuccess)++ describe "--run-settings-check" $ do+ it "can run a settings check with --run-settings-check" $+ withArgs ["--run-settings-check"] $+ dummyRun `shouldThrow` (== ExitSuccess)+ it "can run a settings check with --run-settings-check even when there are more args" $+ withArgs ["--run-settings-check", "more", "args", "here"] $+ runParser+ dummyVersion+ dummyProgDesc+ ( many+ ( setting+ [ help "something that reads args",+ argument,+ reader str,+ metavar "STR"+ ]+ ) ::+ Parser [String]+ )+ `shouldThrow` (== ExitSuccess)
test_resources/completion/bash-completion-script.bash view
@@ -10,7 +10,6 @@ done COMPREPLY=( $(/usr/bin/example-executable "${CMDLINE[@]}") )- echo "${COMPREPLY[@]}" > hm.log } complete -o filenames -F _opt_env_conf_completion_example_executable example-executable
− test_resources/docs/args/config-docs.txt
@@ -1,1 +0,0 @@-AnyDocsAnd []
− test_resources/docs/args/config.txt
− test_resources/docs/args/docs.txt
@@ -1,12 +0,0 @@-AnyDocsSingle- SetDoc- { setDocTryArgument = True- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "ARGUMENT"- , setDocHelp = Just "Argument"- }
− test_resources/docs/args/env-docs.txt
@@ -1,1 +0,0 @@-AnyDocsAnd []
− test_resources/docs/args/env.txt
− test_resources/docs/args/help.txt
@@ -1,15 +0,0 @@-[36mUsage: [m[33margs[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m--args parser--[36mAvailable settings[m:- [34mShow this help text[m- switch: [37m-h[m[36m|[m[37m--help[m-- [34mOutput version information: 0.0.0[m- switch: [37m--version[m-- [34mArgument[m- argument: [33mARGUMENT[m- -
− test_resources/docs/args/man.txt
@@ -1,26 +0,0 @@-.Dd $Mdocdate$-.Dt args 1-.Os-.Sh NAME-.Nm args-.Nd args parser-.Sh VERSION-0.0.0-.Sh SYNOPSIS-args (-h|--help) | --version | ARGUMENT-.Sh SETTINGS- Show this help text- switch: -h|--help-- Output version information: 0.0.0- switch: --version-- Argument- argument: ARGUMENT- --.Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - ARGUMENT Argument -
− test_resources/docs/args/opt-docs.txt
@@ -1,10 +0,0 @@-AnyDocsSingle- OptDoc- { optDocTryArgument = True- , optDocTrySwitch = False- , optDocTryOption = False- , optDocDasheds = []- , optDocDefault = Nothing- , optDocMetavar = Just "ARGUMENT"- , optDocHelp = Just "Argument"- }
− test_resources/docs/args/opt-long.txt
@@ -1,3 +0,0 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [33mARGUMENT[m [34mArgument[m
− test_resources/docs/args/opt-short.txt
@@ -1,1 +0,0 @@-[33margs[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m
− test_resources/docs/args/reference.txt
@@ -1,18 +0,0 @@-[36mUsage: [m[33margs[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m--[36mAll settings[m:- [34mShow this help text[m- switch: [37m-h[m[36m|[m[37m--help[m-- [34mOutput version information: 0.0.0[m- switch: [37m--version[m-- [34mArgument[m- argument: [33mARGUMENT[m- --[36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [33mARGUMENT[m [34mArgument[m -
− test_resources/docs/args/show.txt
@@ -1,18 +0,0 @@-Check- Nothing- True- _- (Many- (Setting- Nothing- (Setting- []- [ _ ]- True- Nothing- False- Nothing- Nothing- Nothing- (Just "ARGUMENT")- (Just "Argument"))))
− test_resources/docs/args/version.txt
@@ -1,1 +0,0 @@-[33margs[m 0.0.0
test_resources/docs/big-config/config-docs.txt view
@@ -1,7 +1,10 @@-AnyDocsSingle- EnvDoc- { envDocVars = "CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }+AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "CONFIG_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "Path to the configuration file"+ }+ ]
test_resources/docs/big-config/config.txt view
@@ -1,6 +1,10 @@- [34mmulti-line config codec explanation, the same option twice.[m+ [34mbig configuration object[m [37mbig[m: # [32mor null[m- [37m<key>[m: + # BigConfig+ [37mmap[m: # [31mrequired[m [37m<key>[m: - [33m<number>[m # [32m64 bit signed integer[m+ [37m<key>[m: + [33m<integer>[m # [32m64 bit signed integer[m+ [37msub[m: # [34moptional[m+ [33m<string>[m
test_resources/docs/big-config/docs.txt view
@@ -1,42 +1,58 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , setDocEnvVars = Just ("CONFIG_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Path to the configuration file"+ })+ , AnyDocsSingle Nothing+ ] , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys =- Just- (( "big" :| []- , AnyOfSchema- (NullSchema :|- [ MapSchema- (MapSchema- (NumberSchema- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- })))- ])- ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp =- Just "multi-line config codec explanation, the same option twice."- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "big" :| []+ , AnyOfSchema+ (NullSchema :|+ [ CommentSchema+ "BigConfig"+ (ObjectSchema+ (ObjectAllOfSchema+ (ObjectKeySchema+ "map"+ Required+ (MapSchema+ (MapSchema+ (IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ })))+ Nothing :|+ [ ObjectKeySchema+ "sub" (Optional Nothing) StringSchema Nothing+ ])))+ ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "big configuration object"+ }) ]
test_resources/docs/big-config/env-docs.txt view
@@ -1,21 +1,33 @@-AnyDocsSingle- ConfDoc- { confDocKeys =- ( "big" :| []- , AnyOfSchema- (NullSchema :|- [ MapSchema- (MapSchema- (NumberSchema- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- })))- ])- ) :|- []- , confDocDefault = Nothing- , confDocHelp =- Just "multi-line config codec explanation, the same option twice."- }+AnyDocsAnd+ [ AnyDocsOr []+ , AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "big" :| []+ , AnyOfSchema+ (NullSchema :|+ [ CommentSchema+ "BigConfig"+ (ObjectSchema+ (ObjectAllOfSchema+ (ObjectKeySchema+ "map"+ Required+ (MapSchema+ (MapSchema+ (IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ })))+ Nothing :|+ [ ObjectKeySchema "sub" (Optional Nothing) StringSchema Nothing+ ])))+ ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "big configuration object"+ }+ ]
test_resources/docs/big-config/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33mbig-config[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m[36m)[m+[36mUsage: [m[33mbig-config[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m example with a big configuration @@ -12,12 +12,15 @@ [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mCONFIG_FILE[m [33mFILE_PATH[m- - [34mmulti-line config codec explanation, the same option twice.[m++ [34mbig configuration object[m config: [37mbig[m: # [32mor null[m- [37m<key>[m: + # BigConfig+ [37mmap[m: # [31mrequired[m [37m<key>[m: - [33m<number>[m # [32m64 bit signed integer[m- + [37m<key>[m: + [33m<integer>[m # [32m64 bit signed integer[m+ [37msub[m: # [34moptional[m+ [33m<string>[m
test_resources/docs/big-config/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-big-config (-h|--help) | --version | (--config-file FILE_PATH)+big-config [--config-file FILE_PATH] .Sh SETTINGS Show this help text switch: -h|--help@@ -18,28 +18,35 @@ Path to the configuration file option: --config-file FILE_PATH env: CONFIG_FILE FILE_PATH- - multi-line config codec explanation, the same option twice.++ big configuration object config: big: # or null- <key>: + # BigConfig+ map: # required <key>: - <number> # 64 bit signed integer- + <key>: + <integer> # 64 bit signed integer+ sub: # optional+ <string> .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file + -h|--help Show this help text + --version Output version information: 0.0.0+ --config-file Path to the configuration file .Sh ENVIRONMENT VARIABLES CONFIG_FILE FILE_PATH Path to the configuration file .Sh CONFIGURATION VALUES- multi-line config codec explanation, the same option twice.+ big configuration object big: # or null- <key>: + # BigConfig+ map: # required <key>: - <number> # 64 bit signed integer+ <key>: + <integer> # 64 bit signed integer+ sub: # optional+ <string>
+ test_resources/docs/big-config/nix-options.nix view
@@ -0,0 +1,18 @@+{ lib }:+{+ big = lib.mkOption {+ default = null;+ description = "big configuration object";+ type = lib.types.nullOr (lib.types.submodule {+ options = {+ map = lib.mkOption {+ type = lib.types.attrsOf (lib.types.attrsOf lib.types.int);+ };+ sub = lib.mkOption {+ default = null;+ type = lib.types.nullOr lib.types.str;+ };+ };+ });+ };+}
test_resources/docs/big-config/opt-docs.txt view
@@ -1,10 +1,17 @@-AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "Path to the configuration file"+ })+ ]+ , AnyDocsSingle Nothing+ ]
test_resources/docs/big-config/opt-long.txt view
@@ -1,3 +1,1 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m + [37m--config-file[m [34mPath to the configuration file[m
test_resources/docs/big-config/opt-short.txt view
@@ -1,1 +1,1 @@-[33mbig-config[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m[36m)[m+[33mbig-config[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m
test_resources/docs/big-config/reference.txt view
@@ -1,37 +1,44 @@-[36mUsage: [m[33mbig-config[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m[36m)[m+[36mUsage: [m[33mbig-config[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mCONFIG_FILE[m [33mFILE_PATH[m- - [34mmulti-line config codec explanation, the same option twice.[m++ [34mbig configuration object[m config: [37mbig[m: # [32mor null[m- [37m<key>[m: + # BigConfig+ [37mmap[m: # [31mrequired[m [37m<key>[m: - [33m<number>[m # [32m64 bit signed integer[m- + [37m<key>[m: + [33m<integer>[m # [32m64 bit signed integer[m+ [37msub[m: # [34moptional[m+ [33m<string>[m [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--config-file[m [34mPath to the configuration file[m [36mEnvironment Variables[m: [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m [36mConfiguration Values[m:- [34mmulti-line config codec explanation, the same option twice.[m+ [34mbig configuration object[m [37mbig[m: # [32mor null[m- [37m<key>[m: + # BigConfig+ [37mmap[m: # [31mrequired[m [37m<key>[m: - [33m<number>[m # [32m64 bit signed integer[m+ [37m<key>[m: + [33m<integer>[m # [32m64 bit signed integer[m+ [37msub[m: # [34moptional[m+ [33m<string>[m
test_resources/docs/big-config/show.txt view
@@ -1,5 +1,6 @@ WithConfig _+ Nothing (Check Nothing False@@ -23,42 +24,47 @@ (Just "FILE_PATH") (Just "Path to the configuration file")))) (Check Nothing False _ (Pure _))))- (Check+ (Setting Nothing- True- _ (Setting+ []+ []+ False Nothing- (Setting- []- []- False- Nothing- False- Nothing- (Just- [ ( "big" :| []- , BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (MapCodec- (MapCodec- (BimapCodec- _- _- (NumberCodec- Nothing- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- }))))))- )- ])- Nothing- Nothing- (Just- "multi-line config codec explanation, the same option twice."))))+ False+ Nothing+ (Just+ (ConfigValSetting+ ("big" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (ObjectOfCodec+ (Just "BigConfig")+ (ApCodec+ (BimapCodec+ _+ _+ (RequiredKeyCodec+ "map"+ Nothing+ (MapCodec+ (MapCodec+ (BimapCodec+ _+ _+ (IntegerCodec+ Nothing+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }))))))+ (BimapCodec+ _ _ (OptionalKeyCodec "sub" Nothing (StringCodec Nothing)))))) :|+ []))+ Nothing+ Nothing+ (Just "big configuration object")))
test_resources/docs/empty/docs.txt view
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsSingle Nothing
test_resources/docs/empty/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33mempty[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[36mUsage: [m[33mempty[m empty parser @@ -8,5 +8,4 @@ [34mOutput version information: 0.0.0[m switch: [37m--version[m-
test_resources/docs/empty/man.txt view
@@ -7,16 +7,15 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-empty (-h|--help) | --version+empty .Sh SETTINGS Show this help text switch: -h|--help Output version information: 0.0.0 switch: --version- .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 + -h|--help Show this help text + --version Output version information: 0.0.0
+ test_resources/docs/empty/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
test_resources/docs/empty/opt-long.txt view
@@ -1,2 +0,0 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m
test_resources/docs/empty/opt-short.txt view
@@ -1,1 +1,1 @@-[33mempty[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[33mempty[m
test_resources/docs/empty/reference.txt view
@@ -1,14 +1,13 @@-[36mUsage: [m[33mempty[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[36mUsage: [m[33mempty[m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m- [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m
+ test_resources/docs/enable-disable-optional/config-docs.txt view
@@ -0,0 +1,10 @@+AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "EXAMPLE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "BOOL"+ , envDocHelp = Just "Example of an enable/disable switch"+ }+ ]
+ test_resources/docs/enable-disable-optional/config.txt view
@@ -0,0 +1,4 @@+ [34mExample of an enable/disable switch[m+ [37mexample[m:+ # [32mor null[m+ [33m<boolean>[m
+ test_resources/docs/enable-disable-optional/docs.txt view
@@ -0,0 +1,55 @@+AnyDocsAnd+ [ AnyDocsSingle Nothing+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("EXAMPLE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "example" :| []+ , AnyOfSchema (NullSchema :| [ BoolSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing+ ]+ ]
+ test_resources/docs/enable-disable-optional/env-docs.txt view
@@ -0,0 +1,11 @@+AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Example of an enable/disable switch"+ }+ ]
+ test_resources/docs/enable-disable-optional/env.txt view
@@ -0,0 +1,1 @@+ [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m
+ test_resources/docs/enable-disable-optional/help.txt view
@@ -0,0 +1,18 @@+[36mUsage: [m[33menable-disable-optional[m [36m[[m[37m--(enable|disable)-example[m[36m][m++enableDisableSwitch' example++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mExample of an enable/disable switch[m+ switch: [37m--(enable|disable)-example[m+ env: [37mEXAMPLE[m [33mBOOL[m+ config:+ [37mexample[m: # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/enable-disable-optional/man.txt view
@@ -0,0 +1,38 @@+.Dd $Mdocdate$+.Dt enable-disable-optional 1+.Os+.Sh NAME+.Nm enable-disable-optional+.Nd enableDisableSwitch' example+.Sh VERSION+0.0.0+.Sh SYNOPSIS+enable-disable-optional [--(enable|disable)-example]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ Example of an enable/disable switch+ switch: --(enable|disable)-example+ env: EXAMPLE BOOL+ config:+ example: # or null+ <boolean>++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0 + --(enable|disable)-example Example of an enable/disable switch++.Sh ENVIRONMENT VARIABLES+ EXAMPLE BOOL Example of an enable/disable switch++.Sh CONFIGURATION VALUES+ Example of an enable/disable switch+ example:+ # or null+ <boolean>+
+ test_resources/docs/enable-disable-optional/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ example = lib.mkOption {+ default = null;+ description = "Example of an enable/disable switch";+ type = lib.types.nullOr lib.types.bool;+ };+}
+ test_resources/docs/enable-disable-optional/opt-docs.txt view
@@ -0,0 +1,16 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ ]
+ test_resources/docs/enable-disable-optional/opt-long.txt view
@@ -0,0 +1,1 @@+ [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m
+ test_resources/docs/enable-disable-optional/opt-short.txt view
@@ -0,0 +1,1 @@+[33menable-disable-optional[m [36m[[m[37m--(enable|disable)-example[m[36m][m
+ test_resources/docs/enable-disable-optional/reference.txt view
@@ -0,0 +1,30 @@+[36mUsage: [m[33menable-disable-optional[m [36m[[m[37m--(enable|disable)-example[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mExample of an enable/disable switch[m+ switch: [37m--(enable|disable)-example[m+ env: [37mEXAMPLE[m [33mBOOL[m+ config:+ [37mexample[m: # [32mor null[m+ [33m<boolean>[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m++[36mEnvironment Variables[m:+ [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m++[36mConfiguration Values[m:+ [34mExample of an enable/disable switch[m+ [37mexample[m:+ # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/enable-disable-optional/show.txt view
@@ -0,0 +1,102 @@+WithConfig+ _+ Nothing+ (Pure _)+ (Alt+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('(' :| "enable|disable)-example") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "Example of an enable/disable switch"))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('d' :| "isable-example") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing)))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('e' :| "nable-example") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing)))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ False+ Nothing+ False+ (Just ("EXAMPLE" :| []))+ Nothing+ Nothing+ (Just "BOOL")+ (Just "Example of an enable/disable switch"))))+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ []+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("example" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ []))+ Nothing+ Nothing+ (Just "Example of an enable/disable switch"))))))))+ (Pure _))
+ test_resources/docs/enable-disable-optional/version.txt view
@@ -0,0 +1,1 @@+[33menable-disable-optional[m 0.0.0
test_resources/docs/enable-disable/config-docs.txt view
@@ -1,15 +1,9 @@-AnyDocsAnd+AnyDocsOr [ AnyDocsSingle EnvDoc- { envDocVars = "CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }- , AnyDocsSingle- EnvDoc { envDocVars = "EXAMPLE" :| [] , envDocDefault = Nothing+ , envDocExamples = [] , envDocMetavar = Just "BOOL" , envDocHelp = Just "Example of an enable/disable switch" }
test_resources/docs/enable-disable/docs.txt view
@@ -1,57 +1,55 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsSingle Nothing , AnyDocsOr [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = True- , setDocTryOption = False- , setDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "Example of an enable/disable switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Just ("EXAMPLE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "BOOL"- , setDocHelp = Just "Example of an enable/disable switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("EXAMPLE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "Example of an enable/disable switch"+ }) , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys =- Just- (( "example" :| []- , AnyOfSchema (NullSchema :| [ BoolSchema ])- ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "Example of an enable/disable switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "example" :| []+ , AnyOfSchema (NullSchema :| [ BoolSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing ] ]
test_resources/docs/enable-disable/env-docs.txt view
@@ -1,8 +1,11 @@-AnyDocsSingle- ConfDoc- { confDocKeys =- ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|- []- , confDocDefault = Nothing- , confDocHelp = Just "Example of an enable/disable switch"- }+AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Example of an enable/disable switch"+ }+ ]
test_resources/docs/enable-disable/env.txt view
@@ -1,2 +1,1 @@- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m - [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m+ [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m
test_resources/docs/enable-disable/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33menable-disable[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--(enable|disable)-example[m[36m)[m+[36mUsage: [m[33menable-disable[m [36m[[m[37m--(enable|disable)-example[m[36m][m enableDisableSwitch example @@ -9,15 +9,10 @@ [34mOutput version information: 0.0.0[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- [34mExample of an enable/disable switch[m switch: [37m--(enable|disable)-example[m env: [37mEXAMPLE[m [33mBOOL[m config: [37mexample[m: # [32mor null[m [33m<boolean>[m-
test_resources/docs/enable-disable/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-enable-disable (-h|--help) | --version | (--config-file FILE_PATH --(enable|disable)-example)+enable-disable [--(enable|disable)-example] .Sh SETTINGS Show this help text switch: -h|--help@@ -15,10 +15,6 @@ Output version information: 0.0.0 switch: --version - Path to the configuration file- option: --config-file FILE_PATH- env: CONFIG_FILE FILE_PATH- Example of an enable/disable switch switch: --(enable|disable)-example env: EXAMPLE BOOL@@ -26,16 +22,13 @@ example: # or null <boolean> - .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file - --(enable|disable)-example Example of an enable/disable switch + -h|--help Show this help text + --version Output version information: 0.0.0 + --(enable|disable)-example Example of an enable/disable switch .Sh ENVIRONMENT VARIABLES- CONFIG_FILE FILE_PATH Path to the configuration file - EXAMPLE BOOL Example of an enable/disable switch+ EXAMPLE BOOL Example of an enable/disable switch .Sh CONFIGURATION VALUES Example of an enable/disable switch
+ test_resources/docs/enable-disable/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ example = lib.mkOption {+ default = null;+ description = "Example of an enable/disable switch";+ type = lib.types.nullOr lib.types.bool;+ };+}
test_resources/docs/enable-disable/opt-docs.txt view
@@ -1,22 +1,16 @@-AnyDocsAnd+AnyDocsOr [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }- , AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = True- , optDocTryOption = False- , optDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]- , optDocDefault = Nothing- , optDocMetavar = Nothing- , optDocHelp = Just "Example of an enable/disable switch"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('(' :| "enable|disable)-example") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "Example of an enable/disable switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing ]
test_resources/docs/enable-disable/opt-long.txt view
@@ -1,4 +1,1 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m + [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m
test_resources/docs/enable-disable/opt-short.txt view
@@ -1,1 +1,1 @@-[33menable-disable[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--(enable|disable)-example[m[36m)[m+[33menable-disable[m [36m[[m[37m--(enable|disable)-example[m[36m][m
test_resources/docs/enable-disable/reference.txt view
@@ -1,16 +1,12 @@-[36mUsage: [m[33menable-disable[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--(enable|disable)-example[m[36m)[m+[36mUsage: [m[33menable-disable[m [36m[[m[37m--(enable|disable)-example[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- [34mExample of an enable/disable switch[m switch: [37m--(enable|disable)-example[m env: [37mEXAMPLE[m [33mBOOL[m@@ -18,16 +14,13 @@ [37mexample[m: # [32mor null[m [33m<boolean>[m - [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--(enable|disable)-example[m [34mExample of an enable/disable switch[m [36mEnvironment Variables[m:- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m - [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m+ [37mEXAMPLE[m [33mBOOL[m [34mExample of an enable/disable switch[m [36mConfiguration Values[m: [34mExample of an enable/disable switch[m
test_resources/docs/enable-disable/show.txt view
@@ -1,28 +1,7 @@ WithConfig _- (Check- Nothing- False- _- (Alt- (Check- Nothing- False- _- (Setting- Nothing- (Setting- [ DashedLong ('c' :| "onfig-file") ]- [ _ ]- False- Nothing- True- (Just ("CONFIG_FILE" :| []))- Nothing- Nothing- (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ Nothing+ (Pure _) (Alt (Check Nothing@@ -110,13 +89,13 @@ False Nothing (Just- [ ( "example" :| []- , BimapCodec- _- _- (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing))- )- ])+ (ConfigValSetting+ ("example" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ [])) Nothing Nothing (Just "Example of an enable/disable switch"))))
test_resources/docs/greet/config-docs.txt view
@@ -1,15 +1,19 @@ AnyDocsAnd- [ AnyDocsSingle- EnvDoc- { envDocVars = "GREET_CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "GREET_CONFIG_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "Path to the configuration file"+ }+ ] , AnyDocsSingle EnvDoc { envDocVars = "GREET_GREETING" :| [] , envDocDefault = Just "\"Hello\""+ , envDocExamples = [ "Greetings" ] , envDocMetavar = Just "GREETING" , envDocHelp = Just "Greeting to use" }@@ -17,6 +21,7 @@ EnvDoc { envDocVars = "GREET_POLITE" :| [] , envDocDefault = Just "False"+ , envDocExamples = [] , envDocMetavar = Just "ANY" , envDocHelp = Just "Whether to be polite" }
test_resources/docs/greet/config.txt view
@@ -1,8 +1,11 @@ [34mGreeting to use[m+ default: [33m"Hello"[m+ example: [33mGreetings[m [37mgreeting[m: # [32mor null[m [33m<string>[m [34mWhether to be polite[m+ default: [33mFalse[m [37mpolite[m: # [32mor null[m [33m<boolean>[m
test_resources/docs/greet/docs.txt view
@@ -1,59 +1,70 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("GREET_CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , setDocEnvVars = Just ("GREET_CONFIG_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Path to the configuration file"+ })+ , AnyDocsSingle Nothing+ ] , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds =- [ DashedShort 'g' , DashedLong ('g' :| "reeting") ]- , setDocEnvVars = Just ("GREET_GREETING" :| [])- , setDocConfKeys =- Just- (( "greeting" :| []- , AnyOfSchema (NullSchema :| [ StringSchema ])- ) :|- [])- , setDocDefault = Just "\"Hello\""- , setDocMetavar = Just "GREETING"- , setDocHelp = Just "Greeting to use"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds =+ [ DashedShort 'g' , DashedLong ('g' :| "reeting") ]+ , setDocEnvVars = Just ("GREET_GREETING" :| [])+ , setDocConfKeys =+ Just+ (( "greeting" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Just "\"Hello\""+ , setDocExamples = [ "Greetings" ]+ , setDocMetavar = Just "GREETING"+ , setDocHelp = Just "Greeting to use"+ }) , AnyDocsSingle- SetDoc- { setDocTryArgument = True- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Just "\"world\""- , setDocMetavar = Just "SUBJECT"- , setDocHelp = Just "Who to greet"- }+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Just "\"world\""+ , setDocExamples = []+ , setDocMetavar = Just "SUBJECT"+ , setDocHelp = Just "Who to greet"+ }) , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = True- , setDocTryOption = False- , setDocDasheds = [ DashedShort 'p' , DashedLong ('p' :| "olite") ]- , setDocEnvVars = Just ("GREET_POLITE" :| [])- , setDocConfKeys =- Just- (( "polite" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|- [])- , setDocDefault = Just "False"- , setDocMetavar = Just "ANY"- , setDocHelp = Just "Whether to be polite"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 'p' , DashedLong ('p' :| "olite") ]+ , setDocEnvVars = Just ("GREET_POLITE" :| [])+ , setDocConfKeys =+ Just+ (( "polite" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ [])+ , setDocDefault = Just "False"+ , setDocExamples = []+ , setDocMetavar = Just "ANY"+ , setDocHelp = Just "Whether to be polite"+ }) ]
test_resources/docs/greet/env-docs.txt view
@@ -1,5 +1,6 @@ AnyDocsAnd- [ AnyDocsSingle+ [ AnyDocsOr []+ , AnyDocsSingle ConfDoc { confDocKeys = ( "greeting" :| []@@ -7,6 +8,7 @@ ) :| [] , confDocDefault = Just "\"Hello\""+ , confDocExamples = [ "Greetings" ] , confDocHelp = Just "Greeting to use" } , AnyDocsSingle@@ -15,6 +17,7 @@ ( "polite" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :| [] , confDocDefault = Just "False"+ , confDocExamples = [] , confDocHelp = Just "Whether to be polite" } ]
test_resources/docs/greet/env.txt view
@@ -1,3 +1,3 @@- [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mGREET_GREETING[m [33mGREETING[m [34mGreeting to use[m - [37mGREET_POLITE[m [33mANY[m [34mWhether to be polite[m + [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m + [37mGREET_GREETING[m [33mGREETING[m [34mGreeting to use[m default: [33m"Hello"[m example: [33mGreetings[m+ [37mGREET_POLITE[m [33mANY[m [34mWhether to be polite[m default: [33mFalse[m
test_resources/docs/greet/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33mgreet[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m [33mSUBJECT[m [37m-p[m[36m|[m[37m--polite[m[36m)[m+[36mUsage: [m[33mgreet[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m[36m][m [36m[[m[33mSUBJECT[m[36m][m [36m[[m[37m-p[m[36m|[m[37m--polite[m[36m][m hello world example @@ -12,22 +12,25 @@ [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m- + [34mGreeting to use[m option: [37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m env: [37mGREET_GREETING[m [33mGREETING[m config: [37mgreeting[m: # [32mor null[m [33m<string>[m- + default: [33m"Hello"[m+ example: [33mGreetings[m+ [34mWho to greet[m argument: [33mSUBJECT[m- + default: [33m"world"[m+ [34mWhether to be polite[m switch: [37m-p[m[36m|[m[37m--polite[m env: [37mGREET_POLITE[m [33mANY[m config: [37mpolite[m: # [32mor null[m [33m<boolean>[m- + default: [33mFalse[m
test_resources/docs/greet/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-greet (-h|--help) | --version | (--config-file FILE_PATH -g|--greeting GREETING SUBJECT -p|--polite)+greet [--config-file FILE_PATH] [-g|--greeting GREETING] [SUBJECT] [-p|--polite] .Sh SETTINGS Show this help text switch: -h|--help@@ -18,44 +18,50 @@ Path to the configuration file option: --config-file FILE_PATH env: GREET_CONFIG_FILE FILE_PATH- + Greeting to use option: -g|--greeting GREETING env: GREET_GREETING GREETING config: greeting: # or null <string>- + default: "Hello"+ example: Greetings+ Who to greet argument: SUBJECT- + default: "world"+ Whether to be polite switch: -p|--polite env: GREET_POLITE ANY config: polite: # or null <boolean>- + default: False .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file - -g|--greeting Greeting to use default: "Hello"- SUBJECT Who to greet default: "world"- -p|--polite Whether to be polite default: False + -h|--help Show this help text + --version Output version information: 0.0.0 + --config-file Path to the configuration file + -g|--greeting Greeting to use default: "Hello" example: Greetings+ SUBJECT Who to greet default: "world" + -p|--polite Whether to be polite default: False .Sh ENVIRONMENT VARIABLES- GREET_CONFIG_FILE FILE_PATH Path to the configuration file- GREET_GREETING GREETING Greeting to use - GREET_POLITE ANY Whether to be polite + GREET_CONFIG_FILE FILE_PATH Path to the configuration file + GREET_GREETING GREETING Greeting to use default: "Hello" example: Greetings+ GREET_POLITE ANY Whether to be polite default: False .Sh CONFIGURATION VALUES Greeting to use+ default: "Hello"+ example: Greetings greeting: # or null <string> Whether to be polite+ default: False polite: # or null <boolean>
+ test_resources/docs/greet/nix-options.nix view
@@ -0,0 +1,13 @@+{ lib }:+{+ greeting = lib.mkOption {+ default = null;+ description = "Greeting to use";+ type = lib.types.nullOr lib.types.str;+ };+ polite = lib.mkOption {+ default = null;+ description = "Whether to be polite";+ type = lib.types.nullOr lib.types.bool;+ };+}
test_resources/docs/greet/opt-docs.txt view
@@ -1,43 +1,53 @@ AnyDocsAnd- [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "Path to the configuration file"+ })+ ] , AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds =- [ DashedShort 'g' , DashedLong ('g' :| "reeting") ]- , optDocDefault = Just "\"Hello\""- , optDocMetavar = Just "GREETING"- , optDocHelp = Just "Greeting to use"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds =+ [ DashedShort 'g' , DashedLong ('g' :| "reeting") ]+ , optDocDefault = Just "\"Hello\""+ , optDocExamples = [ "Greetings" ]+ , optDocMetavar = Just "GREETING"+ , optDocHelp = Just "Greeting to use"+ }) , AnyDocsSingle- OptDoc- { optDocTryArgument = True- , optDocTrySwitch = False- , optDocTryOption = False- , optDocDasheds = []- , optDocDefault = Just "\"world\""- , optDocMetavar = Just "SUBJECT"- , optDocHelp = Just "Who to greet"- }+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Just "\"world\""+ , optDocExamples = []+ , optDocMetavar = Just "SUBJECT"+ , optDocHelp = Just "Who to greet"+ }) , AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = True- , optDocTryOption = False- , optDocDasheds = [ DashedShort 'p' , DashedLong ('p' :| "olite") ]- , optDocDefault = Just "False"- , optDocMetavar = Just "ANY"- , optDocHelp = Just "Whether to be polite"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 'p' , DashedLong ('p' :| "olite") ]+ , optDocDefault = Just "False"+ , optDocExamples = []+ , optDocMetavar = Just "ANY"+ , optDocHelp = Just "Whether to be polite"+ }) ]
test_resources/docs/greet/opt-long.txt view
@@ -1,6 +1,4 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m-g[m[36m|[m[37m--greeting[m [34mGreeting to use[m default: [33m"Hello"[m- [33mSUBJECT[m [34mWho to greet[m default: [33m"world"[m- [37m-p[m[36m|[m[37m--polite[m [34mWhether to be polite[m default: [33mFalse[m + [37m--config-file[m [34mPath to the configuration file[m + [37m-g[m[36m|[m[37m--greeting[m [34mGreeting to use[m default: [33m"Hello"[m example: [33mGreetings[m+ [33mSUBJECT[m [34mWho to greet[m default: [33m"world"[m + [37m-p[m[36m|[m[37m--polite[m [34mWhether to be polite[m default: [33mFalse[m
test_resources/docs/greet/opt-short.txt view
@@ -1,1 +1,1 @@-[33mgreet[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m [33mSUBJECT[m [37m-p[m[36m|[m[37m--polite[m[36m)[m+[33mgreet[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m[36m][m [36m[[m[33mSUBJECT[m[36m][m [36m[[m[37m-p[m[36m|[m[37m--polite[m[36m][m
test_resources/docs/greet/reference.txt view
@@ -1,53 +1,59 @@-[36mUsage: [m[33mgreet[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m [33mSUBJECT[m [37m-p[m[36m|[m[37m--polite[m[36m)[m+[36mUsage: [m[33mgreet[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m[36m][m [36m[[m[33mSUBJECT[m[36m][m [36m[[m[37m-p[m[36m|[m[37m--polite[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m- + [34mGreeting to use[m option: [37m-g[m[36m|[m[37m--greeting[m [33mGREETING[m env: [37mGREET_GREETING[m [33mGREETING[m config: [37mgreeting[m: # [32mor null[m [33m<string>[m- + default: [33m"Hello"[m+ example: [33mGreetings[m+ [34mWho to greet[m argument: [33mSUBJECT[m- + default: [33m"world"[m+ [34mWhether to be polite[m switch: [37m-p[m[36m|[m[37m--polite[m env: [37mGREET_POLITE[m [33mANY[m config: [37mpolite[m: # [32mor null[m [33m<boolean>[m- + default: [33mFalse[m [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m-g[m[36m|[m[37m--greeting[m [34mGreeting to use[m default: [33m"Hello"[m- [33mSUBJECT[m [34mWho to greet[m default: [33m"world"[m- [37m-p[m[36m|[m[37m--polite[m [34mWhether to be polite[m default: [33mFalse[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--config-file[m [34mPath to the configuration file[m + [37m-g[m[36m|[m[37m--greeting[m [34mGreeting to use[m default: [33m"Hello"[m example: [33mGreetings[m+ [33mSUBJECT[m [34mWho to greet[m default: [33m"world"[m + [37m-p[m[36m|[m[37m--polite[m [34mWhether to be polite[m default: [33mFalse[m [36mEnvironment Variables[m:- [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mGREET_GREETING[m [33mGREETING[m [34mGreeting to use[m - [37mGREET_POLITE[m [33mANY[m [34mWhether to be polite[m + [37mGREET_CONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m + [37mGREET_GREETING[m [33mGREETING[m [34mGreeting to use[m default: [33m"Hello"[m example: [33mGreetings[m+ [37mGREET_POLITE[m [33mANY[m [34mWhether to be polite[m default: [33mFalse[m [36mConfiguration Values[m: [34mGreeting to use[m+ default: [33m"Hello"[m+ example: [33mGreetings[m [37mgreeting[m: # [32mor null[m [33m<string>[m [34mWhether to be polite[m+ default: [33mFalse[m [37mpolite[m: # [32mor null[m [33m<boolean>[m
test_resources/docs/greet/show.txt view
@@ -1,5 +1,6 @@ WithConfig _+ Nothing (Check Nothing False@@ -39,16 +40,16 @@ True (Just ("GREET_GREETING" :| [])) (Just- [ ( "greeting" :| []- , BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (BimapCodec _ _ (StringCodec Nothing)))- )- ])+ (ConfigValSetting+ ("greeting" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ [])) (Just _) (Just "GREETING") (Just "Greeting to use"))))@@ -75,11 +76,13 @@ False (Just ("GREET_POLITE" :| [])) (Just- [ ( "polite" :| []- , BimapCodec- _ _ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing))- )- ])+ (ConfigValSetting+ ("polite" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ [])) (Just _) (Just "ANY") (Just "Whether to be polite"))))
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsSingle Nothing
@@ -1,4 +1,4 @@-[36mUsage: [m[33mhidden[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[36mUsage: [m[33mhidden[m example with hidden settings @@ -8,5 +8,4 @@ [34mOutput version information: 0.0.0[m switch: [37m--version[m-
@@ -7,16 +7,15 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-hidden (-h|--help) | --version+hidden .Sh SETTINGS Show this help text switch: -h|--help Output version information: 0.0.0 switch: --version- .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 + -h|--help Show this help text + --version Output version information: 0.0.0
@@ -0,0 +1,2 @@+{ lib }:+{ }
@@ -1,2 +0,0 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m
@@ -1,1 +1,1 @@-[33mhidden[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[33mhidden[m
@@ -1,14 +1,13 @@-[36mUsage: [m[33mhidden[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m+[36mUsage: [m[33mhidden[m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m- [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m
+ test_resources/docs/many-args/config-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/many-args/config.txt view
+ test_resources/docs/many-args/docs.txt view
@@ -0,0 +1,17 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "ARGUMENT"+ , setDocHelp = Just "Argument"+ })+ , AnyDocsSingle Nothing+ ]
+ test_resources/docs/many-args/env-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/many-args/env.txt view
+ test_resources/docs/many-args/help.txt view
@@ -0,0 +1,14 @@+[36mUsage: [m[33mmany-args[m [36m[[m[33mARGUMENT[m[36m][m++many args parser++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mArgument[m+ argument: [33mARGUMENT[m+
+ test_resources/docs/many-args/man.txt view
@@ -0,0 +1,25 @@+.Dd $Mdocdate$+.Dt many-args 1+.Os+.Sh NAME+.Nm many-args+.Nd many args parser+.Sh VERSION+0.0.0+.Sh SYNOPSIS+many-args [ARGUMENT]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ Argument+ argument: ARGUMENT++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ ARGUMENT Argument +
+ test_resources/docs/many-args/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
+ test_resources/docs/many-args/opt-docs.txt view
@@ -0,0 +1,14 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "ARGUMENT"+ , optDocHelp = Just "Argument"+ })+ ]
+ test_resources/docs/many-args/opt-long.txt view
@@ -0,0 +1,1 @@+ [33mARGUMENT[m [34mArgument[m
+ test_resources/docs/many-args/opt-short.txt view
@@ -0,0 +1,1 @@+[33mmany-args[m [36m[[m[33mARGUMENT[m[36m][m
+ test_resources/docs/many-args/reference.txt view
@@ -0,0 +1,17 @@+[36mUsage: [m[33mmany-args[m [36m[[m[33mARGUMENT[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mArgument[m+ argument: [33mARGUMENT[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [33mARGUMENT[m [34mArgument[m +
+ test_resources/docs/many-args/show.txt view
@@ -0,0 +1,14 @@+Many+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ True+ Nothing+ False+ Nothing+ Nothing+ Nothing+ (Just "ARGUMENT")+ (Just "Argument")))
+ test_resources/docs/many-args/version.txt view
@@ -0,0 +1,1 @@+[33mmany-args[m 0.0.0
test_resources/docs/optional/config-docs.txt view
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsOr []
test_resources/docs/optional/docs.txt view
@@ -1,12 +1,17 @@-AnyDocsSingle- SetDoc- { setDocTryArgument = True- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "ARGUMENT"- , setDocHelp = Just "Argument"- }+AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "ARGUMENT"+ , setDocHelp = Just "Argument"+ })+ , AnyDocsSingle Nothing+ ]
test_resources/docs/optional/env-docs.txt view
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsOr []
test_resources/docs/optional/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33moptional[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m+[36mUsage: [m[33moptional[m [36m[[m[33mARGUMENT[m[36m][m optional argument @@ -11,5 +11,4 @@ [34mArgument[m argument: [33mARGUMENT[m-
test_resources/docs/optional/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-optional (-h|--help) | --version | ARGUMENT+optional [ARGUMENT] .Sh SETTINGS Show this help text switch: -h|--help@@ -17,10 +17,9 @@ Argument argument: ARGUMENT- .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - ARGUMENT Argument + -h|--help Show this help text + --version Output version information: 0.0.0+ ARGUMENT Argument
+ test_resources/docs/optional/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
test_resources/docs/optional/opt-docs.txt view
@@ -1,10 +1,14 @@-AnyDocsSingle- OptDoc- { optDocTryArgument = True- , optDocTrySwitch = False- , optDocTryOption = False- , optDocDasheds = []- , optDocDefault = Nothing- , optDocMetavar = Just "ARGUMENT"- , optDocHelp = Just "Argument"- }+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "ARGUMENT"+ , optDocHelp = Just "Argument"+ })+ ]
test_resources/docs/optional/opt-long.txt view
@@ -1,3 +1,1 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [33mARGUMENT[m [34mArgument[m + [33mARGUMENT[m [34mArgument[m
test_resources/docs/optional/opt-short.txt view
@@ -1,1 +1,1 @@-[33moptional[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m+[33moptional[m [36m[[m[33mARGUMENT[m[36m][m
test_resources/docs/optional/reference.txt view
@@ -1,18 +1,17 @@-[36mUsage: [m[33moptional[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [33mARGUMENT[m+[36mUsage: [m[33moptional[m [36m[[m[33mARGUMENT[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m [34mArgument[m argument: [33mARGUMENT[m- [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [33mARGUMENT[m [34mArgument[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [33mARGUMENT[m [34mArgument[m
+ test_resources/docs/same-help/config-docs.txt view
@@ -0,0 +1,30 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "INT" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "INT"+ , envDocHelp = Just "int or string"+ }+ , AnyDocsSingle+ EnvDoc+ { envDocVars = "STRING" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "STR"+ , envDocHelp = Just "int or string"+ }+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "OTHER" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "BOOL"+ , envDocHelp = Just "int or string"+ }+ ]+ ]
+ test_resources/docs/same-help/config.txt view
@@ -0,0 +1,12 @@+ [34mint or string[m+ [37mint[m:+ # [32mor null[m+ [33m<integer>[m # [32m64 bit signed integer[m+ [34mint or string[m+ [37mstring[m:+ # [32mor null[m+ [33m<string>[m+ [34mint or string[m+ [37mother[m:+ # [32mor null[m+ [33m<boolean>[m
+ test_resources/docs/same-help/docs.txt view
@@ -0,0 +1,100 @@+AnyDocsAnd+ [ AnyDocsSingle Nothing+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('i' :| "nt") ]+ , setDocEnvVars = Just ("INT" :| [])+ , setDocConfKeys =+ Just+ (( "int" :| []+ , AnyOfSchema+ (NullSchema :|+ [ IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }+ ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "INT"+ , setDocHelp = Just "int or string"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('s' :| "tring") ]+ , setDocEnvVars = Just ("STRING" :| [])+ , setDocConfKeys =+ Just+ (( "string" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "STR"+ , setDocHelp = Just "int or string"+ })+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('[' :| "no-]other") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "int or string"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("OTHER" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "int or string"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "other" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "int or string"+ })+ , AnyDocsSingle Nothing+ ]+ ]
+ test_resources/docs/same-help/env-docs.txt view
@@ -0,0 +1,44 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "int" :| []+ , AnyOfSchema+ (NullSchema :|+ [ IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }+ ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "int or string"+ }+ , AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "string" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "int or string"+ }+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "other" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "int or string"+ }+ ]+ ]
+ test_resources/docs/same-help/env.txt view
@@ -0,0 +1,3 @@+ [37mINT[m [33mINT[m [34mint or string[m+ [37mSTRING[m [33mSTR[m [34mint or string[m+ [37mOTHER[m [33mBOOL[m [34mint or string[m
+ test_resources/docs/same-help/help.txt view
@@ -0,0 +1,30 @@+[36mUsage: [m[33msame-help[m [36m[[m[37m--int[m [33mINT[m [36m|[m [37m--string[m [33mSTR[m[36m][m [36m[[m[37m--[no-]other[m[36m][m++example where multiple options use the same help string++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mint or string[m+ option: [37m--int[m [33mINT[m+ env: [37mINT[m [33mINT[m+ config:+ [37mint[m: # [32mor null[m+ [33m<integer>[m # [32m64 bit signed integer[m+ option: [37m--string[m [33mSTR[m+ env: [37mSTRING[m [33mSTR[m+ config:+ [37mstring[m: # [32mor null[m+ [33m<string>[m++ [34mint or string[m+ switch: [37m--[no-]other[m+ env: [37mOTHER[m [33mBOOL[m+ config:+ [37mother[m: # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/same-help/man.txt view
@@ -0,0 +1,62 @@+.Dd $Mdocdate$+.Dt same-help 1+.Os+.Sh NAME+.Nm same-help+.Nd example where multiple options use the same help string+.Sh VERSION+0.0.0+.Sh SYNOPSIS+same-help [--int INT | --string STR] [--[no-]other]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ int or string+ option: --int INT+ env: INT INT+ config:+ int: # or null+ <integer> # 64 bit signed integer+ option: --string STR+ env: STRING STR+ config:+ string: # or null+ <string>++ int or string+ switch: --[no-]other+ env: OTHER BOOL+ config:+ other: # or null+ <boolean>++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ --int int or string + --string int or string + --[no-]other int or string ++.Sh ENVIRONMENT VARIABLES+ INT INT int or string+ STRING STR int or string+ OTHER BOOL int or string++.Sh CONFIGURATION VALUES+ int or string+ int:+ # or null+ <integer> # 64 bit signed integer+ int or string+ string:+ # or null+ <string>+ int or string+ other:+ # or null+ <boolean>+
+ test_resources/docs/same-help/nix-options.nix view
@@ -0,0 +1,18 @@+{ lib }:+{+ int = lib.mkOption {+ default = null;+ description = "int or string";+ type = lib.types.nullOr lib.types.int;+ };+ other = lib.mkOption {+ default = null;+ description = "int or string";+ type = lib.types.nullOr lib.types.bool;+ };+ string = lib.mkOption {+ default = null;+ description = "int or string";+ type = lib.types.nullOr lib.types.str;+ };+}
+ test_resources/docs/same-help/opt-docs.txt view
@@ -0,0 +1,44 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('i' :| "nt") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "INT"+ , optDocHelp = Just "int or string"+ })+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('s' :| "tring") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "STR"+ , optDocHelp = Just "int or string"+ })+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('[' :| "no-]other") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "int or string"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ ]+ ]
+ test_resources/docs/same-help/opt-long.txt view
@@ -0,0 +1,3 @@+ [37m--int[m [34mint or string[m+ [37m--string[m [34mint or string[m+ [37m--[no-]other[m [34mint or string[m
+ test_resources/docs/same-help/opt-short.txt view
@@ -0,0 +1,1 @@+[33msame-help[m [36m[[m[37m--int[m [33mINT[m [36m|[m [37m--string[m [33mSTR[m[36m][m [36m[[m[37m--[no-]other[m[36m][m
+ test_resources/docs/same-help/reference.txt view
@@ -0,0 +1,54 @@+[36mUsage: [m[33msame-help[m [36m[[m[37m--int[m [33mINT[m [36m|[m [37m--string[m [33mSTR[m[36m][m [36m[[m[37m--[no-]other[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mint or string[m+ option: [37m--int[m [33mINT[m+ env: [37mINT[m [33mINT[m+ config:+ [37mint[m: # [32mor null[m+ [33m<integer>[m # [32m64 bit signed integer[m+ option: [37m--string[m [33mSTR[m+ env: [37mSTRING[m [33mSTR[m+ config:+ [37mstring[m: # [32mor null[m+ [33m<string>[m++ [34mint or string[m+ switch: [37m--[no-]other[m+ env: [37mOTHER[m [33mBOOL[m+ config:+ [37mother[m: # [32mor null[m+ [33m<boolean>[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [37m--int[m [34mint or string[m + [37m--string[m [34mint or string[m + [37m--[no-]other[m [34mint or string[m ++[36mEnvironment Variables[m:+ [37mINT[m [33mINT[m [34mint or string[m+ [37mSTRING[m [33mSTR[m [34mint or string[m+ [37mOTHER[m [33mBOOL[m [34mint or string[m++[36mConfiguration Values[m:+ [34mint or string[m+ [37mint[m:+ # [32mor null[m+ [33m<integer>[m # [32m64 bit signed integer[m+ [34mint or string[m+ [37mstring[m:+ # [32mor null[m+ [33m<string>[m+ [34mint or string[m+ [37mother[m:+ # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/same-help/show.txt view
@@ -0,0 +1,146 @@+WithConfig+ _+ Nothing+ (Pure _)+ (Ap+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('i' :| "nt") ]+ [ _ ]+ False+ Nothing+ True+ (Just ("INT" :| []))+ (Just+ (ConfigValSetting+ ("int" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec+ _+ _+ (IntegerCodec+ Nothing+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }))) :|+ []))+ Nothing+ (Just "INT")+ (Just "int or string"))))+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('s' :| "tring") ]+ [ _ ]+ False+ Nothing+ True+ (Just ("STRING" :| []))+ (Just+ (ConfigValSetting+ ("string" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ (Just "STR")+ (Just "int or string")))))+ (Alt+ (Setting+ Nothing+ (Setting+ [ DashedLong ('[' :| "no-]other") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "int or string")))+ (Alt+ (Setting+ Nothing+ (Setting+ [ DashedLong ('n' :| "o-other") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing))+ (Alt+ (Setting+ Nothing+ (Setting+ [ DashedLong ('o' :| "ther") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing))+ (Alt+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ False+ Nothing+ False+ (Just ("OTHER" :| []))+ Nothing+ Nothing+ (Just "BOOL")+ (Just "int or string")))+ (Alt+ (Setting+ Nothing+ (Setting+ []+ []+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("other" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ []))+ Nothing+ Nothing+ (Just "int or string")))+ (Pure _)))))))
+ test_resources/docs/same-help/version.txt view
@@ -0,0 +1,1 @@+[33msame-help[m 0.0.0
+ test_resources/docs/secret/config-docs.txt view
@@ -0,0 +1,50 @@+AnyDocsAnd+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "FIRST_SECRET_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "First example secret"+ }+ , AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "SECOND_SECRET" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "SECRET"+ , envDocHelp = Just "Second example secret, bare or in a file"+ }+ , AnyDocsSingle+ EnvDoc+ { envDocVars = "SECOND_SECRET_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "Second example secret, bare or in a file"+ }+ ]+ , AnyDocsOr []+ , AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "second-secret" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "SECRET"+ , envDocHelp =+ Just "Second example secret, bare or in a file, only env"+ }+ , AnyDocsSingle+ EnvDoc+ { envDocVars = "second-secret_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp =+ Just "Second example secret, bare or in a file, only env"+ }+ ]+ , AnyDocsOr []+ ]
+ test_resources/docs/secret/config.txt view
@@ -0,0 +1,20 @@+ [34mFirst example secret[m+ [37mfirst-secret-file[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file[m+ [37msecond-secret[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file[m+ [37msecond-secret-file[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file, only conf[m+ [37msecond-secret[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file, only conf[m+ [37msecond-secret-file[m:+ # [32mor null[m+ [33m<string>[m
+ test_resources/docs/secret/docs.txt view
@@ -0,0 +1,224 @@+AnyDocsAnd+ [ AnyDocsSingle Nothing+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('f' :| "irst-secret-file") ]+ , setDocEnvVars = Just ("FIRST_SECRET_FILE" :| [])+ , setDocConfKeys =+ Just+ (( "first-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "First example secret"+ })+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('s' :| "econd-secret") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('s' :| "econd-secret-file") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("SECOND_SECRET" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("SECOND_SECRET_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "second-secret" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "second-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Second example secret, bare or in a file"+ })+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('s' :| "econd-secret") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only option"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('s' :| "econd-secret-file") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only option"+ })+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("second-secret" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only env"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("second-secret_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only env"+ })+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "second-secret" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SECRET"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only conf"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "second-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp =+ Just "Second example secret, bare or in a file, only conf"+ })+ ]+ ]
+ test_resources/docs/secret/env-docs.txt view
@@ -0,0 +1,65 @@+AnyDocsAnd+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "first-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "First example secret"+ }+ , AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "second-secret" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Second example secret, bare or in a file"+ }+ , AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "second-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Second example secret, bare or in a file"+ }+ ]+ , AnyDocsOr []+ , AnyDocsOr []+ , AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "second-secret" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp =+ Just "Second example secret, bare or in a file, only conf"+ }+ , AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "second-secret-file" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp =+ Just "Second example secret, bare or in a file, only conf"+ }+ ]+ ]
+ test_resources/docs/secret/env.txt view
@@ -0,0 +1,5 @@+ [37mFIRST_SECRET_FILE[m [33mFILE_PATH[m [34mFirst example secret[m + [37mSECOND_SECRET[m [33mSECRET[m [34mSecond example secret, bare or in a file[m + [37mSECOND_SECRET_FILE[m [33mFILE_PATH[m [34mSecond example secret, bare or in a file[m + [37msecond-secret[m [33mSECRET[m [34mSecond example secret, bare or in a file, only env[m+ [37msecond-secret_FILE[m [33mFILE_PATH[m [34mSecond example secret, bare or in a file, only env[m
+ test_resources/docs/secret/help.txt view
@@ -0,0 +1,46 @@+[36mUsage: [m[33msecret[m [37m--first-secret-file[m [33mFILE_PATH[m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m++Secrets example++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mFirst example secret[m+ option: [37m--first-secret-file[m [33mFILE_PATH[m+ env: [37mFIRST_SECRET_FILE[m [33mFILE_PATH[m+ config:+ [37mfirst-secret-file[m: # [32mor null[m+ [33m<string>[m++ [34mSecond example secret, bare or in a file[m+ option: [37m--second-secret[m [33mSECRET[m+ option: [37m--second-secret-file[m [33mFILE_PATH[m+ env: [37mSECOND_SECRET[m [33mSECRET[m+ env: [37mSECOND_SECRET_FILE[m [33mFILE_PATH[m+ config:+ [37msecond-secret[m: # [32mor null[m+ [33m<string>[m+ config:+ [37msecond-secret-file[m: # [32mor null[m+ [33m<string>[m++ [34mSecond example secret, bare or in a file, only option[m+ option: [37m--second-secret[m [33mSECRET[m+ option: [37m--second-secret-file[m [33mFILE_PATH[m++ [34mSecond example secret, bare or in a file, only env[m+ env: [37msecond-secret[m [33mSECRET[m+ env: [37msecond-secret_FILE[m [33mFILE_PATH[m++ [34mSecond example secret, bare or in a file, only conf[m+ config:+ [37msecond-secret[m: # [32mor null[m+ [33m<string>[m+ config:+ [37msecond-secret-file[m: # [32mor null[m+ [33m<string>[m+
+ test_resources/docs/secret/man.txt view
@@ -0,0 +1,90 @@+.Dd $Mdocdate$+.Dt secret 1+.Os+.Sh NAME+.Nm secret+.Nd Secrets example+.Sh VERSION+0.0.0+.Sh SYNOPSIS+secret --first-secret-file FILE_PATH [--second-secret SECRET | --second-secret-file FILE_PATH] [--second-secret SECRET | --second-secret-file FILE_PATH]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ First example secret+ option: --first-secret-file FILE_PATH+ env: FIRST_SECRET_FILE FILE_PATH+ config:+ first-secret-file: # or null+ <string>++ Second example secret, bare or in a file+ option: --second-secret SECRET+ option: --second-secret-file FILE_PATH+ env: SECOND_SECRET SECRET+ env: SECOND_SECRET_FILE FILE_PATH+ config:+ second-secret: # or null+ <string>+ config:+ second-secret-file: # or null+ <string>++ Second example secret, bare or in a file, only option+ option: --second-secret SECRET+ option: --second-secret-file FILE_PATH++ Second example secret, bare or in a file, only env+ env: second-secret SECRET+ env: second-secret_FILE FILE_PATH++ Second example secret, bare or in a file, only conf+ config:+ second-secret: # or null+ <string>+ config:+ second-secret-file: # or null+ <string>++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0 + --first-secret-file First example secret + --second-secret Second example secret, bare or in a file + --second-secret-file Second example secret, bare or in a file + --second-secret Second example secret, bare or in a file, only option+ --second-secret-file Second example secret, bare or in a file, only option++.Sh ENVIRONMENT VARIABLES+ FIRST_SECRET_FILE FILE_PATH First example secret + SECOND_SECRET SECRET Second example secret, bare or in a file + SECOND_SECRET_FILE FILE_PATH Second example secret, bare or in a file + second-secret SECRET Second example secret, bare or in a file, only env+ second-secret_FILE FILE_PATH Second example secret, bare or in a file, only env++.Sh CONFIGURATION VALUES+ First example secret+ first-secret-file:+ # or null+ <string>+ Second example secret, bare or in a file+ second-secret:+ # or null+ <string>+ Second example secret, bare or in a file+ second-secret-file:+ # or null+ <string>+ Second example secret, bare or in a file, only conf+ second-secret:+ # or null+ <string>+ Second example secret, bare or in a file, only conf+ second-secret-file:+ # or null+ <string>+
+ test_resources/docs/secret/nix-options.nix view
@@ -0,0 +1,18 @@+{ lib }:+{+ first-secret-file = lib.mkOption {+ default = null;+ description = "First example secret";+ type = lib.types.nullOr lib.types.str;+ };+ second-secret = lib.mkOption {+ default = null;+ description = "Second example secret, bare or in a file, only conf";+ type = lib.types.nullOr lib.types.str;+ };+ second-secret-file = lib.mkOption {+ default = null;+ description = "Second example secret, bare or in a file, only conf";+ type = lib.types.nullOr lib.types.str;+ };+}
+ test_resources/docs/secret/opt-docs.txt view
@@ -0,0 +1,74 @@+AnyDocsAnd+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('f' :| "irst-secret-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "First example secret"+ })+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('s' :| "econd-secret") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "SECRET"+ , optDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('s' :| "econd-secret-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "Second example secret, bare or in a file"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ ]+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('s' :| "econd-secret") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "SECRET"+ , optDocHelp =+ Just "Second example secret, bare or in a file, only option"+ })+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('s' :| "econd-secret-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp =+ Just "Second example secret, bare or in a file, only option"+ })+ ]+ , AnyDocsOr [ AnyDocsSingle Nothing , AnyDocsSingle Nothing ]+ , AnyDocsOr [ AnyDocsSingle Nothing , AnyDocsSingle Nothing ]+ ]
+ test_resources/docs/secret/opt-long.txt view
@@ -0,0 +1,5 @@+ [37m--first-secret-file[m [34mFirst example secret[m + [37m--second-secret[m [34mSecond example secret, bare or in a file[m + [37m--second-secret-file[m [34mSecond example secret, bare or in a file[m + [37m--second-secret[m [34mSecond example secret, bare or in a file, only option[m+ [37m--second-secret-file[m [34mSecond example secret, bare or in a file, only option[m
+ test_resources/docs/secret/opt-short.txt view
@@ -0,0 +1,1 @@+[33msecret[m [37m--first-secret-file[m [33mFILE_PATH[m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m
+ test_resources/docs/secret/reference.txt view
@@ -0,0 +1,82 @@+[36mUsage: [m[33msecret[m [37m--first-secret-file[m [33mFILE_PATH[m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--second-secret[m [33mSECRET[m [36m|[m [37m--second-secret-file[m [33mFILE_PATH[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mFirst example secret[m+ option: [37m--first-secret-file[m [33mFILE_PATH[m+ env: [37mFIRST_SECRET_FILE[m [33mFILE_PATH[m+ config:+ [37mfirst-secret-file[m: # [32mor null[m+ [33m<string>[m++ [34mSecond example secret, bare or in a file[m+ option: [37m--second-secret[m [33mSECRET[m+ option: [37m--second-secret-file[m [33mFILE_PATH[m+ env: [37mSECOND_SECRET[m [33mSECRET[m+ env: [37mSECOND_SECRET_FILE[m [33mFILE_PATH[m+ config:+ [37msecond-secret[m: # [32mor null[m+ [33m<string>[m+ config:+ [37msecond-secret-file[m: # [32mor null[m+ [33m<string>[m++ [34mSecond example secret, bare or in a file, only option[m+ option: [37m--second-secret[m [33mSECRET[m+ option: [37m--second-secret-file[m [33mFILE_PATH[m++ [34mSecond example secret, bare or in a file, only env[m+ env: [37msecond-secret[m [33mSECRET[m+ env: [37msecond-secret_FILE[m [33mFILE_PATH[m++ [34mSecond example secret, bare or in a file, only conf[m+ config:+ [37msecond-secret[m: # [32mor null[m+ [33m<string>[m+ config:+ [37msecond-secret-file[m: # [32mor null[m+ [33m<string>[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--first-secret-file[m [34mFirst example secret[m + [37m--second-secret[m [34mSecond example secret, bare or in a file[m + [37m--second-secret-file[m [34mSecond example secret, bare or in a file[m + [37m--second-secret[m [34mSecond example secret, bare or in a file, only option[m+ [37m--second-secret-file[m [34mSecond example secret, bare or in a file, only option[m++[36mEnvironment Variables[m:+ [37mFIRST_SECRET_FILE[m [33mFILE_PATH[m [34mFirst example secret[m + [37mSECOND_SECRET[m [33mSECRET[m [34mSecond example secret, bare or in a file[m + [37mSECOND_SECRET_FILE[m [33mFILE_PATH[m [34mSecond example secret, bare or in a file[m + [37msecond-secret[m [33mSECRET[m [34mSecond example secret, bare or in a file, only env[m+ [37msecond-secret_FILE[m [33mFILE_PATH[m [34mSecond example secret, bare or in a file, only env[m++[36mConfiguration Values[m:+ [34mFirst example secret[m+ [37mfirst-secret-file[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file[m+ [37msecond-secret[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file[m+ [37msecond-secret-file[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file, only conf[m+ [37msecond-secret[m:+ # [32mor null[m+ [33m<string>[m+ [34mSecond example secret, bare or in a file, only conf[m+ [37msecond-secret-file[m:+ # [32mor null[m+ [33m<string>[m+
+ test_resources/docs/secret/show.txt view
@@ -0,0 +1,291 @@+WithConfig+ _+ Nothing+ (Pure _)+ (Ap+ (Ap+ (Ap+ (Ap+ (Check+ Nothing+ False+ _+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('f' :| "irst-secret-file") ]+ [ _ ]+ False+ Nothing+ True+ (Just ("FIRST_SECRET_FILE" :| []))+ (Just+ (ConfigValSetting+ ("first-secret-file" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ (Just "FILE_PATH")+ (Just "First example secret")))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('s' :| "econd-secret") ]+ [ _ , _ ]+ False+ Nothing+ True+ Nothing+ Nothing+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file"))))+ (Alt+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('s' :| "econd-secret-file") ]+ [ _ , _ ]+ False+ Nothing+ True+ Nothing+ Nothing+ Nothing+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file"))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ (Just ("SECOND_SECRET" :| []))+ Nothing+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file"))))+ (Alt+ (Check+ Nothing+ False+ _+ (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+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("second-secret" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file"))))+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (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"))))))))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('s' :| "econd-secret") ]+ [ _ , _ ]+ False+ Nothing+ True+ Nothing+ Nothing+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file, only option"))))+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (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"))))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ (Just ("second-secret" :| []))+ Nothing+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file, only env"))))+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ (Just ("second-secret_FILE" :| []))+ Nothing+ Nothing+ (Just "FILE_PATH")+ (Just "Second example secret, bare or in a file, only env"))))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ , _ ]+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("second-secret" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ (Just "SECRET")+ (Just "Second example secret, bare or in a file, only conf"))))+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (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"))))))
+ test_resources/docs/secret/version.txt view
@@ -0,0 +1,1 @@+[33msecret[m 0.0.0
+ test_resources/docs/some-args/config-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/some-args/config.txt view
+ test_resources/docs/some-args/docs.txt view
@@ -0,0 +1,33 @@+AnyDocsAnd+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "ARGUMENT"+ , setDocHelp = Just "Argument"+ })+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "ARGUMENT"+ , setDocHelp = Just "Argument"+ })+ , AnyDocsSingle Nothing+ ]+ ]
+ test_resources/docs/some-args/env-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/some-args/env.txt view
+ test_resources/docs/some-args/help.txt view
@@ -0,0 +1,17 @@+[36mUsage: [m[33msome-args[m [33mARGUMENT[m [36m[[m[33mARGUMENT[m[36m][m++some args parser++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mArgument[m+ argument: [33mARGUMENT[m++ [34mArgument[m+ argument: [33mARGUMENT[m+
+ test_resources/docs/some-args/man.txt view
@@ -0,0 +1,33 @@+.Dd $Mdocdate$+.Dt some-args 1+.Os+.Sh NAME+.Nm some-args+.Nd some args parser+.Sh VERSION+0.0.0+.Sh SYNOPSIS+some-args ARGUMENT [ARGUMENT]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ Argument+ argument: ARGUMENT++ Argument+ argument: ARGUMENT++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ ARGUMENT Argument + ARGUMENT Argument ++.Sh ENVIRONMENT VARIABLES++.Sh CONFIGURATION VALUES+
+ test_resources/docs/some-args/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
+ test_resources/docs/some-args/opt-docs.txt view
@@ -0,0 +1,28 @@+AnyDocsAnd+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "ARGUMENT"+ , optDocHelp = Just "Argument"+ })+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "ARGUMENT"+ , optDocHelp = Just "Argument"+ })+ ]+ ]
+ test_resources/docs/some-args/opt-long.txt view
@@ -0,0 +1,2 @@+ [33mARGUMENT[m [34mArgument[m+ [33mARGUMENT[m [34mArgument[m
+ test_resources/docs/some-args/opt-short.txt view
@@ -0,0 +1,1 @@+[33msome-args[m [33mARGUMENT[m [36m[[m[33mARGUMENT[m[36m][m
+ test_resources/docs/some-args/reference.txt view
@@ -0,0 +1,25 @@+[36mUsage: [m[33msome-args[m [33mARGUMENT[m [36m[[m[33mARGUMENT[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mArgument[m+ argument: [33mARGUMENT[m++ [34mArgument[m+ argument: [33mARGUMENT[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [33mARGUMENT[m [34mArgument[m + [33mARGUMENT[m [34mArgument[m ++[36mEnvironment Variables[m:++[36mConfiguration Values[m:+
+ test_resources/docs/some-args/show.txt view
@@ -0,0 +1,18 @@+Check+ Nothing+ True+ _+ (Some+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ True+ Nothing+ False+ Nothing+ Nothing+ Nothing+ (Just "ARGUMENT")+ (Just "Argument"))))
+ test_resources/docs/some-args/version.txt view
@@ -0,0 +1,1 @@+[33msome-args[m 0.0.0
test_resources/docs/sub-commands/config-docs.txt view
@@ -1,12 +1,16 @@ AnyDocsAnd- [ AnyDocsSingle- EnvDoc- { envDocVars = "CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "CONFIG_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "Path to the configuration file"+ }+ ] , AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "top" , commandDocHelp = "command without subcommands"@@ -15,6 +19,7 @@ EnvDoc { envDocVars = "NAME" :| [] , envDocDefault = Nothing+ , envDocExamples = [ "john" ] , envDocMetavar = Just "NAME" , envDocHelp = Just "name" }@@ -25,6 +30,7 @@ , commandDocs = AnyDocsAnd [ AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "a" , commandDocHelp = "A"@@ -37,6 +43,7 @@ } ] , AnyDocsCommands+ (Just "c") [ CommandDoc { commandDocArgument = "c" , commandDocHelp = "C"
test_resources/docs/sub-commands/config.txt view
@@ -1,4 +1,5 @@ [34mname[m+ example: [33mjohn[m [37mname[m: # [32mor null[m [33m<string>[m
test_resources/docs/sub-commands/docs.txt view
@@ -1,36 +1,44 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , setDocEnvVars = Just ("CONFIG_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Path to the configuration file"+ })+ , AnyDocsSingle Nothing+ ] , AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "top" , commandDocHelp = "command without subcommands" , commandDocs = AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('n' :| "ame") ]- , setDocEnvVars = Just ("NAME" :| [])- , setDocConfKeys =- Just- (( "name" :| [] , AnyOfSchema (NullSchema :| [ StringSchema ]) ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Just "NAME"- , setDocHelp = Just "name"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('n' :| "ame") ]+ , setDocEnvVars = Just ("NAME" :| [])+ , setDocConfKeys =+ Just+ (( "name" :| [] , AnyOfSchema (NullSchema :| [ StringSchema ]) ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = [ "john" ]+ , setDocMetavar = Just "NAME"+ , setDocHelp = Just "name"+ }) } , CommandDoc { commandDocArgument = "sub"@@ -38,27 +46,29 @@ , commandDocs = AnyDocsAnd [ AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "a" , commandDocHelp = "A"- , commandDocs = AnyDocsAnd []+ , commandDocs = AnyDocsSingle Nothing } , CommandDoc { commandDocArgument = "b" , commandDocHelp = "B"- , commandDocs = AnyDocsAnd []+ , commandDocs = AnyDocsSingle Nothing } ] , AnyDocsCommands+ (Just "c") [ CommandDoc { commandDocArgument = "c" , commandDocHelp = "C"- , commandDocs = AnyDocsAnd []+ , commandDocs = AnyDocsSingle Nothing } , CommandDoc { commandDocArgument = "d" , commandDocHelp = "D"- , commandDocs = AnyDocsAnd []+ , commandDocs = AnyDocsSingle Nothing } ] ]
test_resources/docs/sub-commands/env-docs.txt view
@@ -1,46 +1,53 @@-AnyDocsCommands- [ CommandDoc- { commandDocArgument = "top"- , commandDocHelp = "command without subcommands"- , commandDocs =- AnyDocsSingle- ConfDoc- { confDocKeys =- ( "name" :| [] , AnyOfSchema (NullSchema :| [ StringSchema ]) ) :|- []- , confDocDefault = Nothing- , confDocHelp = Just "name"- }- }- , CommandDoc- { commandDocArgument = "sub"- , commandDocHelp = "command with subcommands"- , commandDocs =- AnyDocsAnd- [ AnyDocsCommands- [ CommandDoc- { commandDocArgument = "a"- , commandDocHelp = "A"- , commandDocs = AnyDocsAnd []- }- , CommandDoc- { commandDocArgument = "b"- , commandDocHelp = "B"- , commandDocs = AnyDocsAnd []- }- ]- , AnyDocsCommands- [ CommandDoc- { commandDocArgument = "c"- , commandDocHelp = "C"- , commandDocs = AnyDocsAnd []- }- , CommandDoc- { commandDocArgument = "d"- , commandDocHelp = "D"- , commandDocs = AnyDocsAnd []- }+AnyDocsAnd+ [ AnyDocsOr []+ , AnyDocsCommands+ Nothing+ [ CommandDoc+ { commandDocArgument = "top"+ , commandDocHelp = "command without subcommands"+ , commandDocs =+ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "name" :| [] , AnyOfSchema (NullSchema :| [ StringSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = [ "john" ]+ , confDocHelp = Just "name"+ }+ }+ , CommandDoc+ { commandDocArgument = "sub"+ , commandDocHelp = "command with subcommands"+ , commandDocs =+ AnyDocsAnd+ [ AnyDocsCommands+ Nothing+ [ CommandDoc+ { commandDocArgument = "a"+ , commandDocHelp = "A"+ , commandDocs = AnyDocsAnd []+ }+ , CommandDoc+ { commandDocArgument = "b"+ , commandDocHelp = "B"+ , commandDocs = AnyDocsAnd []+ }+ ]+ , AnyDocsCommands+ (Just "c")+ [ CommandDoc+ { commandDocArgument = "c"+ , commandDocHelp = "C"+ , commandDocs = AnyDocsAnd []+ }+ , CommandDoc+ { commandDocArgument = "d"+ , commandDocHelp = "D"+ , commandDocs = AnyDocsAnd []+ }+ ] ]- ]- }+ }+ ] ]
test_resources/docs/sub-commands/env.txt view
@@ -1,2 +1,2 @@- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mNAME[m [33mNAME[m [34mname[m + [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m + [37mNAME[m [33mNAME[m [34mname[m example: [33mjohn[m
test_resources/docs/sub-commands/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33msub-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mtop[m [37m--name[m [33mNAME[m [36m|[m [35msub[m [35ma[m [36m|[m [35mb[m [35mc[m [36m|[m [35md[m[36m)[m+[36mUsage: [m[33msub-commands[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m COMMAND example with subcommands @@ -12,30 +12,8 @@ [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mCONFIG_FILE[m [33mFILE_PATH[m- - [34mcommand without subcommands[m- command: [35mtop[m- [34mname[m- option: [37m--name[m [33mNAME[m- env: [37mNAME[m [33mNAME[m- config:- [37mname[m: # [32mor null[m- [33m<string>[m- - - [34mcommand with subcommands[m- command: [35msub[m- [34mA[m- command: [35ma[m- - [34mB[m- command: [35mb[m- - [34mC[m- command: [35mc[m- - [34mD[m- command: [35md[m- - ++[36mAvailable commands[m:+ [35mtop[m [34mcommand without subcommands[m+ [35msub[m [34mcommand with subcommands[m
test_resources/docs/sub-commands/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-sub-commands (-h|--help) | --version | (--config-file FILE_PATH top --name NAME | sub a | b c | d)+sub-commands [--config-file FILE_PATH] COMMAND .Sh SETTINGS Show this help text switch: -h|--help@@ -18,7 +18,8 @@ Path to the configuration file option: --config-file FILE_PATH env: CONFIG_FILE FILE_PATH- ++.Sh COMMANDS command without subcommands command: top name@@ -27,6 +28,7 @@ config: name: # or null <string>+ example: john command with subcommands@@ -38,7 +40,7 @@ command: b C- command: c+ command: c (default) D command: d@@ -46,23 +48,24 @@ .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file + -h|--help Show this help text+ --version Output version information: 0.0.0+ --config-file Path to the configuration file top command without subcommands- --name name + --name name example: john sub command with subcommands a A b B- c C+ c (default) C d D .Sh ENVIRONMENT VARIABLES- CONFIG_FILE FILE_PATH Path to the configuration file- NAME NAME name + CONFIG_FILE FILE_PATH Path to the configuration file + NAME NAME name example: john .Sh CONFIGURATION VALUES name+ example: john name: # or null <string>
+ test_resources/docs/sub-commands/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ name = lib.mkOption {+ default = null;+ description = "name";+ type = lib.types.nullOr lib.types.str;+ };+}
test_resources/docs/sub-commands/opt-docs.txt view
@@ -1,29 +1,36 @@ AnyDocsAnd- [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "Path to the configuration file"+ })+ ] , AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "top" , commandDocHelp = "command without subcommands" , commandDocs = AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('n' :| "ame") ]- , optDocDefault = Nothing- , optDocMetavar = Just "NAME"- , optDocHelp = Just "name"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('n' :| "ame") ]+ , optDocDefault = Nothing+ , optDocExamples = [ "john" ]+ , optDocMetavar = Just "NAME"+ , optDocHelp = Just "name"+ }) } , CommandDoc { commandDocArgument = "sub"@@ -31,6 +38,7 @@ , commandDocs = AnyDocsAnd [ AnyDocsCommands+ Nothing [ CommandDoc { commandDocArgument = "a" , commandDocHelp = "A"@@ -43,6 +51,7 @@ } ] , AnyDocsCommands+ (Just "c") [ CommandDoc { commandDocArgument = "c" , commandDocHelp = "C"
test_resources/docs/sub-commands/opt-long.txt view
@@ -1,10 +1,8 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m + [37m--config-file[m [34mPath to the configuration file[m [35mtop[m [34mcommand without subcommands[m- [37m--name[m [34mname[m + [37m--name[m [34mname[m example: [33mjohn[m [35msub[m [34mcommand with subcommands[m [35ma[m [34mA[m [35mb[m [34mB[m- [35mc[m [34mC[m+ [35mc[m (default) [34mC[m [35md[m [34mD[m
test_resources/docs/sub-commands/opt-short.txt view
@@ -1,1 +1,1 @@-[33msub-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mtop[m [37m--name[m [33mNAME[m [36m|[m [35msub[m [35ma[m [36m|[m [35mb[m [35mc[m [36m|[m [35md[m[36m)[m+[33msub-commands[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m COMMAND
test_resources/docs/sub-commands/reference.txt view
@@ -1,16 +1,17 @@-[36mUsage: [m[33msub-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mtop[m [37m--name[m [33mNAME[m [36m|[m [35msub[m [35ma[m [36m|[m [35mb[m [35mc[m [36m|[m [35md[m[36m)[m+[36mUsage: [m[33msub-commands[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m COMMAND [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m [34mPath to the configuration file[m option: [37m--config-file[m [33mFILE_PATH[m env: [37mCONFIG_FILE[m [33mFILE_PATH[m- ++[36mAll commands[m: [34mcommand without subcommands[m command: [35mtop[m [34mname[m@@ -19,6 +20,7 @@ config: [37mname[m: # [32mor null[m [33m<string>[m+ example: [33mjohn[m [34mcommand with subcommands[m@@ -30,7 +32,7 @@ command: [35mb[m [34mC[m- command: [35mc[m+ command: [35mc[m (default) [34mD[m command: [35md[m@@ -38,23 +40,24 @@ [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m+ [37m--version[m [34mOutput version information[m+ [37m--config-file[m [34mPath to the configuration file[m [35mtop[m [34mcommand without subcommands[m- [37m--name[m [34mname[m + [37m--name[m [34mname[m example: [33mjohn[m [35msub[m [34mcommand with subcommands[m [35ma[m [34mA[m [35mb[m [34mB[m- [35mc[m [34mC[m+ [35mc[m (default) [34mC[m [35md[m [34mD[m [36mEnvironment Variables[m:- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mNAME[m [33mNAME[m [34mname[m + [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m + [37mNAME[m [33mNAME[m [34mname[m example: [33mjohn[m [36mConfiguration Values[m: [34mname[m+ example: [33mjohn[m [37mname[m: # [32mor null[m [33m<string>[m
test_resources/docs/sub-commands/show.txt view
@@ -1,5 +1,6 @@ WithConfig _+ Nothing (Check Nothing False@@ -24,16 +25,8 @@ (Just "Path to the configuration file")))) (Check Nothing False _ (Pure _)))) (Commands- (Just- SrcLoc- { srcLocPackage = "main"- , srcLocModule = "OptEnvConf.APISpec"- , srcLocFile = "test/OptEnvConf/APISpec.hs"- , srcLocStartLine = 273- , srcLocStartCol = 5- , srcLocEndLine = 273- , srcLocEndCol = 13- })+ Nothing+ Nothing [ Command "top" "command without subcommands"@@ -51,16 +44,16 @@ True (Just ("NAME" :| [])) (Just- [ ( "name" :| []- , BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (BimapCodec _ _ (StringCodec Nothing)))- )- ])+ (ConfigValSetting+ ("name" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ [])) Nothing (Just "NAME") (Just "name"))))@@ -69,27 +62,11 @@ "command with subcommands" (Ap (Commands- (Just- SrcLoc- { srcLocPackage = "main"- , srcLocModule = "OptEnvConf.APISpec"- , srcLocFile = "test/OptEnvConf/APISpec.hs"- , srcLocStartLine = 289- , srcLocStartCol = 3- , srcLocEndLine = 289- , srcLocEndCol = 11- })+ Nothing+ Nothing [ Command "a" "A" (Pure _) , Command "b" "B" (Pure _) ]) (Commands- (Just- SrcLoc- { srcLocPackage = "main"- , srcLocModule = "OptEnvConf.APISpec"- , srcLocFile = "test/OptEnvConf/APISpec.hs"- , srcLocStartLine = 298- , srcLocStartCol = 3- , srcLocEndLine = 298- , srcLocEndCol = 11- })+ Nothing+ (Just "c") [ Command "c" "C" (Pure _) , Command "d" "D" (Pure _) ])) ])
+ test_resources/docs/sub-settings/config-docs.txt view
@@ -0,0 +1,20 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "CONFIG_FILE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "FILE_PATH"+ , envDocHelp = Just "Path to the configuration file"+ }+ ]+ , AnyDocsSingle+ EnvDoc+ { envDocVars = "FOO_BAR_QUUX" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "STR"+ , envDocHelp = Just "Example with sub-settings"+ }+ ]
+ test_resources/docs/sub-settings/config.txt view
@@ -0,0 +1,4 @@+ [34mExample with sub-settings[m+ [37mfoo.bar.quux[m:+ # [32mor null[m+ [33m<string>[m
+ test_resources/docs/sub-settings/docs.txt view
@@ -0,0 +1,38 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , setDocEnvVars = Just ("CONFIG_FILE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "FILE_PATH"+ , setDocHelp = Just "Path to the configuration file"+ })+ , AnyDocsSingle Nothing+ ]+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('f' :| "oo-bar-quux") ]+ , setDocEnvVars = Just ("FOO_BAR_QUUX" :| [])+ , setDocConfKeys =+ Just+ (( "foo" :| [ "bar" , "quux" ]+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "STR"+ , setDocHelp = Just "Example with sub-settings"+ })+ ]
+ test_resources/docs/sub-settings/env-docs.txt view
@@ -0,0 +1,14 @@+AnyDocsAnd+ [ AnyDocsOr []+ , AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "foo" :| [ "bar" , "quux" ]+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Example with sub-settings"+ }+ ]
+ test_resources/docs/sub-settings/env.txt view
@@ -0,0 +1,2 @@+ [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m+ [37mFOO_BAR_QUUX[m [33mSTR[m [34mExample with sub-settings[m
+ test_resources/docs/sub-settings/help.txt view
@@ -0,0 +1,22 @@+[36mUsage: [m[33msub-settings[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [37m--foo-bar-quux[m [33mSTR[m++example with a sub settings++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mPath to the configuration file[m+ option: [37m--config-file[m [33mFILE_PATH[m+ env: [37mCONFIG_FILE[m [33mFILE_PATH[m++ [34mExample with sub-settings[m+ option: [37m--foo-bar-quux[m [33mSTR[m+ env: [37mFOO_BAR_QUUX[m [33mSTR[m+ config:+ [37mfoo.bar.quux[m: # [32mor null[m+ [33m<string>[m+
+ test_resources/docs/sub-settings/man.txt view
@@ -0,0 +1,44 @@+.Dd $Mdocdate$+.Dt sub-settings 1+.Os+.Sh NAME+.Nm sub-settings+.Nd example with a sub settings+.Sh VERSION+0.0.0+.Sh SYNOPSIS+sub-settings [--config-file FILE_PATH] --foo-bar-quux STR+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ Path to the configuration file+ option: --config-file FILE_PATH+ env: CONFIG_FILE FILE_PATH++ Example with sub-settings+ option: --foo-bar-quux STR+ env: FOO_BAR_QUUX STR+ config:+ foo.bar.quux: # or null+ <string>++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ --config-file Path to the configuration file + --foo-bar-quux Example with sub-settings ++.Sh ENVIRONMENT VARIABLES+ CONFIG_FILE FILE_PATH Path to the configuration file+ FOO_BAR_QUUX STR Example with sub-settings ++.Sh CONFIGURATION VALUES+ Example with sub-settings+ foo.bar.quux:+ # or null+ <string>+
+ test_resources/docs/sub-settings/nix-options.nix view
@@ -0,0 +1,22 @@+{ lib }:+{+ foo = lib.mkOption {+ default = { };+ type = lib.types.submodule {+ options = {+ bar = lib.mkOption {+ default = { };+ type = lib.types.submodule {+ options = {+ quux = lib.mkOption {+ default = null;+ description = "Example with sub-settings";+ type = lib.types.nullOr lib.types.str;+ };+ };+ };+ };+ };+ };+ };+}
+ test_resources/docs/sub-settings/opt-docs.txt view
@@ -0,0 +1,28 @@+AnyDocsAnd+ [ AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "FILE_PATH"+ , optDocHelp = Just "Path to the configuration file"+ })+ ]+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('f' :| "oo-bar-quux") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "STR"+ , optDocHelp = Just "Example with sub-settings"+ })+ ]
+ test_resources/docs/sub-settings/opt-long.txt view
@@ -0,0 +1,2 @@+ [37m--config-file[m [34mPath to the configuration file[m+ [37m--foo-bar-quux[m [34mExample with sub-settings[m
+ test_resources/docs/sub-settings/opt-short.txt view
@@ -0,0 +1,1 @@+[33msub-settings[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [37m--foo-bar-quux[m [33mSTR[m
+ test_resources/docs/sub-settings/reference.txt view
@@ -0,0 +1,36 @@+[36mUsage: [m[33msub-settings[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [37m--foo-bar-quux[m [33mSTR[m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mPath to the configuration file[m+ option: [37m--config-file[m [33mFILE_PATH[m+ env: [37mCONFIG_FILE[m [33mFILE_PATH[m++ [34mExample with sub-settings[m+ option: [37m--foo-bar-quux[m [33mSTR[m+ env: [37mFOO_BAR_QUUX[m [33mSTR[m+ config:+ [37mfoo.bar.quux[m: # [32mor null[m+ [33m<string>[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m--config-file[m [34mPath to the configuration file[m+ [37m--foo-bar-quux[m [34mExample with sub-settings[m ++[36mEnvironment Variables[m:+ [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m+ [37mFOO_BAR_QUUX[m [33mSTR[m [34mExample with sub-settings[m ++[36mConfiguration Values[m:+ [34mExample with sub-settings[m+ [37mfoo.bar.quux[m:+ # [32mor null[m+ [33m<string>[m+
+ test_resources/docs/sub-settings/show.txt view
@@ -0,0 +1,49 @@+WithConfig+ _+ Nothing+ (Check+ Nothing+ False+ _+ (Alt+ (Check+ Nothing+ False+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('c' :| "onfig-file") ]+ [ _ ]+ False+ Nothing+ True+ (Just ("CONFIG_FILE" :| []))+ Nothing+ Nothing+ (Just "FILE_PATH")+ (Just "Path to the configuration file"))))+ (Check Nothing False _ (Pure _))))+ (Setting+ Nothing+ (Setting+ [ DashedLong ('f' :| "oo-bar-quux") ]+ [ _ ]+ False+ Nothing+ True+ (Just ("FOO_BAR_QUUX" :| []))+ (Just+ (ConfigValSetting+ ("foo" :| [ "bar" , "quux" ])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ (Just "STR")+ (Just "Example with sub-settings")))
+ test_resources/docs/sub-settings/version.txt view
@@ -0,0 +1,1 @@+[33msub-settings[m 0.0.0
+ test_resources/docs/sum-type/config-docs.txt view
@@ -0,0 +1,10 @@+AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "sum-type" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "SUM_TYPE"+ , envDocHelp = Just "example"+ }+ ]
+ test_resources/docs/sum-type/config.txt view
@@ -0,0 +1,4 @@+ [34mexample[m+ [37msum-type[m:+ # [32mor null[m+ [33m<string>[m
+ test_resources/docs/sum-type/docs.txt view
@@ -0,0 +1,80 @@+AnyDocsAnd+ [ AnyDocsSingle Nothing+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 'a' ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "a"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 'b' ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "b"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("sum-type" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "SUM_TYPE"+ , setDocHelp = Just "example"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "sum-type" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "example"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Just "a"+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "example"+ })+ ]+ ]
+ test_resources/docs/sum-type/env-docs.txt view
@@ -0,0 +1,13 @@+AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "sum-type" :| []+ , AnyOfSchema (NullSchema :| [ StringSchema ])+ ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "example"+ }+ ]
+ test_resources/docs/sum-type/env.txt view
@@ -0,0 +1,1 @@+ [37msum-type[m [33mSUM_TYPE[m [34mexample[m
+ test_resources/docs/sum-type/help.txt view
@@ -0,0 +1,24 @@+[36mUsage: [m[33msum-type[m [36m[[m[37m-a[m [36m|[m [37m-b[m[36m][m++Sum type example++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34ma[m+ switch: [37m-a[m++ [34mb[m+ switch: [37m-b[m++ [34mexample[m+ env: [37msum-type[m [33mSUM_TYPE[m+ config:+ [37msum-type[m: # [32mor null[m+ [33m<string>[m+ default: [33ma[m+
+ test_resources/docs/sum-type/man.txt view
@@ -0,0 +1,45 @@+.Dd $Mdocdate$+.Dt sum-type 1+.Os+.Sh NAME+.Nm sum-type+.Nd Sum type example+.Sh VERSION+0.0.0+.Sh SYNOPSIS+sum-type [-a | -b]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ a+ switch: -a++ b+ switch: -b++ example+ env: sum-type SUM_TYPE+ config:+ sum-type: # or null+ <string>+ default: a++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ -a a + -b b ++.Sh ENVIRONMENT VARIABLES+ sum-type SUM_TYPE example++.Sh CONFIGURATION VALUES+ example+ sum-type:+ # or null+ <string>+
+ test_resources/docs/sum-type/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ sum-type = lib.mkOption {+ default = null;+ description = "example";+ type = lib.types.nullOr lib.types.str;+ };+}
+ test_resources/docs/sum-type/opt-docs.txt view
@@ -0,0 +1,29 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 'a' ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "a"+ })+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 'b' ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "b"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ ]
+ test_resources/docs/sum-type/opt-long.txt view
@@ -0,0 +1,2 @@+ [37m-a[m [34ma[m+ [37m-b[m [34mb[m
+ test_resources/docs/sum-type/opt-short.txt view
@@ -0,0 +1,1 @@+[33msum-type[m [36m[[m[37m-a[m [36m|[m [37m-b[m[36m][m
+ test_resources/docs/sum-type/reference.txt view
@@ -0,0 +1,37 @@+[36mUsage: [m[33msum-type[m [36m[[m[37m-a[m [36m|[m [37m-b[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34ma[m+ switch: [37m-a[m++ [34mb[m+ switch: [37m-b[m++ [34mexample[m+ env: [37msum-type[m [33mSUM_TYPE[m+ config:+ [37msum-type[m: # [32mor null[m+ [33m<string>[m+ default: [33ma[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [37m-a[m [34ma[m + [37m-b[m [34mb[m ++[36mEnvironment Variables[m:+ [37msum-type[m [33mSUM_TYPE[m [34mexample[m++[36mConfiguration Values[m:+ [34mexample[m+ [37msum-type[m:+ # [32mor null[m+ [33m<string>[m+
+ test_resources/docs/sum-type/show.txt view
@@ -0,0 +1,83 @@+WithConfig+ _+ Nothing+ (Pure _)+ (Alt+ (Setting+ Nothing+ (Setting+ [ DashedShort 'a' ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "a")))+ (Alt+ (Setting+ Nothing+ (Setting+ [ DashedShort 'b' ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "b")))+ (Alt+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ False+ Nothing+ False+ (Just ("sum-type" :| []))+ Nothing+ Nothing+ (Just "SUM_TYPE")+ (Just "example")))+ (Alt+ (Setting+ Nothing+ (Setting+ []+ []+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("sum-type" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec _ _ (StringCodec Nothing))) :|+ []))+ Nothing+ Nothing+ (Just "example")))+ (Setting+ Nothing+ (Setting+ []+ []+ False+ Nothing+ False+ Nothing+ Nothing+ (Just _)+ Nothing+ (Just "example")))))))
+ test_resources/docs/sum-type/version.txt view
@@ -0,0 +1,1 @@+[33msum-type[m 0.0.0
test_resources/docs/three-commands/config-docs.txt view
@@ -1,42 +1,38 @@-AnyDocsAnd- [ AnyDocsSingle- EnvDoc- { envDocVars = "CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }- , AnyDocsCommands- [ CommandDoc- { commandDocArgument = "one"- , commandDocHelp = "first"- , commandDocs = AnyDocsAnd []- }- , CommandDoc- { commandDocArgument = "two"- , commandDocHelp = "second"- , commandDocs =- AnyDocsAnd+AnyDocsCommands+ (Just "one")+ [ CommandDoc+ { commandDocArgument = "one"+ , commandDocHelp = "first"+ , commandDocs = AnyDocsAnd []+ }+ , CommandDoc+ { commandDocArgument = "two"+ , commandDocHelp = "second"+ , commandDocs =+ AnyDocsAnd+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "NUMBER" :| []+ , envDocDefault = Nothing+ , envDocExamples = [ "5" ]+ , envDocMetavar = Just "INT"+ , envDocHelp = Just "number"+ }+ , AnyDocsOr [ AnyDocsSingle EnvDoc- { envDocVars = "NUMBER" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "INT"- , envDocHelp = Just "number"- }- , AnyDocsSingle- EnvDoc { envDocVars = "ENABLE" :| [] , envDocDefault = Nothing+ , envDocExamples = [] , envDocMetavar = Just "BOOL" , envDocHelp = Just "enable extra" } ]- }- , CommandDoc- { commandDocArgument = "three"- , commandDocHelp = "third"- , commandDocs = AnyDocsAnd []- }- ]+ ]+ }+ , CommandDoc+ { commandDocArgument = "three-very-long-command-name"+ , commandDocHelp = "third"+ , commandDocs = AnyDocsAnd []+ } ]
test_resources/docs/three-commands/config.txt view
@@ -1,7 +1,8 @@ [34mnumber[m+ example: [33m5[m [37mnumber[m: # [32mor null[m- [33m<number>[m # [32m64 bit signed integer[m+ [33m<integer>[m # [32m64 bit signed integer[m [34menable extra[m [37menable[m: # [32mor null[m
test_resources/docs/three-commands/docs.txt view
@@ -1,33 +1,25 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsSingle Nothing , AnyDocsCommands+ (Just "one") [ CommandDoc { commandDocArgument = "one" , commandDocHelp = "first" , commandDocs = AnyDocsSingle- SetDoc- { setDocTryArgument = True- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "STR"- , setDocHelp = Just "argument"- }+ (Just+ SetDoc+ { setDocTryArgument = True+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "STR"+ , setDocHelp = Just "argument"+ }) } , CommandDoc { commandDocArgument = "two"@@ -35,77 +27,89 @@ , commandDocs = AnyDocsAnd [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('n' :| "umber") , DashedShort 'n' ]- , setDocEnvVars = Just ("NUMBER" :| [])- , setDocConfKeys =- Just- (( "number" :| []- , AnyOfSchema- (NullSchema :|- [ NumberSchema- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- })- ])- ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Just "INT"- , setDocHelp = Just "number"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = True+ , setDocDasheds = [ DashedLong ('n' :| "umber") , DashedShort 'n' ]+ , setDocEnvVars = Just ("NUMBER" :| [])+ , setDocConfKeys =+ Just+ (( "number" :| []+ , AnyOfSchema+ (NullSchema :|+ [ IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }+ ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = [ "5" ]+ , setDocMetavar = Just "INT"+ , setDocHelp = Just "number"+ }) , AnyDocsOr [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = True- , setDocTryOption = False- , setDocDasheds = [ DashedLong ('(' :| "enable|disable)-enable") ]- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "enable extra"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('(' :| "enable|disable)-enable") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "enable extra"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Just ("ENABLE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "BOOL"- , setDocHelp = Just "enable extra"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("ENABLE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "enable extra"+ }) , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys =- Just- (( "enable" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "enable extra"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "enable" :| []+ , AnyOfSchema (NullSchema :| [ BoolSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "enable extra"+ })+ , AnyDocsSingle Nothing ] ] } , CommandDoc- { commandDocArgument = "three"+ { commandDocArgument = "three-very-long-command-name" , commandDocHelp = "third"- , commandDocs = AnyDocsAnd []+ , commandDocs = AnyDocsSingle Nothing } ] ]
test_resources/docs/three-commands/env-docs.txt view
@@ -1,4 +1,5 @@ AnyDocsCommands+ (Just "one") [ CommandDoc { commandDocArgument = "one" , commandDocHelp = "first"@@ -15,30 +16,33 @@ ( "number" :| [] , AnyOfSchema (NullSchema :|- [ NumberSchema- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- })+ [ IntegerSchema+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ } ]) ) :| [] , confDocDefault = Nothing+ , confDocExamples = [ "5" ] , confDocHelp = Just "number" }- , AnyDocsSingle- ConfDoc- { confDocKeys =- ( "enable" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|- []- , confDocDefault = Nothing- , confDocHelp = Just "enable extra"- }+ , AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "enable" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "enable extra"+ }+ ] ] } , CommandDoc- { commandDocArgument = "three"+ { commandDocArgument = "three-very-long-command-name" , commandDocHelp = "third" , commandDocs = AnyDocsAnd [] }
test_resources/docs/three-commands/env.txt view
@@ -1,3 +1,2 @@- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mNUMBER[m [33mINT[m [34mnumber[m - [37mENABLE[m [33mBOOL[m [34menable extra[m + [37mNUMBER[m [33mINT[m [34mnumber[m example: [33m5[m+ [37mENABLE[m [33mBOOL[m [34menable extra[m
test_resources/docs/three-commands/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33mthree-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mone[m [33mSTR[m [36m|[m [35mtwo[m [37m--number[m[36m|[m[37m-n[m [33mINT[m [37m--(enable|disable)-enable[m [36m|[m [35mthree[m[36m)[m+[36mUsage: [m[33mthree-commands[m [COMMAND] example with three commands @@ -9,34 +9,8 @@ [34mOutput version information: 0.0.0[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- - [34mfirst[m- command: [35mone[m- [34margument[m- argument: [33mSTR[m- - - [34msecond[m- command: [35mtwo[m- [34mnumber[m- option: [37m--number[m[36m|[m[37m-n[m [33mINT[m- env: [37mNUMBER[m [33mINT[m- config:- [37mnumber[m: # [32mor null[m- [33m<number>[m # [32m64 bit signed integer[m- - [34menable extra[m- switch: [37m--(enable|disable)-enable[m- env: [37mENABLE[m [33mBOOL[m- config:- [37menable[m: # [32mor null[m- [33m<boolean>[m- - - [34mthird[m- command: [35mthree[m- +[36mAvailable commands[m:+ [35mone[m (default) [34mfirst[m + [35mtwo[m [34msecond[m+ [35mthree-very-long-command-name[m [34mthird[m
test_resources/docs/three-commands/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-three-commands (-h|--help) | --version | (--config-file FILE_PATH one STR | two --number|-n INT --(enable|disable)-enable | three)+three-commands [COMMAND] .Sh SETTINGS Show this help text switch: -h|--help@@ -15,12 +15,9 @@ Output version information: 0.0.0 switch: --version - Path to the configuration file- option: --config-file FILE_PATH- env: CONFIG_FILE FILE_PATH- +.Sh COMMANDS first- command: one+ command: one (default) argument argument: STR @@ -32,7 +29,8 @@ env: NUMBER INT config: number: # or null- <number> # 64 bit signed integer+ <integer> # 64 bit signed integer+ example: 5 enable extra switch: --(enable|disable)-enable@@ -43,30 +41,29 @@ third- command: three+ command: three-very-long-command-name .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file - one first- STR argument + -h|--help Show this help text+ --version Output version information: 0.0.0+ one (default) first+ STR argument two second- --number|-n number - --(enable|disable)-enable enable extra - three third+ --number|-n number example: 5+ --(enable|disable)-enable enable extra + three-very-long-command-name third .Sh ENVIRONMENT VARIABLES- CONFIG_FILE FILE_PATH Path to the configuration file- NUMBER INT number - ENABLE BOOL enable extra + NUMBER INT number example: 5+ ENABLE BOOL enable extra .Sh CONFIGURATION VALUES number+ example: 5 number: # or null- <number> # 64 bit signed integer+ <integer> # 64 bit signed integer enable extra enable: # or null
+ test_resources/docs/three-commands/nix-options.nix view
@@ -0,0 +1,13 @@+{ lib }:+{+ enable = lib.mkOption {+ default = null;+ description = "enable extra";+ type = lib.types.nullOr lib.types.bool;+ };+ number = lib.mkOption {+ default = null;+ description = "number";+ type = lib.types.nullOr lib.types.int;+ };+}
test_resources/docs/three-commands/opt-docs.txt view
@@ -1,61 +1,60 @@-AnyDocsAnd- [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }- , AnyDocsCommands- [ CommandDoc- { commandDocArgument = "one"- , commandDocHelp = "first"- , commandDocs =- AnyDocsSingle- OptDoc- { optDocTryArgument = True- , optDocTrySwitch = False- , optDocTryOption = False- , optDocDasheds = []- , optDocDefault = Nothing- , optDocMetavar = Just "STR"- , optDocHelp = Just "argument"- }- }- , CommandDoc- { commandDocArgument = "two"- , commandDocHelp = "second"- , commandDocs =- AnyDocsAnd+AnyDocsCommands+ (Just "one")+ [ CommandDoc+ { commandDocArgument = "one"+ , commandDocHelp = "first"+ , commandDocs =+ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = True+ , optDocTrySwitch = False+ , optDocTryOption = False+ , optDocDasheds = []+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Just "STR"+ , optDocHelp = Just "argument"+ })+ }+ , CommandDoc+ { commandDocArgument = "two"+ , commandDocHelp = "second"+ , commandDocs =+ AnyDocsAnd+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = False+ , optDocTryOption = True+ , optDocDasheds = [ DashedLong ('n' :| "umber") , DashedShort 'n' ]+ , optDocDefault = Nothing+ , optDocExamples = [ "5" ]+ , optDocMetavar = Just "INT"+ , optDocHelp = Just "number"+ })+ , AnyDocsOr [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('n' :| "umber") , DashedShort 'n' ]- , optDocDefault = Nothing- , optDocMetavar = Just "INT"- , optDocHelp = Just "number"- }- , AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = True- , optDocTryOption = False- , optDocDasheds = [ DashedLong ('(' :| "enable|disable)-enable") ]- , optDocDefault = Nothing- , optDocMetavar = Nothing- , optDocHelp = Just "enable extra"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('(' :| "enable|disable)-enable") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "enable extra"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing ]- }- , CommandDoc- { commandDocArgument = "three"- , commandDocHelp = "third"- , commandDocs = AnyDocsAnd []- }- ]+ ]+ }+ , CommandDoc+ { commandDocArgument = "three-very-long-command-name"+ , commandDocHelp = "third"+ , commandDocs = AnyDocsAnd []+ } ]
test_resources/docs/three-commands/opt-long.txt view
@@ -1,9 +1,6 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [35mone[m [34mfirst[m- [33mSTR[m [34margument[m + [35mone[m (default) [34mfirst[m+ [33mSTR[m [34margument[m [35mtwo[m [34msecond[m- [37m--number[m[36m|[m[37m-n[m [34mnumber[m - [37m--(enable|disable)-enable[m [34menable extra[m - [35mthree[m [34mthird[m+ [37m--number[m[36m|[m[37m-n[m [34mnumber[m example: [33m5[m+ [37m--(enable|disable)-enable[m [34menable extra[m + [35mthree-very-long-command-name[m [34mthird[m
test_resources/docs/three-commands/opt-short.txt view
@@ -1,1 +1,1 @@-[33mthree-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mone[m [33mSTR[m [36m|[m [35mtwo[m [37m--number[m[36m|[m[37m-n[m [33mINT[m [37m--(enable|disable)-enable[m [36m|[m [35mthree[m[36m)[m+[33mthree-commands[m [COMMAND]
test_resources/docs/three-commands/reference.txt view
@@ -1,18 +1,15 @@-[36mUsage: [m[33mthree-commands[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [35mone[m [33mSTR[m [36m|[m [35mtwo[m [37m--number[m[36m|[m[37m-n[m [33mINT[m [37m--(enable|disable)-enable[m [36m|[m [35mthree[m[36m)[m+[36mUsage: [m[33mthree-commands[m [COMMAND] [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- +[36mAll commands[m: [34mfirst[m- command: [35mone[m+ command: [35mone[m (default) [34margument[m argument: [33mSTR[m @@ -24,7 +21,8 @@ env: [37mNUMBER[m [33mINT[m config: [37mnumber[m: # [32mor null[m- [33m<number>[m # [32m64 bit signed integer[m+ [33m<integer>[m # [32m64 bit signed integer[m+ example: [33m5[m [34menable extra[m switch: [37m--(enable|disable)-enable[m@@ -35,30 +33,29 @@ [34mthird[m- command: [35mthree[m+ command: [35mthree-very-long-command-name[m [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [35mone[m [34mfirst[m- [33mSTR[m [34margument[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m+ [37m--version[m [34mOutput version information[m+ [35mone[m (default) [34mfirst[m+ [33mSTR[m [34margument[m [35mtwo[m [34msecond[m- [37m--number[m[36m|[m[37m-n[m [34mnumber[m - [37m--(enable|disable)-enable[m [34menable extra[m - [35mthree[m [34mthird[m+ [37m--number[m[36m|[m[37m-n[m [34mnumber[m example: [33m5[m+ [37m--(enable|disable)-enable[m [34menable extra[m + [35mthree-very-long-command-name[m [34mthird[m [36mEnvironment Variables[m:- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mNUMBER[m [33mINT[m [34mnumber[m - [37mENABLE[m [33mBOOL[m [34menable extra[m + [37mNUMBER[m [33mINT[m [34mnumber[m example: [33m5[m+ [37mENABLE[m [33mBOOL[m [34menable extra[m [36mConfiguration Values[m: [34mnumber[m+ example: [33m5[m [37mnumber[m: # [32mor null[m- [33m<number>[m # [32m64 bit signed integer[m+ [33m<integer>[m # [32m64 bit signed integer[m [34menable extra[m [37menable[m: # [32mor null[m
test_resources/docs/three-commands/show.txt view
@@ -1,39 +1,10 @@ WithConfig _- (Check- Nothing- False- _- (Alt- (Check- Nothing- False- _- (Setting- Nothing- (Setting- [ DashedLong ('c' :| "onfig-file") ]- [ _ ]- False- Nothing- True- (Just ("CONFIG_FILE" :| []))- Nothing- Nothing- (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ Nothing+ (Pure _) (Commands- (Just- SrcLoc- { srcLocPackage = "main"- , srcLocModule = "OptEnvConf.APISpec"- , srcLocFile = "test/OptEnvConf/APISpec.hs"- , srcLocStartLine = 239- , srcLocStartCol = 5- , srcLocEndLine = 239- , srcLocEndCol = 13- })+ Nothing+ (Just "one") [ Command "one" "first"@@ -72,25 +43,24 @@ True (Just ("NUMBER" :| [])) (Just- [ ( "number" :| []- , BimapCodec- _- _- (EitherCodec- PossiblyJointUnion- NullCodec- (BimapCodec- _- _- (NumberCodec- Nothing- (Just- NumberBounds- { numberBoundsLower = -9.223372036854775808e18- , numberBoundsUpper = 9.223372036854775807e18- }))))- )- ])+ (ConfigValSetting+ ("number" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion+ NullCodec+ (BimapCodec+ _+ _+ (IntegerCodec+ Nothing+ Bounds+ { boundsLower = Just (-9223372036854775808)+ , boundsUpper = Just 9223372036854775807+ }))) :|+ [])) Nothing (Just "INT") (Just "number"))))@@ -161,17 +131,17 @@ False Nothing (Just- [ ( "enable" :| []- , BimapCodec- _- _- (EitherCodec- PossiblyJointUnion NullCodec (BoolCodec Nothing))- )- ])+ (ConfigValSetting+ ("enable" :| [])+ BimapCodec+ _+ _+ (EitherCodec+ PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ [])) Nothing Nothing (Just "enable extra"))) (Pure _)))))))- , Command "three" "third" (Pure _)+ , Command "three-very-long-command-name" "third" (Pure _) ])
test_resources/docs/verbose/config-docs.txt view
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsOr []
test_resources/docs/verbose/docs.txt view
@@ -1,13 +1,18 @@-AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = True- , setDocTryOption = False- , setDocDasheds = [ DashedShort 'v' ]- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp =- Just "Verbosity level. Use multiple to increase verbosity"- }+AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 'v' ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp =+ Just "Verbosity level. Use multiple to increase verbosity"+ })+ , AnyDocsSingle Nothing+ ]
test_resources/docs/verbose/env-docs.txt view
@@ -1,1 +1,1 @@-AnyDocsAnd []+AnyDocsOr []
test_resources/docs/verbose/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33mverbose[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [37m-v[m+[36mUsage: [m[33mverbose[m [36m[[m[37m-v[m[36m][m verbosity example @@ -11,5 +11,4 @@ [34mVerbosity level. Use multiple to increase verbosity[m switch: [37m-v[m-
test_resources/docs/verbose/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-verbose (-h|--help) | --version | -v+verbose [-v] .Sh SETTINGS Show this help text switch: -h|--help@@ -17,10 +17,9 @@ Verbosity level. Use multiple to increase verbosity switch: -v- .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - -v Verbosity level. Use multiple to increase verbosity + -h|--help Show this help text + --version Output version information: 0.0.0 + -v Verbosity level. Use multiple to increase verbosity
+ test_resources/docs/verbose/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
test_resources/docs/verbose/opt-docs.txt view
@@ -1,11 +1,15 @@-AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = True- , optDocTryOption = False- , optDocDasheds = [ DashedShort 'v' ]- , optDocDefault = Nothing- , optDocMetavar = Nothing- , optDocHelp =- Just "Verbosity level. Use multiple to increase verbosity"- }+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 'v' ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp =+ Just "Verbosity level. Use multiple to increase verbosity"+ })+ ]
test_resources/docs/verbose/opt-long.txt view
@@ -1,3 +1,1 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m-v[m [34mVerbosity level. Use multiple to increase verbosity[m + [37m-v[m [34mVerbosity level. Use multiple to increase verbosity[m
test_resources/docs/verbose/opt-short.txt view
@@ -1,1 +1,1 @@-[33mverbose[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [37m-v[m+[33mverbose[m [36m[[m[37m-v[m[36m][m
test_resources/docs/verbose/reference.txt view
@@ -1,18 +1,17 @@-[36mUsage: [m[33mverbose[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [37m-v[m+[36mUsage: [m[33mverbose[m [36m[[m[37m-v[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m [34mVerbosity level. Use multiple to increase verbosity[m switch: [37m-v[m- [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m-v[m [34mVerbosity level. Use multiple to increase verbosity[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m-v[m [34mVerbosity level. Use multiple to increase verbosity[m
+ test_resources/docs/with-default/config-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/with-default/config.txt view
+ test_resources/docs/with-default/docs.txt view
@@ -0,0 +1,30 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 'f' , DashedLong ('f' :| "irst") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "first"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedShort 's' , DashedLong ('s' :| "econd") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Just "Second"+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "second"+ })+ ]
+ test_resources/docs/with-default/env-docs.txt view
@@ -0,0 +1,1 @@+AnyDocsOr []
+ test_resources/docs/with-default/env.txt view
+ test_resources/docs/with-default/help.txt view
@@ -0,0 +1,18 @@+[36mUsage: [m[33mwith-default[m [36m[[m[37m-f[m[36m|[m[37m--first[m [36m|[m [36m[[m[37m-s[m[36m|[m[37m--second[m[36m][m[36m][m++withDefault example++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mfirst[m+ switch: [37m-f[m[36m|[m[37m--first[m++ [34msecond[m+ switch: [37m-s[m[36m|[m[37m--second[m+ default: [33mSecond[m+
+ test_resources/docs/with-default/man.txt view
@@ -0,0 +1,30 @@+.Dd $Mdocdate$+.Dt with-default 1+.Os+.Sh NAME+.Nm with-default+.Nd withDefault example+.Sh VERSION+0.0.0+.Sh SYNOPSIS+with-default [-f|--first | [-s|--second]]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ first+ switch: -f|--first++ second+ switch: -s|--second+ default: Second++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0 + -f|--first first + -s|--second second default: Second+
+ test_resources/docs/with-default/nix-options.nix view
@@ -0,0 +1,2 @@+{ lib }:+{ }
+ test_resources/docs/with-default/opt-docs.txt view
@@ -0,0 +1,26 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 'f' , DashedLong ('f' :| "irst") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "first"+ })+ , AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedShort 's' , DashedLong ('s' :| "econd") ]+ , optDocDefault = Just "Second"+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "second"+ })+ ]
+ test_resources/docs/with-default/opt-long.txt view
@@ -0,0 +1,2 @@+ [37m-f[m[36m|[m[37m--first[m [34mfirst[m + [37m-s[m[36m|[m[37m--second[m [34msecond[m default: [33mSecond[m
+ test_resources/docs/with-default/opt-short.txt view
@@ -0,0 +1,1 @@+[33mwith-default[m [36m[[m[37m-f[m[36m|[m[37m--first[m [36m|[m [36m[[m[37m-s[m[36m|[m[37m--second[m[36m][m[36m][m
+ test_resources/docs/with-default/reference.txt view
@@ -0,0 +1,22 @@+[36mUsage: [m[33mwith-default[m [36m[[m[37m-f[m[36m|[m[37m--first[m [36m|[m [36m[[m[37m-s[m[36m|[m[37m--second[m[36m][m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mfirst[m+ switch: [37m-f[m[36m|[m[37m--first[m++ [34msecond[m+ switch: [37m-s[m[36m|[m[37m--second[m+ default: [33mSecond[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m + [37m-f[m[36m|[m[37m--first[m [34mfirst[m + [37m-s[m[36m|[m[37m--second[m [34msecond[m default: [33mSecond[m+
+ test_resources/docs/with-default/show.txt view
@@ -0,0 +1,27 @@+Alt+ (Setting+ Nothing+ (Setting+ [ DashedShort 'f' , DashedLong ('f' :| "irst") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "first")))+ (Setting+ Nothing+ (Setting+ [ DashedShort 's' , DashedLong ('s' :| "econd") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ (Just _)+ Nothing+ (Just "second")))
+ test_resources/docs/with-default/version.txt view
@@ -0,0 +1,1 @@+[33mwith-default[m 0.0.0
+ test_resources/docs/yes-no-optional/config-docs.txt view
@@ -0,0 +1,10 @@+AnyDocsOr+ [ AnyDocsSingle+ EnvDoc+ { envDocVars = "EXAMPLE" :| []+ , envDocDefault = Nothing+ , envDocExamples = []+ , envDocMetavar = Just "BOOL"+ , envDocHelp = Just "Example of a yes/no switch"+ }+ ]
+ test_resources/docs/yes-no-optional/config.txt view
@@ -0,0 +1,4 @@+ [34mExample of a yes/no switch[m+ [37mexample[m:+ # [32mor null[m+ [33m<boolean>[m
+ test_resources/docs/yes-no-optional/docs.txt view
@@ -0,0 +1,55 @@+AnyDocsAnd+ [ AnyDocsSingle Nothing+ , AnyDocsOr+ [ AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('[' :| "no-]example") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("EXAMPLE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "example" :| []+ , AnyOfSchema (NullSchema :| [ BoolSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing+ ]+ ]
+ test_resources/docs/yes-no-optional/env-docs.txt view
@@ -0,0 +1,11 @@+AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Example of a yes/no switch"+ }+ ]
+ test_resources/docs/yes-no-optional/env.txt view
@@ -0,0 +1,1 @@+ [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m
+ test_resources/docs/yes-no-optional/help.txt view
@@ -0,0 +1,18 @@+[36mUsage: [m[33myes-no-optional[m [36m[[m[37m--[no-]example[m[36m][m++yesNoSwitch' example++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mExample of a yes/no switch[m+ switch: [37m--[no-]example[m+ env: [37mEXAMPLE[m [33mBOOL[m+ config:+ [37mexample[m: # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/yes-no-optional/man.txt view
@@ -0,0 +1,38 @@+.Dd $Mdocdate$+.Dt yes-no-optional 1+.Os+.Sh NAME+.Nm yes-no-optional+.Nd yesNoSwitch' example+.Sh VERSION+0.0.0+.Sh SYNOPSIS+yes-no-optional [--[no-]example]+.Sh SETTINGS+ Show this help text+ switch: -h|--help++ Output version information: 0.0.0+ switch: --version++ Example of a yes/no switch+ switch: --[no-]example+ env: EXAMPLE BOOL+ config:+ example: # or null+ <boolean>++.Sh OPTIONS+ -h|--help Show this help text + --version Output version information: 0.0.0+ --[no-]example Example of a yes/no switch ++.Sh ENVIRONMENT VARIABLES+ EXAMPLE BOOL Example of a yes/no switch++.Sh CONFIGURATION VALUES+ Example of a yes/no switch+ example:+ # or null+ <boolean>+
+ test_resources/docs/yes-no-optional/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ example = lib.mkOption {+ default = null;+ description = "Example of a yes/no switch";+ type = lib.types.nullOr lib.types.bool;+ };+}
+ test_resources/docs/yes-no-optional/opt-docs.txt view
@@ -0,0 +1,16 @@+AnyDocsOr+ [ AnyDocsSingle+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('[' :| "no-]example") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing+ ]
+ test_resources/docs/yes-no-optional/opt-long.txt view
@@ -0,0 +1,1 @@+ [37m--[no-]example[m [34mExample of a yes/no switch[m
+ test_resources/docs/yes-no-optional/opt-short.txt view
@@ -0,0 +1,1 @@+[33myes-no-optional[m [36m[[m[37m--[no-]example[m[36m][m
+ test_resources/docs/yes-no-optional/reference.txt view
@@ -0,0 +1,30 @@+[36mUsage: [m[33myes-no-optional[m [36m[[m[37m--[no-]example[m[36m][m++[36mAll settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information[m+ switch: [37m--version[m++ [34mExample of a yes/no switch[m+ switch: [37m--[no-]example[m+ env: [37mEXAMPLE[m [33mBOOL[m+ config:+ [37mexample[m: # [32mor null[m+ [33m<boolean>[m++[36mOptions[m:+ [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [37m--[no-]example[m [34mExample of a yes/no switch[m++[36mEnvironment Variables[m:+ [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m++[36mConfiguration Values[m:+ [34mExample of a yes/no switch[m+ [37mexample[m:+ # [32mor null[m+ [33m<boolean>[m+
+ test_resources/docs/yes-no-optional/show.txt view
@@ -0,0 +1,102 @@+WithConfig+ _+ Nothing+ (Pure _)+ (Alt+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('[' :| "no-]example") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ (Just "Example of a yes/no switch"))))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('n' :| "o-example") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing)))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ [ DashedLong ('e' :| "xample") ]+ []+ False+ (Just _)+ False+ Nothing+ Nothing+ Nothing+ Nothing+ Nothing)))+ (Alt+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ [ _ ]+ False+ Nothing+ False+ (Just ("EXAMPLE" :| []))+ Nothing+ Nothing+ (Just "BOOL")+ (Just "Example of a yes/no switch"))))+ (Check+ Nothing+ True+ _+ (Setting+ Nothing+ (Setting+ []+ []+ False+ Nothing+ False+ Nothing+ (Just+ (ConfigValSetting+ ("example" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ []))+ Nothing+ Nothing+ (Just "Example of a yes/no switch"))))))))+ (Pure _))
+ test_resources/docs/yes-no-optional/version.txt view
@@ -0,0 +1,1 @@+[33myes-no-optional[m 0.0.0
test_resources/docs/yes-no/config-docs.txt view
@@ -1,15 +1,9 @@-AnyDocsAnd+AnyDocsOr [ AnyDocsSingle EnvDoc- { envDocVars = "CONFIG_FILE" :| []- , envDocDefault = Nothing- , envDocMetavar = Just "FILE_PATH"- , envDocHelp = Just "Path to the configuration file"- }- , AnyDocsSingle- EnvDoc { envDocVars = "EXAMPLE" :| [] , envDocDefault = Nothing+ , envDocExamples = [] , envDocMetavar = Just "BOOL" , envDocHelp = Just "Example of a yes/no switch" }
test_resources/docs/yes-no/docs.txt view
@@ -1,57 +1,55 @@ AnyDocsAnd- [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = True- , setDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , setDocEnvVars = Just ("CONFIG_FILE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "FILE_PATH"- , setDocHelp = Just "Path to the configuration file"- }+ [ AnyDocsSingle Nothing , AnyDocsOr [ AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = True- , setDocTryOption = False- , setDocDasheds = [ DashedLong ('[' :| "no-]example") ]- , setDocEnvVars = Nothing- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "Example of a yes/no switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = True+ , setDocTryOption = False+ , setDocDasheds = [ DashedLong ('[' :| "no-]example") ]+ , setDocEnvVars = Nothing+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Just ("EXAMPLE" :| [])- , setDocConfKeys = Nothing- , setDocDefault = Nothing- , setDocMetavar = Just "BOOL"- , setDocHelp = Just "Example of a yes/no switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Just ("EXAMPLE" :| [])+ , setDocConfKeys = Nothing+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Just "BOOL"+ , setDocHelp = Just "Example of a yes/no switch"+ }) , AnyDocsSingle- SetDoc- { setDocTryArgument = False- , setDocTrySwitch = False- , setDocTryOption = False- , setDocDasheds = []- , setDocEnvVars = Nothing- , setDocConfKeys =- Just- (( "example" :| []- , AnyOfSchema (NullSchema :| [ BoolSchema ])- ) :|- [])- , setDocDefault = Nothing- , setDocMetavar = Nothing- , setDocHelp = Just "Example of a yes/no switch"- }+ (Just+ SetDoc+ { setDocTryArgument = False+ , setDocTrySwitch = False+ , setDocTryOption = False+ , setDocDasheds = []+ , setDocEnvVars = Nothing+ , setDocConfKeys =+ Just+ (( "example" :| []+ , AnyOfSchema (NullSchema :| [ BoolSchema ])+ ) :|+ [])+ , setDocDefault = Nothing+ , setDocExamples = []+ , setDocMetavar = Nothing+ , setDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing ] ]
test_resources/docs/yes-no/env-docs.txt view
@@ -1,8 +1,11 @@-AnyDocsSingle- ConfDoc- { confDocKeys =- ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|- []- , confDocDefault = Nothing- , confDocHelp = Just "Example of a yes/no switch"- }+AnyDocsOr+ [ AnyDocsSingle+ ConfDoc+ { confDocKeys =+ ( "example" :| [] , AnyOfSchema (NullSchema :| [ BoolSchema ]) ) :|+ []+ , confDocDefault = Nothing+ , confDocExamples = []+ , confDocHelp = Just "Example of a yes/no switch"+ }+ ]
test_resources/docs/yes-no/env.txt view
@@ -1,2 +1,1 @@- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m + [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m
test_resources/docs/yes-no/help.txt view
@@ -1,4 +1,4 @@-[36mUsage: [m[33myes-no[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--[no-]example[m[36m)[m+[36mUsage: [m[33myes-no[m [36m[[m[37m--[no-]example[m[36m][m yesNoSwitch example @@ -9,15 +9,10 @@ [34mOutput version information: 0.0.0[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- [34mExample of a yes/no switch[m switch: [37m--[no-]example[m env: [37mEXAMPLE[m [33mBOOL[m config: [37mexample[m: # [32mor null[m [33m<boolean>[m-
test_resources/docs/yes-no/man.txt view
@@ -7,7 +7,7 @@ .Sh VERSION 0.0.0 .Sh SYNOPSIS-yes-no (-h|--help) | --version | (--config-file FILE_PATH --[no-]example)+yes-no [--[no-]example] .Sh SETTINGS Show this help text switch: -h|--help@@ -15,10 +15,6 @@ Output version information: 0.0.0 switch: --version - Path to the configuration file- option: --config-file FILE_PATH- env: CONFIG_FILE FILE_PATH- Example of a yes/no switch switch: --[no-]example env: EXAMPLE BOOL@@ -26,16 +22,13 @@ example: # or null <boolean> - .Sh OPTIONS- -h|--help Show this help text - --version Output version information: 0.0.0 - --config-file Path to the configuration file - --[no-]example Example of a yes/no switch + -h|--help Show this help text + --version Output version information: 0.0.0+ --[no-]example Example of a yes/no switch .Sh ENVIRONMENT VARIABLES- CONFIG_FILE FILE_PATH Path to the configuration file- EXAMPLE BOOL Example of a yes/no switch + EXAMPLE BOOL Example of a yes/no switch .Sh CONFIGURATION VALUES Example of a yes/no switch
+ test_resources/docs/yes-no/nix-options.nix view
@@ -0,0 +1,8 @@+{ lib }:+{+ example = lib.mkOption {+ default = null;+ description = "Example of a yes/no switch";+ type = lib.types.nullOr lib.types.bool;+ };+}
test_resources/docs/yes-no/opt-docs.txt view
@@ -1,22 +1,16 @@-AnyDocsAnd+AnyDocsOr [ AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = False- , optDocTryOption = True- , optDocDasheds = [ DashedLong ('c' :| "onfig-file") ]- , optDocDefault = Nothing- , optDocMetavar = Just "FILE_PATH"- , optDocHelp = Just "Path to the configuration file"- }- , AnyDocsSingle- OptDoc- { optDocTryArgument = False- , optDocTrySwitch = True- , optDocTryOption = False- , optDocDasheds = [ DashedLong ('[' :| "no-]example") ]- , optDocDefault = Nothing- , optDocMetavar = Nothing- , optDocHelp = Just "Example of a yes/no switch"- }+ (Just+ OptDoc+ { optDocTryArgument = False+ , optDocTrySwitch = True+ , optDocTryOption = False+ , optDocDasheds = [ DashedLong ('[' :| "no-]example") ]+ , optDocDefault = Nothing+ , optDocExamples = []+ , optDocMetavar = Nothing+ , optDocHelp = Just "Example of a yes/no switch"+ })+ , AnyDocsSingle Nothing+ , AnyDocsSingle Nothing ]
test_resources/docs/yes-no/opt-long.txt view
@@ -1,4 +1,1 @@- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m--[no-]example[m [34mExample of a yes/no switch[m + [37m--[no-]example[m [34mExample of a yes/no switch[m
test_resources/docs/yes-no/opt-short.txt view
@@ -1,1 +1,1 @@-[33myes-no[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--[no-]example[m[36m)[m+[33myes-no[m [36m[[m[37m--[no-]example[m[36m][m
test_resources/docs/yes-no/reference.txt view
@@ -1,16 +1,12 @@-[36mUsage: [m[33myes-no[m [36m([m[37m-h[m[36m|[m[37m--help[m[36m)[m [36m|[m [37m--version[m [36m|[m [36m([m[37m--config-file[m [33mFILE_PATH[m [37m--[no-]example[m[36m)[m+[36mUsage: [m[33myes-no[m [36m[[m[37m--[no-]example[m[36m][m [36mAll settings[m: [34mShow this help text[m switch: [37m-h[m[36m|[m[37m--help[m - [34mOutput version information: 0.0.0[m+ [34mOutput version information[m switch: [37m--version[m - [34mPath to the configuration file[m- option: [37m--config-file[m [33mFILE_PATH[m- env: [37mCONFIG_FILE[m [33mFILE_PATH[m- [34mExample of a yes/no switch[m switch: [37m--[no-]example[m env: [37mEXAMPLE[m [33mBOOL[m@@ -18,16 +14,13 @@ [37mexample[m: # [32mor null[m [33m<boolean>[m - [36mOptions[m:- [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m - [37m--version[m [34mOutput version information: 0.0.0[m - [37m--config-file[m [34mPath to the configuration file[m - [37m--[no-]example[m [34mExample of a yes/no switch[m + [37m-h[m[36m|[m[37m--help[m [34mShow this help text[m + [37m--version[m [34mOutput version information[m+ [37m--[no-]example[m [34mExample of a yes/no switch[m [36mEnvironment Variables[m:- [37mCONFIG_FILE[m [33mFILE_PATH[m [34mPath to the configuration file[m- [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m + [37mEXAMPLE[m [33mBOOL[m [34mExample of a yes/no switch[m [36mConfiguration Values[m: [34mExample of a yes/no switch[m
test_resources/docs/yes-no/show.txt view
@@ -1,28 +1,7 @@ WithConfig _- (Check- Nothing- False- _- (Alt- (Check- Nothing- False- _- (Setting- Nothing- (Setting- [ DashedLong ('c' :| "onfig-file") ]- [ _ ]- False- Nothing- True- (Just ("CONFIG_FILE" :| []))- Nothing- Nothing- (Just "FILE_PATH")- (Just "Path to the configuration file"))))- (Check Nothing False _ (Pure _))))+ Nothing+ (Pure _) (Alt (Check Nothing@@ -110,13 +89,13 @@ False Nothing (Just- [ ( "example" :| []- , BimapCodec- _- _- (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing))- )- ])+ (ConfigValSetting+ ("example" :| [])+ BimapCodec+ _+ _+ (EitherCodec PossiblyJointUnion NullCodec (BoolCodec Nothing)) :|+ [])) Nothing Nothing (Just "Example of a yes/no switch"))))
test_resources/error/all-or-nothing-relevant.txt view
@@ -1,3 +1,5 @@-Missing option: [37m--bar[m [34mThis one will not exist[m +Missing option: [37m--bar[m [34mThis one will not exist[m You are seeing this error because at least one, but not all, of the settings in an allOrNothing (or subSettings) parser have been defined.+The following settings have been parsed:+[36mtest/OptEnvConf/ErrorSpec.hs:153:21 in main:OptEnvConf.ErrorSpec[m Hit the 'empty' case of the Parser type, this should not happen.
test_resources/error/all-or-nothing.txt view
@@ -1,2 +1,4 @@-Missing option: [37m--bar[m [34mThis one will not exist[m +Missing option: [37m--bar[m [34mThis one will not exist[m You are seeing this error because at least one, but not all, of the settings in an allOrNothing (or subSettings) parser have been defined.+The following settings have been parsed:+[36mtest/OptEnvConf/ErrorSpec.hs:141:19 in main:OptEnvConf.ErrorSpec[m
+ test_resources/error/leftover-argument.txt view
@@ -0,0 +1,1 @@+Unrecognised args: foo bar
+ test_resources/error/leftover-option.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --key val
+ test_resources/error/leftover-switch.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --switch
test_resources/error/missing-argument.txt view
@@ -1,1 +1,1 @@-Missing argument: [33mARGUMENT[m [34mexample argument[m +Missing argument: [33mARGUMENT[m [34mexample argument[m
test_resources/error/missing-option.txt view
@@ -1,1 +1,1 @@-Missing option: [37m--foo[m [34mexample option[m +Missing option: [37m--foo[m [34mexample option[m
test_resources/error/missing-options.txt view
@@ -1,2 +1,2 @@-Missing option: [37m--foo[m [34mexample option 1[m -Missing option: [37m--bar[m [34mexample option 2[m +Missing option: [37m--foo[m [34mexample option 1[m+Missing option: [37m--bar[m [34mexample option 2[m
test_resources/error/read-int-argument.txt view
@@ -1,3 +1,3 @@ Failed to read argument: -[33mINT[m [34minteger option[m +[33mINT[m [34minteger option[m Un-Read-able value: "five"
test_resources/error/read-int-option.txt view
@@ -1,3 +1,3 @@ Failed to read option: -[37m--num[m [34minteger option[m +[37m--num[m [34minteger option[m Un-Read-able value: "five"
test_resources/error/read-int-options.txt view
@@ -1,6 +1,6 @@ Failed to read option: -[37m--foo[m [34minteger option 1[m +[37m--foo[m [34minteger option 1[m Un-Read-able value: "n" Failed to read option: -[37m--bar[m [34minteger option 2[m +[37m--bar[m [34minteger option 2[m Un-Read-able value: "m"
test_resources/error/required-command.txt view
@@ -1,2 +1,3 @@ Missing command, available commands:-[33mone[m [33mtwo[m+[35mone[m: [34mfirst[m+[35mtwo[m: [34msecond[m
test_resources/error/some-none.txt view
@@ -1,1 +1,1 @@-Missing argument: [33mMETAVAR[m [31mundocumented[m +Missing argument: [33mMETAVAR[m [31mundocumented[m
+ test_resources/error/typo-option.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --baz arg
+ test_resources/error/typo-switch.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --baz
test_resources/error/unfolding-tombstone-option.txt view
@@ -1,1 +1,1 @@-Missing option: [37m-b[m [31mundocumented[m +Missing option: [37m-b[m [31mundocumented[m
test_resources/error/unfolding-tombstone-switch.txt view
@@ -1,1 +1,1 @@-Missing option: [37m-f[m [31mundocumented[m +Missing option: [37m-f[m [31mundocumented[m
+ test_resources/error/unrecognised-arg.txt view
@@ -0,0 +1,1 @@+Unrecognised args: arg
test_resources/error/unrecognised-command.txt view
@@ -1,3 +1,4 @@ [31mUnrecognised command: [m[33mthree[m [34mavailable commands:[m-[33mone[m [33mtwo[m+[35mone[m: [34mfirst[m+[35mtwo[m: [34msecond[m
+ test_resources/error/unrecognised-option.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --foo bar
+ test_resources/error/unrecognised-switch.txt view
@@ -0,0 +1,1 @@+Unrecognised args: --foo
+ test_resources/help/create.txt view
@@ -0,0 +1,11 @@+[36mUsage: [m[33mexample create[m [33mSTR[m++create command explanation++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mThe item to create[m+ argument: [33mSTR[m+
+ test_resources/help/read.txt view
@@ -0,0 +1,8 @@+[36mUsage: [m[33mexample read[m ++read command explanation++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m+
+ test_resources/help/sub-bar.txt view
@@ -0,0 +1,8 @@+[36mUsage: [m[33mexample sub bar[m ++bar explanation++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m+
+ test_resources/help/sub-foo.txt view
@@ -0,0 +1,8 @@+[36mUsage: [m[33mexample sub foo[m ++foo explanation++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m+
+ test_resources/help/sub.txt view
@@ -0,0 +1,12 @@+[36mUsage: [m[33mexample sub[m COMMAND++command with subcommand++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++[36mAvailable commands[m:+ [35mfoo[m [34mfoo explanation[m+ [35mbar[m [34mbar explanation[m+
+ test_resources/help/toplevel-pure-with-invalid-port.txt view
@@ -0,0 +1,57 @@+[36mUsage: [m[33mexample[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--port[m [33mPORT[m[36m][m [36m[[m[37m--log-level[m [33mLOG_LEVEL[m[36m][m [36m[[m[37m--payment-public-key[m [33mPUBLIC_KEY[m [37m--payment-secret-key[m [33mFILE_PATH[m [36m[[m[37m--payment-currency[m [33mCURRENCY[m[36m][m[36m][m COMMAND++example program description++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mPath to the configuration file[m+ option: [37m--config-file[m [33mFILE_PATH[m+ env: [37mCONFIG_FILE[m [33mFILE_PATH[m++ [34mport to serve requests on[m+ option: [37m--port[m [33mPORT[m+ env: [37mPORT[m [33mPORT[m+ config:+ [37mport[m: # [32mor null[m+ [33m<integer>[m # [32m16 bit unsigned integer[m+ default: [33m8080[m++ [34mminimal severity of log messages[m+ option: [37m--log-level[m [33mLOG_LEVEL[m+ env: [37mLOG_LEVEL[m [33mLOG_LEVEL[m+ config:+ [37mlog-level[m: # [32mor null[m+ [33m<string>[m+ default: [33m"DEBUG"[m++ [34mPublic key[m+ option: [37m--payment-public-key[m [33mPUBLIC_KEY[m+ env: [37mPAYMENT_PUBLIC_KEY[m [33mPUBLIC_KEY[m+ config:+ [37mpayment.public-key[m: # [32mor null[m+ [33m<string>[m++ [34mSecret key[m+ option: [37m--payment-secret-key[m [33mFILE_PATH[m+ env: [37mPAYMENT_SECRET_KEY[m [33mFILE_PATH[m+ config:+ [37mpayment.secret-key[m: # [32mor null[m+ [33m<string>[m++ [34mCurrency[m+ option: [37m--payment-currency[m [33mCURRENCY[m+ env: [37mPAYMENT_CURRENCY[m [33mCURRENCY[m+ config:+ [37mpayment.currency[m: # [32mor null[m+ [33m<string>[m++[36mAvailable commands[m:+ [35mread[m [34mread command explanation[m + [35mcreate[m [34mcreate command explanation[m+ [35msub[m [34mcommand with subcommand[m +
+ test_resources/help/toplevel-pure.txt view
@@ -0,0 +1,57 @@+[36mUsage: [m[33mexample[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--port[m [33mPORT[m[36m][m [36m[[m[37m--log-level[m [33mLOG_LEVEL[m[36m][m [36m[[m[37m--payment-public-key[m [33mPUBLIC_KEY[m [37m--payment-secret-key[m [33mFILE_PATH[m [36m[[m[37m--payment-currency[m [33mCURRENCY[m[36m][m[36m][m COMMAND++example program description++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mPath to the configuration file[m+ option: [37m--config-file[m [33mFILE_PATH[m+ env: [37mCONFIG_FILE[m [33mFILE_PATH[m++ [34mport to serve requests on[m+ option: [37m--port[m [33mPORT[m+ env: [37mPORT[m [33mPORT[m+ config:+ [37mport[m: # [32mor null[m+ [33m<integer>[m # [32m16 bit unsigned integer[m+ default: [33m8080[m++ [34mminimal severity of log messages[m+ option: [37m--log-level[m [33mLOG_LEVEL[m+ env: [37mLOG_LEVEL[m [33mLOG_LEVEL[m+ config:+ [37mlog-level[m: # [32mor null[m+ [33m<string>[m+ default: [33m"DEBUG"[m++ [34mPublic key[m+ option: [37m--payment-public-key[m [33mPUBLIC_KEY[m+ env: [37mPAYMENT_PUBLIC_KEY[m [33mPUBLIC_KEY[m+ config:+ [37mpayment.public-key[m: # [32mor null[m+ [33m<string>[m++ [34mSecret key[m+ option: [37m--payment-secret-key[m [33mFILE_PATH[m+ env: [37mPAYMENT_SECRET_KEY[m [33mFILE_PATH[m+ config:+ [37mpayment.secret-key[m: # [32mor null[m+ [33m<string>[m++ [34mCurrency[m+ option: [37m--payment-currency[m [33mCURRENCY[m+ env: [37mPAYMENT_CURRENCY[m [33mCURRENCY[m+ config:+ [37mpayment.currency[m: # [32mor null[m+ [33m<string>[m++[36mAvailable commands[m:+ [35mread[m [34mread command explanation[m + [35mcreate[m [34mcreate command explanation[m+ [35msub[m [34mcommand with subcommand[m +
+ test_resources/help/wrong-command.txt view
@@ -0,0 +1,57 @@+[36mUsage: [m[33mexample[m [36m[[m[37m--config-file[m [33mFILE_PATH[m[36m][m [36m[[m[37m--port[m [33mPORT[m[36m][m [36m[[m[37m--log-level[m [33mLOG_LEVEL[m[36m][m [36m[[m[37m--payment-public-key[m [33mPUBLIC_KEY[m [37m--payment-secret-key[m [33mFILE_PATH[m [36m[[m[37m--payment-currency[m [33mCURRENCY[m[36m][m[36m][m COMMAND++example program description++[36mAvailable settings[m:+ [34mShow this help text[m+ switch: [37m-h[m[36m|[m[37m--help[m++ [34mOutput version information: 0.0.0[m+ switch: [37m--version[m++ [34mPath to the configuration file[m+ option: [37m--config-file[m [33mFILE_PATH[m+ env: [37mCONFIG_FILE[m [33mFILE_PATH[m++ [34mport to serve requests on[m+ option: [37m--port[m [33mPORT[m+ env: [37mPORT[m [33mPORT[m+ config:+ [37mport[m: # [32mor null[m+ [33m<integer>[m # [32m16 bit unsigned integer[m+ default: [33m8080[m++ [34mminimal severity of log messages[m+ option: [37m--log-level[m [33mLOG_LEVEL[m+ env: [37mLOG_LEVEL[m [33mLOG_LEVEL[m+ config:+ [37mlog-level[m: # [32mor null[m+ [33m<string>[m+ default: [33m"DEBUG"[m++ [34mPublic key[m+ option: [37m--payment-public-key[m [33mPUBLIC_KEY[m+ env: [37mPAYMENT_PUBLIC_KEY[m [33mPUBLIC_KEY[m+ config:+ [37mpayment.public-key[m: # [32mor null[m+ [33m<string>[m++ [34mSecret key[m+ option: [37m--payment-secret-key[m [33mFILE_PATH[m+ env: [37mPAYMENT_SECRET_KEY[m [33mFILE_PATH[m+ config:+ [37mpayment.secret-key[m: # [32mor null[m+ [33m<string>[m++ [34mCurrency[m+ option: [37m--payment-currency[m [33mCURRENCY[m+ env: [37mPAYMENT_CURRENCY[m [33mCURRENCY[m+ config:+ [37mpayment.currency[m: # [32mor null[m+ [33m<string>[m++[36mAvailable commands[m:+ [35mread[m [34mread command explanation[m + [35mcreate[m [34mcreate command explanation[m+ [35msub[m [34mcommand with subcommand[m +
test_resources/lint/config-without-load.txt view
@@ -1,5 +1,6 @@ [31mSetting parser is invalid:[m [31mInvalid Setting:[m- [33mconf[m was called with no way to load configuration.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:120:7 in main:OptEnvConf.LintSpec[m+ [33mconf[m or [33mname[m was called with no way to load configuration.+ You can load configuration with [33mwithConfig[m, or explicitly not load any configuration with [33mwithoutConfig[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:124:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/dash-in-long.txt view
@@ -4,4 +4,4 @@ [33mlong[m may not start with a '-'. Found [33mlong[m "--switch". Try [33mlong[m "switch" instead.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:40:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:33:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/dash-in-short.txt view
@@ -3,4 +3,4 @@ [31mInvalid Setting:[m [33mshort[m may not contain a '-'. Found [33mshort[m '-'.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:32:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:25:7 in main:OptEnvConf.LintSpec[m
+ test_resources/lint/many-conf.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mmany[m or [33msome[m was called with a parser that may succeed without consuming anything.+ This is not allowed because the parser would run infinitely.
+ test_resources/lint/many-env.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mmany[m or [33msome[m was called with a parser that may succeed without consuming anything.+ This is not allowed because the parser would run infinitely.
test_resources/lint/no-commands.txt view
@@ -2,4 +2,4 @@ [31mInvalid Setting:[m [33mcommands[m was called with an empty list.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:117:6 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:121:6 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-dashed-for-option.txt view
@@ -2,4 +2,4 @@ [31mInvalid Setting:[m [33moption[m has no [33mlong[m or [33mshort[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:74:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:67:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-dashed-for-switch.txt view
@@ -2,4 +2,4 @@ [31mInvalid Setting:[m [33mswitch[m has no [33mlong[m or [33mshort[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:94:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:98:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-metavar-for-argument.txt view
@@ -2,4 +2,4 @@ [31mInvalid Setting:[m [33margument[m has no [33mmetavar[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:56:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:49:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-metavar-for-env.txt view
@@ -1,5 +1,5 @@ [31mSetting parser is invalid:[m [31mInvalid Setting:[m- [33menv[m has no [33mmetavar[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:108:7 in main:OptEnvConf.LintSpec[m+ [33menv[m or [33mname[m has no [33mmetavar[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:112:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-metavar-for-option.txt view
@@ -1,5 +1,5 @@ [31mSetting parser is invalid:[m [31mInvalid Setting:[m- [33moption[m has no [33mmetavar[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:84:7 in main:OptEnvConf.LintSpec[m+ [33moption[m or [33mname[m has no [33mmetavar[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:88:7 in main:OptEnvConf.LintSpec[m
+ test_resources/lint/no-option-or-switch-for-dashed.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mlong[m or [33mshort[m has no [33moption[m or [33mswitch[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:77:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-reader-for-argument.txt view
@@ -2,4 +2,4 @@ [31mInvalid Setting:[m [33margument[m has no [33mreader[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:48:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:41:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-reader-for-env.txt view
@@ -1,9 +1,9 @@ [31mSetting parser is invalid:[m [31mInvalid Setting:[m- [33menv[m has no [33mreader[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:101:7 in main:OptEnvConf.LintSpec[m+ [33menv[m or [33mname[m has no [33mreader[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:105:7 in main:OptEnvConf.LintSpec[m [31mInvalid Setting:[m- [33menv[m has no [33mmetavar[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:101:7 in main:OptEnvConf.LintSpec[m+ [33menv[m or [33mname[m has no [33mmetavar[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:105:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/no-reader-for-option.txt view
@@ -1,5 +1,5 @@ [31mSetting parser is invalid:[m [31mInvalid Setting:[m- [33moption[m has no [33mreader[m.- Defined at: [36mtest/OptEnvConf/LintSpec.hs:65:7 in main:OptEnvConf.LintSpec[m+ [33moption[m or [33mname[m has no [33mreader[m.+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:58:7 in main:OptEnvConf.LintSpec[m
+ test_resources/lint/some-conf.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mmany[m or [33msome[m was called with a parser that may succeed without consuming anything.+ This is not allowed because the parser would run infinitely.
+ test_resources/lint/some-env.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mmany[m or [33msome[m was called with a parser that may succeed without consuming anything.+ This is not allowed because the parser would run infinitely.
+ test_resources/lint/unknown-default-command.txt view
@@ -0,0 +1,5 @@+[31mSetting parser is invalid:[m+ + [31mInvalid Setting:[m+ [33mdefaultCommand[m was called with an unknown command: [35mb[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:185:7 in main:OptEnvConf.LintSpec[m
test_resources/lint/unreadable-example.txt view
@@ -3,4 +3,4 @@ [31mInvalid Setting:[m [33mexample[m was called with an example that none of the [33mreader[ms succeed in reading. Example: NaN- Defined at: [36mtest/OptEnvConf/LintSpec.hs:128:7 in main:OptEnvConf.LintSpec[m+ Defined at: [36mtest/OptEnvConf/LintSpec.hs:132:7 in main:OptEnvConf.LintSpec[m