on master help sign in
Added default config printing
commitffe9aedd90afe176fa0f33424f849bd443965559 authoriko <ilyakooo0@gmail.com> dateMon 24 Feb 2020, 14:50 (7 years ago) parent1b7e155
2 files changed+16−1
app/Main.hs+8−1 src/Server/Config.hs+8
app/Main.hs+8−1
@@ -1,6 +1,13 @@
11module Main (main) where
22
3+import qualified Data.ByteString.Char8 as BS
4+import Data.Yaml
35import Server
6+import Server.Config
7+import System.Environment
48
59main :: IO ()
6−main = runServer
10+main = getArgs >>= \case
11+ [] -> runServer
12+ ["default"] -> putStrLn . BS.unpack . encode $ defaultConfig
13+ xs -> error . show $ xs
src/Server/Config.hs+8
@@ -40,12 +40,20 @@ instance FromJSON ByteString where
4040 parseJSON (String s) = return . BS.pack . T.unpack $ s
4141 parseJSON _ = fail "not a string"
4242
43+instance ToJSON ByteString where
44+ toJSON = String . T.pack . BS.unpack
45+
4346instance FromJSON Severity where
4447 parseJSON (String s) = maybe (fail "oh no") return . readMaybe . T.unpack $ s
4548 parseJSON _ = fail "not a string"
4649
50+instance ToJSON Severity where
51+ toJSON = String . T.pack . show
52+
4753instance FromJSON Config
4854
55+instance ToJSON Config
56+
4957defaultConfig :: Config
5058defaultConfig =
5159 Config