summaryrefslogtreecommitdiff
path: root/src/SlackBuilder/CommandLine.hs
blob: e06a40eaee5993c84b3d8a7f6b734001640075d1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{- 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/. -}

-- | Command line parser.
module SlackBuilder.CommandLine
    ( SlackBuilderCommand(..)
    , slackBuilderParser
    ) where

import Data.Text (Text)
import Options.Applicative
    ( Parser
    , ParserInfo(..)
    , metavar
    , argument
    , str
    , info
    , fullDesc
    , subparser
    , command
    , optional
    )

data SlackBuilderCommand
    = CheckCommand
    | Up2DateCommand (Maybe Text)

slackBuilderParser :: ParserInfo SlackBuilderCommand
slackBuilderParser = info slackBuilderCommand fullDesc

slackBuilderCommand :: Parser SlackBuilderCommand
slackBuilderCommand = subparser
    $ command "check" (info checkCommand mempty)
    <> command "up2date" (info up2DateCommand mempty)
  where
    checkCommand = pure CheckCommand
    up2DateCommand = Up2DateCommand
        <$> optional (argument str (metavar "PKGNAM"))