2023-08-06 14:25:19 +02:00
|
|
|
module SlackBuilder.CommandLine
|
2023-08-09 20:59:42 +02:00
|
|
|
( GhArguments(..)
|
|
|
|
, SlackBuilderCommand(..)
|
2023-08-06 14:25:19 +02:00
|
|
|
, 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,
|
2023-08-06 14:25:19 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
data SlackBuilderCommand
|
2023-10-20 19:23:21 +02:00
|
|
|
= CategoryCommand Text
|
2023-08-17 22:07:09 +02:00
|
|
|
| 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
|
2023-08-06 14:25:19 +02:00
|
|
|
|
|
|
|
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)
|
|
|
|
|
2023-10-20 15:53:48 +02:00
|
|
|
data TextArguments = TextArguments
|
|
|
|
{ versionPicker :: Text -> Text
|
|
|
|
, textURL :: Text
|
|
|
|
}
|
2023-08-06 14:25:19 +02:00
|
|
|
|
|
|
|
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)
|
2023-08-17 22:07:09 +02:00
|
|
|
<> 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")
|
2023-08-17 22:07:09 +02:00
|
|
|
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
|