Comments
This commit is contained in:
parent
649efea81c
commit
68b5be3edf
11
app/Main.hs
11
app/Main.hs
@ -124,6 +124,7 @@ lForkOpts = ListForkOptions <$> optional
|
|||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
||||||
|
-- wrapper to run effects with settings
|
||||||
let run e = do
|
let run e = do
|
||||||
settings <- exceptT
|
settings <- exceptT
|
||||||
(\_ -> die
|
(\_ -> die
|
||||||
@ -134,16 +135,24 @@ main = do
|
|||||||
$ getSettings
|
$ getSettings
|
||||||
(flip runReaderT) settings . runExceptT . withExceptT show $ e
|
(flip runReaderT) settings . runExceptT . withExceptT show $ e
|
||||||
e <- execParser (info (opts <**> helper) idm) >>= \case
|
e <- execParser (info (opts <**> helper) idm) >>= \case
|
||||||
|
|
||||||
|
-- fork
|
||||||
Fork (ForkOptions {..}) -> run $ do
|
Fork (ForkOptions {..}) -> run $ do
|
||||||
case repoBasePath of
|
case repoBasePath of
|
||||||
Just rbp -> case parseAbs rbp of
|
Just rbp -> case parseAbs rbp of
|
||||||
Just p -> prepareRepoForPR' repo (Just p) newBranch
|
Just p -> prepareRepoForPR' repo (Just p) newBranch
|
||||||
Nothing -> liftIO $ die (color Red $ "Repo path must be absolute")
|
Nothing -> liftIO $ die (color Red $ "Repo path must be absolute")
|
||||||
Nothing -> prepareRepoForPR' repo Nothing newBranch
|
Nothing -> prepareRepoForPR' repo Nothing newBranch
|
||||||
|
|
||||||
|
-- config
|
||||||
Config (ConfigOptions {..}) -> do
|
Config (ConfigOptions {..}) -> do
|
||||||
p <- maybe (pure Nothing) (fmap Just . parseAbs) bPath
|
p <- maybe (pure Nothing) (fmap Just . parseAbs) bPath
|
||||||
writeSettings (Settings (OAuth oAuth) p) <&> Right
|
writeSettings (Settings (OAuth oAuth) p) <&> Right
|
||||||
|
|
||||||
|
-- delete
|
||||||
Del (DelOptions {..} ) -> run $ deleteFork' del
|
Del (DelOptions {..} ) -> run $ deleteFork' del
|
||||||
|
|
||||||
|
-- list-forks
|
||||||
ListForks (ListForkOptions {..}) -> run $ do
|
ListForks (ListForkOptions {..}) -> run $ do
|
||||||
mtime <- liftIO $ case lSince of
|
mtime <- liftIO $ case lSince of
|
||||||
Just t -> do
|
Just t -> do
|
||||||
@ -174,6 +183,8 @@ main = do
|
|||||||
forks
|
forks
|
||||||
liftIO $ putStrLn $ formatted
|
liftIO $ putStrLn $ formatted
|
||||||
pure ()
|
pure ()
|
||||||
|
|
||||||
|
-- print error, if any
|
||||||
case e of
|
case e of
|
||||||
Right () -> pure ()
|
Right () -> pure ()
|
||||||
Left t -> die (color Red $ t)
|
Left t -> die (color Red $ t)
|
||||||
|
Loading…
Reference in New Issue
Block a user