@@ -48,7 +48,10 @@ import Prelude hiding (lookup, putStr)
4848-- In particular, this is used to pass on the category and access token
4949-- which would have been passed in as arguments to the program
5050-- from the argument parsing stage to the API call to GitHub.
51- data Context = Context { category :: Maybe String , gitHubToken :: Maybe String }
51+ data Context = Context
52+ { category :: Maybe String ,
53+ gitHubToken :: Maybe String
54+ }
5255
5356main :: [String ] -> IO ()
5457main args = case Arguments. validate args of
@@ -57,10 +60,12 @@ main args = case Arguments.validate args of
5760
5861invoke :: [String ] -> IO ()
5962invoke args = do
60- let (executable, flags, cat, tok) = Arguments. translate args
61- (exitCode, out, err) <- readCreateProcessWithExitCode (proc executable flags) " "
63+ let (executable, flags, category, token) = Arguments. translate args
64+ (exitCode, out, err) <-
65+ readCreateProcessWithExitCode (proc executable flags) " "
66+ let context = Context {category = category, gitHubToken = token}
6267 case exitCode of
63- ExitSuccess -> annotate Context {category = cat, gitHubToken = tok} ( fromString out)
68+ ExitSuccess -> annotate context $ fromString out
6469 _ -> putStrLn err >> exitWith exitCode
6570
6671annotate :: Context -> ByteString -> IO ()
@@ -70,7 +75,7 @@ annotate context output = do
7075 let annotated' = Fingerprint. fill <$> annotated
7176 case annotated' of
7277 Nothing -> die $ " invalid encoding\n " <> show output <> " \n "
73- Just output' -> send context ( encode output')
78+ Just output' -> send context $ encode output'
7479 where
7580 value = decode output :: Maybe Value
7681
@@ -81,8 +86,9 @@ send context output = do
8186 let endpoint' = toCall env output
8287 case endpoint' of
8388 Just endpoint -> call settings endpoint
84- _ -> die ( " missing environment variables\n " <> show env)
89+ _ -> die " not all necessary environment variables available "
8590
8691call :: GitHubSettings -> GHEndpoint -> IO ()
87- call settings endpoint = do
88- putStrLn . unlines . toOutputs =<< runGitHubT settings (queryGitHub endpoint)
92+ call settings endpoint =
93+ putStrLn . unlines . toOutputs
94+ =<< runGitHubT settings (queryGitHub endpoint)
0 commit comments