on master help sign in
Drop ‘yaml’ configuration
c201862mrkkrp
app/Main.hs+2−16
@@ -15,21 +15,15 @@ import Paths_ormolu (version)
15import System.Exit (ExitCode (..), exitWith)
15import System.Exit (ExitCode (..), exitWith)
16import System.IO (hPutStrLn, stderr)
16import System.IO (hPutStrLn, stderr)
17import qualified Data.Text.IO as TIO
17import qualified Data.Text.IO as TIO
18−import qualified Data.Yaml as Yaml
19
18
20-- | Entry point of the program.
19-- | Entry point of the program.
21
20
22main :: IO ()
21main :: IO ()
23main = withPrettyOrmoluExceptions $ do
22main = withPrettyOrmoluExceptions $ do
24 Opts {..} <- execParser optsParserInfo
23 Opts {..} <- execParser optsParserInfo
25− config <- case optConfigFile of
26− Nothing -> return optConfig
27− Just path -> do
28− config <- Yaml.decodeFileThrow path
29− return (config <> optConfig)
30 r <- case optInputFile of
24 r <- case optInputFile of
31− "-" -> ormoluStdin config
25+ "-" -> ormoluStdin optConfig
32− inputFile -> ormoluFile config inputFile
26+ inputFile -> ormoluFile optConfig inputFile
33 let notForStdin = do
27 let notForStdin = do
34 when (optInputFile == "-") $ do
28 when (optInputFile == "-") $ do
35 hPutStrLn
29 hPutStrLn
@@ -58,8 +52,6 @@ main = withPrettyOrmoluExceptions $ do
58data Opts = Opts
52data Opts = Opts
59 { optMode :: !Mode
53 { optMode :: !Mode
60 -- ^ Mode of operation
54 -- ^ Mode of operation
61− , optConfigFile :: !(Maybe FilePath)
62− -- ^ Location of configuration file (optional)
63 , optConfig :: !Config
55 , optConfig :: !Config
64 -- ^ Ormolu 'Config'
56 -- ^ Ormolu 'Config'
65 , optInputFile :: !FilePath
57 , optInputFile :: !FilePath
@@ -107,12 +99,6 @@ optsParser = Opts
107 , value Stdout
99 , value Stdout
108 , help "Mode of operation: 'stdout', 'inplace', or 'check'"
100 , help "Mode of operation: 'stdout', 'inplace', or 'check'"
109 ]
101 ]
110− <*> (optional . strOption . mconcat)
111− [ long "config"
112− , short 'c'
113− , metavar "CONFIG"
114− , help "Location of configuration file"
115− ]
116 <*> configParser
102 <*> configParser
117 <*> (strArgument . mconcat)
103 <*> (strArgument . mconcat)
118 [ metavar "FILE"
104 [ metavar "FILE"
ormolu.cabal−2
@@ -47,7 +47,6 @@ library
47 , mtl >= 2.0 && < 3.0
47 , mtl >= 2.0 && < 3.0
48 , syb >= 0.7 && < 0.8
48 , syb >= 0.7 && < 0.8
49 , text >= 0.2 && < 1.3
49 , text >= 0.2 && < 1.3
50− , yaml >= 0.8 && < 0.12
51 exposed-modules: Ormolu
50 exposed-modules: Ormolu
52 , Ormolu.Config
51 , Ormolu.Config
53 , Ormolu.Diff
52 , Ormolu.Diff
@@ -126,7 +125,6 @@ executable ormolu
126 , optparse-applicative >= 0.14 && < 0.15
125 , optparse-applicative >= 0.14 && < 0.15
127 , ormolu
126 , ormolu
128 , text >= 0.2 && < 1.3
127 , text >= 0.2 && < 1.3
129− , yaml >= 0.8 && < 0.12
130 other-modules: Paths_ormolu
128 other-modules: Paths_ormolu
131 if flag(dev)
129 if flag(dev)
132 ghc-options: -Wall -Werror -Wcompat
130 ghc-options: -Wall -Werror -Wcompat
src/Ormolu/Config.hs+1−20
@@ -12,7 +12,6 @@ module Ormolu.Config
12 )
12 )
13where
13where
14
14
15−import Data.Yaml
16import qualified SrcLoc as GHC
15import qualified SrcLoc as GHC
17
16
18-- | Ormolu configuration.
17-- | Ormolu configuration.
@@ -26,24 +25,6 @@ data Config = Config
26 -- ^ Output information useful for debugging
25 -- ^ Output information useful for debugging
27 } deriving (Eq, Show)
26 } deriving (Eq, Show)
28
27
29−instance Semigroup Config where
30− a <> b = Config
31− { cfgDynOptions = cfgDynOptions a <> cfgDynOptions b
32− , cfgUnsafe = cfgUnsafe a || cfgUnsafe b
33− , cfgDebug = cfgDebug a || cfgDebug b
34− }
35−
36−instance Monoid Config where
37− mempty = defaultConfig
38− mappend = (<>)
39−
40−instance FromJSON Config where
41− parseJSON = withObject "config" $ \o -> do
42− cfgDynOptions <- o .: "ghc-opts"
43− cfgUnsafe <- o .: "unsafe"
44− cfgDebug <- o .: "debug"
45− return Config {..}
46−
47-- | Default 'Config'.
28-- | Default 'Config'.
48
29
49defaultConfig :: Config
30defaultConfig :: Config
@@ -57,7 +38,7 @@ defaultConfig = Config
57
38
58newtype DynOption = DynOption
39newtype DynOption = DynOption
59 { unDynOption :: String
40 { unDynOption :: String
60− } deriving (Eq, Ord, Show, FromJSON)
41+ } deriving (Eq, Ord, Show)
61
42
62-- | Convert 'DynOption' to @'GHC.Located' 'String'@.
43-- | Convert 'DynOption' to @'GHC.Located' 'String'@.
63
44