packages feed

mdoc-0.4.1.2: src/Mdoc/Examples/Docker.hs

module Mdoc.Examples.Docker
  ( docker1
  ) where

import Mdoc.Prelude

import Mdoc
import OptEnvConf hiding (name)
import OptEnvConf.Mdoc

docker1 :: Named
docker1 = getPage dockerOpt & name "docker" "a self-sufficient runtime for containers"

{- FOURMOLU_DISABLE -}
dockerOpt :: Parser ()
dockerOpt = void $ (,,,,,,,,,,,,)
  <$>           option' [           long "config",    metavar "string", help "Location of client config files", value "~/.docker"]
  <*> optional (option' [short 'c', long "context",   metavar "string", help "Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with \"docker context use\")"])
  <*>           switch' [short 'D', long "debug",                       help "Enable debug mode"]
  <*> optional (option' [short 'H', long "host",      metavar "string", help "Daemon socket to connect to"])
  <*>           option' [short 'l', long "log-level", metavar "string", help "Set the logging level (\"debug\", \"info\", \"warn\", \"error\", \"fatal\")", value "info"]
  <*>           switch' [           long "tls",                         help "Use TLS; implied by --tlsverify"]
  <*>           option' [           long "tlscacert", metavar "string", help "Trust certs signed only by this CA", value "~/.docker/ca.pem"]
  <*>           option' [           long "tlscert",   metavar "string", help "Path to TLS certificate file", value "~/.docker/cert.pem"]
  <*>           option' [           long "tlskey",    metavar "string", help "Path to TLS key file", value "~/.docker/key.pem"]
  <*>           switch' [           long "tlsverify",                   help "Use TLS and verify the remote"]
  <*>           switch' [short 'v', long "version",                     help "Print version information and quit"]
  <*> commands
    [ command "run"  "Create and run a new container from an image" runOpt
    ]

runOpt :: Parser ()
runOpt = void $ (,,,)
  <$> optional (option'   [short 'a', long "attach", metavar "list", help "Attach to STDIN, STDOUT or STDERR"])
  <*>           argument' [                          metavar "IMAGE"]
  <*> optional (argument' [                          metavar "COMMAND"])
  <*>     many (argument' [                          metavar "ARG"])
{- FOURMOLU_ENABLE -}

option' :: [Builder Text] -> Parser Text
option' xs = setting $ [option, reader str] <> xs

argument' :: [Builder Text] -> Parser Text
argument' xs = setting $ [argument, reader str] <> xs

switch' :: [Builder Bool] -> Parser Bool
switch' xs = setting $ [switch True, value False] <> xs