72 lines
2.0 KiB
Haskell
72 lines
2.0 KiB
Haskell
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,
|
|
)
|
|
|
|
data SlackBuilderCommand
|
|
= CategoryCommand Text
|
|
| ExistsCommand Text
|
|
| DownloadCommand Text String
|
|
| CloneCommand Text Text Text
|
|
| DownloadAndDeployCommand Text Text
|
|
| Up2DateCommand
|
|
|
|
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 "exists" (info existsCommand mempty)
|
|
<> command "download" (info downloadCommand mempty)
|
|
<> command "clone" (info cloneCommand mempty)
|
|
<> command "deploy" (info deployCommand mempty)
|
|
<> command "up2date" (info up2DateCommand mempty)
|
|
where
|
|
categoryCommand = CategoryCommand
|
|
<$> argument str (metavar "PKGNAM")
|
|
existsCommand = ExistsCommand <$> argument str (metavar "PATH")
|
|
downloadCommand = DownloadCommand
|
|
<$> argument str (metavar "URI")
|
|
<*> argument str (metavar "TARGET")
|
|
cloneCommand = CloneCommand
|
|
<$> argument str (metavar "REPO")
|
|
<*> argument str (metavar "TARBALL")
|
|
<*> argument str (metavar "TAG_PREFIX")
|
|
deployCommand = DownloadAndDeployCommand
|
|
<$> argument str (metavar "URI")
|
|
<*> argument str (metavar "TARBALL")
|
|
up2DateCommand = pure Up2DateCommand
|