aboutsummaryrefslogtreecommitdiff
path: root/locopy/Locopy/CommandLine.hs
blob: 0146cc9e2d234ebfde09f11e0d855c5c0daf81b5 (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
40
41
42
43
44
{- 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/. -}

module Locopy.CommandLine
    ( CommandLine(..)
    , Wordpress(..)
    , commandLine
    ) where

import Options.Applicative
    ( Parser
    , ParserInfo(..)
    , command
    , header
    , help
    , hsubparser
    , idm
    , info
    , long
    , metavar
    , strOption
    )

data Wordpress = Wordpress
    { root :: FilePath
    , siteurl :: String
    }

newtype CommandLine
    = WordpressCommand Wordpress

wordpress :: Parser CommandLine
wordpress = fmap WordpressCommand
    $ Wordpress
    <$> strOption (long "root" <> metavar "ROOT" <> help "Website configuration directory")
    <*> strOption (long "siteurl" <> metavar "HOME" <> help "siteurl and home address")

commandLine :: ParserInfo CommandLine
commandLine = info subcommand (header "locopy (wordpress) [OPTIONS]")
  where
    subcommand = hsubparser
        ( command "wordpress" (info wordpress idm)
        )