slackbuilder/src/SlackBuilder/CommandLine.hs
Eugen Wissner 34d7dbd68f
All checks were successful
Build / audit (push) Successful in 14m48s
Build / test (push) Successful in 15m54s
Add license information to all files
2023-12-23 22:15:10 +01:00

61 lines
1.5 KiB
Haskell

{- This Source Code Form is subject to the terms of the Mozilla Public License,
v. 2.0. If a copy of the MPL was not distributed with this file, You can
obtain one at https://mozilla.org/MPL/2.0/. -}
module SlackBuilder.CommandLine
( GhArguments(..)
, SlackBuilderCommand(..)
, PackagistArguments(..)
, TextArguments(..)
, slackBuilderParser
) where
import Data.Text (Text)
import Options.Applicative
( Parser
, ParserInfo(..)
, metavar
, argument
, str
, info
, fullDesc
, subparser
, command
, optional
)
data SlackBuilderCommand
= CategoryCommand
| CheckCommand
| Up2DateCommand (Maybe Text)
data PackagistArguments = PackagistArguments
{ vendor :: Text
, name :: Text
} deriving (Eq, Show)
data GhArguments = GhArguments
{ owner :: Text
, name :: Text
, transform :: Maybe Text
} deriving (Eq, Show)
data TextArguments = TextArguments
{ versionPicker :: Text -> Text
, textURL :: Text
}
slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc
slackBuilderCommand :: Parser SlackBuilderCommand
slackBuilderCommand = subparser
$ command "category" (info categoryCommand mempty)
<> command "check" (info checkCommand mempty)
<> command "up2date" (info up2DateCommand mempty)
where
categoryCommand = pure CategoryCommand
checkCommand = pure CheckCommand
up2DateCommand = Up2DateCommand
<$> optional (argument str (metavar "PKGNAM"))