on master help sign in
hext/src/Control/Hext/Arguments.hs
50 lines 1.1 kB history raw
1{-# LANGUAGE DeriveAnyClass #-}
2{-# LANGUAGE DeriveGeneric #-}
3{-# LANGUAGE LambdaCase #-}
4{-# LANGUAGE NoImplicitPrelude #-}
5{-# LANGUAGE OverloadedStrings #-}
6{-# LANGUAGE RecordWildCards #-}
7{-# LANGUAGE ScopedTypeVariables #-}
8{-# LANGUAGE TypeApplications #-}
10module Control.Hext.Arguments
11 ( parseOptions,
12 Options (..),
13 )
14where
16import Options.Applicative
17import Relude
19parseOptions :: IO Options
20parseOptions =
21 execParser $
22 info
23 (Options <$> activeDirectoryArgument <*> extensionsFilePath)
24 ( fullDesc
25 <> progDesc "Add GHC extensions to source files automatically."
26 )
28data Options
29 = Options
30 { activeDirectory :: Maybe FilePath,
31 extensionsPath :: FilePath
32 }
34activeDirectoryArgument :: Parser (Maybe FilePath)
35activeDirectoryArgument =
36 argument
37 (maybeReader $ (Just . Just))
38 ( help "The directiry to scan for .hs files."
39 <> value Nothing
40 )
42extensionsFilePath :: Parser FilePath
43extensionsFilePath =
44 option
45 auto
46 ( short 'i'
47 <> long "input"
48 <> help "The input yaml file with extensions."
49 <> value ".hext.yaml"
50 )