diff options
| author | Eugen Wissner <belka@caraus.de> | 2023-08-06 14:25:19 +0200 |
|---|---|---|
| committer | Eugen Wissner <belka@caraus.de> | 2023-08-06 14:25:19 +0200 |
| commit | 69ba04a7314aa5750a5fedbb9533cf775486870f (patch) | |
| tree | 2d9f88b4020b8e3136494074dceb5e48c9828591 /app/SlackBuilder/CommandLine.hs | |
| parent | 028f64d25a93e0430f22240024e255eec12bfb09 (diff) | |
| download | slackbuilder-69ba04a7314aa5750a5fedbb9533cf775486870f.tar.gz | |
Move text URL check to the Haskell binary
Diffstat (limited to 'app/SlackBuilder/CommandLine.hs')
| -rw-r--r-- | app/SlackBuilder/CommandLine.hs | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/app/SlackBuilder/CommandLine.hs b/app/SlackBuilder/CommandLine.hs new file mode 100644 index 0000000..2459bb5 --- /dev/null +++ b/app/SlackBuilder/CommandLine.hs @@ -0,0 +1,46 @@ +module SlackBuilder.CommandLine + ( SlackBuilderCommand(..) + , PackagistArguments(..) + , TextArguments(..) + , slackBuilderParser + ) where + +import Data.Text (Text) +import Options.Applicative + ( Parser + , ParserInfo(..) + , metavar + , argument + , str + , info + , fullDesc + , subparser + , command + ) + +data SlackBuilderCommand + = PackagistCommand PackagistArguments + | TextCommand TextArguments + +data PackagistArguments = PackagistArguments + { vendor :: Text + , name :: Text + } deriving (Eq, Show) + +newtype TextArguments = TextArguments Text + +packagistArguments :: Parser PackagistArguments +packagistArguments = PackagistArguments + <$> argument str (metavar "VENDOR") + <*> argument str (metavar"NAME") + +textArguments :: Parser TextArguments +textArguments = TextArguments <$> argument str (metavar "URL") + +slackBuilderParser :: ParserInfo SlackBuilderCommand +slackBuilderParser = info slackBuilderCommand fullDesc + +slackBuilderCommand :: Parser SlackBuilderCommand +slackBuilderCommand = subparser + $ command "packagist" (info (PackagistCommand <$> packagistArguments) mempty) + <> command "text" (info (TextCommand <$> textArguments) mempty) |
