mirror of
https://github.com/tweag/ormolu.git
synced 2024-10-26 15:35:11 +03:00
Drop ‘yaml’ configuration
This commit is contained in:
parent
d63eeea3df
commit
c201862f11
18
app/Main.hs
18
app/Main.hs
@ -15,21 +15,15 @@ import Paths_ormolu (version)
|
||||
import System.Exit (ExitCode (..), exitWith)
|
||||
import System.IO (hPutStrLn, stderr)
|
||||
import qualified Data.Text.IO as TIO
|
||||
import qualified Data.Yaml as Yaml
|
||||
|
||||
-- | Entry point of the program.
|
||||
|
||||
main :: IO ()
|
||||
main = withPrettyOrmoluExceptions $ do
|
||||
Opts {..} <- execParser optsParserInfo
|
||||
config <- case optConfigFile of
|
||||
Nothing -> return optConfig
|
||||
Just path -> do
|
||||
config <- Yaml.decodeFileThrow path
|
||||
return (config <> optConfig)
|
||||
r <- case optInputFile of
|
||||
"-" -> ormoluStdin config
|
||||
inputFile -> ormoluFile config inputFile
|
||||
"-" -> ormoluStdin optConfig
|
||||
inputFile -> ormoluFile optConfig inputFile
|
||||
let notForStdin = do
|
||||
when (optInputFile == "-") $ do
|
||||
hPutStrLn
|
||||
@ -58,8 +52,6 @@ main = withPrettyOrmoluExceptions $ do
|
||||
data Opts = Opts
|
||||
{ optMode :: !Mode
|
||||
-- ^ Mode of operation
|
||||
, optConfigFile :: !(Maybe FilePath)
|
||||
-- ^ Location of configuration file (optional)
|
||||
, optConfig :: !Config
|
||||
-- ^ Ormolu 'Config'
|
||||
, optInputFile :: !FilePath
|
||||
@ -107,12 +99,6 @@ optsParser = Opts
|
||||
, value Stdout
|
||||
, help "Mode of operation: 'stdout', 'inplace', or 'check'"
|
||||
]
|
||||
<*> (optional . strOption . mconcat)
|
||||
[ long "config"
|
||||
, short 'c'
|
||||
, metavar "CONFIG"
|
||||
, help "Location of configuration file"
|
||||
]
|
||||
<*> configParser
|
||||
<*> (strArgument . mconcat)
|
||||
[ metavar "FILE"
|
||||
|
@ -47,7 +47,6 @@ library
|
||||
, mtl >= 2.0 && < 3.0
|
||||
, syb >= 0.7 && < 0.8
|
||||
, text >= 0.2 && < 1.3
|
||||
, yaml >= 0.8 && < 0.12
|
||||
exposed-modules: Ormolu
|
||||
, Ormolu.Config
|
||||
, Ormolu.Diff
|
||||
@ -126,7 +125,6 @@ executable ormolu
|
||||
, optparse-applicative >= 0.14 && < 0.15
|
||||
, ormolu
|
||||
, text >= 0.2 && < 1.3
|
||||
, yaml >= 0.8 && < 0.12
|
||||
other-modules: Paths_ormolu
|
||||
if flag(dev)
|
||||
ghc-options: -Wall -Werror -Wcompat
|
||||
|
@ -12,7 +12,6 @@ module Ormolu.Config
|
||||
)
|
||||
where
|
||||
|
||||
import Data.Yaml
|
||||
import qualified SrcLoc as GHC
|
||||
|
||||
-- | Ormolu configuration.
|
||||
@ -26,24 +25,6 @@ data Config = Config
|
||||
-- ^ Output information useful for debugging
|
||||
} deriving (Eq, Show)
|
||||
|
||||
instance Semigroup Config where
|
||||
a <> b = Config
|
||||
{ cfgDynOptions = cfgDynOptions a <> cfgDynOptions b
|
||||
, cfgUnsafe = cfgUnsafe a || cfgUnsafe b
|
||||
, cfgDebug = cfgDebug a || cfgDebug b
|
||||
}
|
||||
|
||||
instance Monoid Config where
|
||||
mempty = defaultConfig
|
||||
mappend = (<>)
|
||||
|
||||
instance FromJSON Config where
|
||||
parseJSON = withObject "config" $ \o -> do
|
||||
cfgDynOptions <- o .: "ghc-opts"
|
||||
cfgUnsafe <- o .: "unsafe"
|
||||
cfgDebug <- o .: "debug"
|
||||
return Config {..}
|
||||
|
||||
-- | Default 'Config'.
|
||||
|
||||
defaultConfig :: Config
|
||||
@ -57,7 +38,7 @@ defaultConfig = Config
|
||||
|
||||
newtype DynOption = DynOption
|
||||
{ unDynOption :: String
|
||||
} deriving (Eq, Ord, Show, FromJSON)
|
||||
} deriving (Eq, Ord, Show)
|
||||
|
||||
-- | Convert 'DynOption' to @'GHC.Located' 'String'@.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user