slack-progressbar-0.1.0.0

Copyright(c) 2020 Tom McLaughlin
LicenseMIT
Stabilityexperimental
Portabilityportable
Safe HaskellNone
LanguageHaskell2010

Web.Slack.ProgressBar

Contents

Description

This is a simple library for creating and updating Slack messages that contain progressbars. It can be used to display the progress of a long-running task in a Slack channel, for example as part of CI tooling.

main :: IO ()
main = do
  let mySlackConfig = SlackConfig { slackApiToken = "my-slack-api-token" }

  let progressBarInfo = def { progressBarInfoTopMessage = Just "Top message"
                            , progressBarInfoSize = Just 0 }

  result <- runExceptT $ do
    progressBar <- ExceptT $ createProgressBar mySlackConfig "test-channel" progressBarInfo

    forM_ [10, 20, 30, 40, 50, 60, 70, 80, 90, 100] $ \size -> do
      threadDelay 1000000
      ExceptT $ updateProgressBar mySlackConfig progressBar (progressBarInfo { progressBarInfoSize = Just size })

  putStrLn [i|Result: '#{result}'|]
Synopsis

Documentation

createProgressBar :: SlackConfig -> ChannelName -> ProgressBarInfo -> IO (Either Text ProgressBar) Source #

Create a progress bar message on the given channel. Returns a ProgressBar which can be used to update the message by calling updateProgressBar.

updateProgressBar :: SlackConfig -> ProgressBar -> ProgressBarInfo -> IO (Either Text ()) Source #

Update an existing progress bar.

data ProgressBarInfo Source #

The state of a progress bar message.

Constructors

ProgressBarInfo 

Fields

data ProgressBar Source #

An opaque type representing an existing Slack message.

Re-exports

newtype SlackConfig Source #

Configuration options needed to connect to the Slack API

Constructors

SlackConfig 

Fields

Instances
Show SlackConfig Source # 
Instance details

Defined in Web.Slack.ProgressBar