slackbuilder/app/SlackBuilder/CommandLine.hs

72 lines
2.0 KiB
Haskell
Raw Normal View History

module SlackBuilder.CommandLine
2023-08-09 20:59:42 +02:00
( GhArguments(..)
, SlackBuilderCommand(..)
, PackagistArguments(..)
, TextArguments(..)
, slackBuilderParser
) where
import Data.Text (Text)
import Options.Applicative
( Parser
, ParserInfo(..)
, metavar
, argument
, str
, info
, fullDesc
, subparser
2023-10-13 19:34:02 +02:00
, command,
)
data SlackBuilderCommand
2023-10-20 19:23:21 +02:00
= CategoryCommand Text
| ExistsCommand Text
2023-08-21 13:38:20 +02:00
| DownloadCommand Text String
2023-08-25 10:30:24 +02:00
| CloneCommand Text Text Text
2023-08-28 21:05:47 +02:00
| DownloadAndDeployCommand Text Text
2023-09-03 10:26:43 +02:00
| Up2DateCommand
data PackagistArguments = PackagistArguments
{ vendor :: Text
, name :: Text
} deriving (Eq, Show)
2023-08-09 20:59:42 +02:00
data GhArguments = GhArguments
{ owner :: Text
, name :: Text
2023-08-10 12:47:43 +02:00
, transform :: Maybe Text
2023-08-09 20:59:42 +02:00
} deriving (Eq, Show)
data TextArguments = TextArguments
{ versionPicker :: Text -> Text
, textURL :: Text
}
slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc
slackBuilderCommand :: Parser SlackBuilderCommand
slackBuilderCommand = subparser
2023-10-20 19:23:21 +02:00
$ command "category" (info categoryCommand mempty)
<> command "exists" (info existsCommand mempty)
2023-08-21 13:38:20 +02:00
<> command "download" (info downloadCommand mempty)
2023-08-25 10:30:24 +02:00
<> command "clone" (info cloneCommand mempty)
2023-08-28 21:05:47 +02:00
<> command "deploy" (info deployCommand mempty)
2023-09-03 10:26:43 +02:00
<> command "up2date" (info up2DateCommand mempty)
2023-08-15 10:33:19 +02:00
where
2023-10-20 19:23:21 +02:00
categoryCommand = CategoryCommand
<$> argument str (metavar "PKGNAM")
existsCommand = ExistsCommand <$> argument str (metavar "PATH")
2023-08-21 13:38:20 +02:00
downloadCommand = DownloadCommand
<$> argument str (metavar "URI")
<*> argument str (metavar "TARGET")
2023-08-25 10:30:24 +02:00
cloneCommand = CloneCommand
<$> argument str (metavar "REPO")
<*> argument str (metavar "TARBALL")
<*> argument str (metavar "TAG_PREFIX")
2023-08-28 21:05:47 +02:00
deployCommand = DownloadAndDeployCommand
<$> argument str (metavar "URI")
<*> argument str (metavar "TARBALL")
2023-09-03 10:26:43 +02:00
up2DateCommand = pure Up2DateCommand