1{-# LANGUAGE FlexibleContexts #-}
2{-# LANGUAGE OverloadedStrings #-}
3{-# LANGUAGE ScopedTypeVariables #-}
4module Obelisk.CliApp.Demo where
6import Control.Concurrent (threadDelay)
7import Control.Monad.IO.Class
8import Data.Semigroup ((<>))
9import qualified Data.Text as T
10import System.Process (proc)
12import Control.Monad.Catch (MonadMask)
17 :: ( MonadIO m, MonadMask m
18 , CliLog m, HasCliConfig e m, CliThrow e m, AsProcessFailure e, AsUnstructuredError e)
20cliDemo = withSpinner "CLI Demo" $ do
21 putLog Notice "This demo will showcase the CLI library functionality"
22 _ <- withSpinner' "Searching long for something" (Just $ \c -> "Discovered " <> T.pack (show c) <> " objects") $ do
24 withSpinner "Nested task" $ do
26 putLog Notice "In nested task"
27 -- This is a 'no trail' spinner that won't leave a trail (even its sub spinners)
28 withSpinnerNoTrail "In between, doing something temporary" $ do
29 withSpinner "Runnning something deep inside" $ do
31 putLog Notice "You can still log from inside no-trail spinners"
34 putLog Error "Top nested task finished"
36 putLog Error "Some user error while spinning"
38 putLog Notice "This is some info mesage"
39 putLog Warning "And now a warning as well"
41 return (42 :: Integer)
42 putLog Notice "Now we start a 2nd spinner, run a couple of process, the last of which fails:"
43 withSpinner "Looking around" $ do
45 output <- readProcessAndLogStderr Notice $ proc "ls" ["-l", "/"]
46 putLog Notice $ "Output was: " <> output
48 callProcessAndLogOutput (Notice, Error) $ proc "ls" ["-l", "/does-not-exist"]
50 failWith "Something dangerous happened"
52 delay = liftIO $ threadDelay 1000000
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list