GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - haskell-github-trust/effectful-cli: A CLI toolkit bundled in an `effectful` effect

BranchesTags
Open more actions menu

Latest commit

 

History

49 Commits
49 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
api
api
 
 
src
src
 
 
test
test
 
 
.gitignore
.gitignore
 
 
.hlint.yaml
.hlint.yaml
 
 
.node-version
.node-version
 
 
.releaserc.json
.releaserc.json
 
 
AGENTS.md
AGENTS.md
 
 
CHANGELOG.md
CHANGELOG.md
 
 
Justfile
Justfile
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
fourmolu.yaml
fourmolu.yaml
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
package.yaml
package.yaml
 
 
renovate.json
renovate.json
 
 
stack-ghc-9.12.yaml
stack-ghc-9.12.yaml
 
 
stack-ghc-9.12.yaml.lock
stack-ghc-9.12.yaml.lock
 
 
stack.yaml
stack.yaml
 
 
stack.yaml.lock
stack.yaml.lock
 
 

Repository files navigation

effectful-cli

Small helpers for writing CLIs with effectful: effect constraints, concurrency, prompts, sleep/time, optparse-applicative helpers and a monad-logger bridge (stderr or OpenTelemetry).

Quick start

Add the dependencies to package.yaml:

dependencies:
  - effectful
  - effectful-cli
  - http-client-effectful
  - monad-logger
  - optparse-applicative
  - text

Minimal Main.hs, one hello subcommand logging to stderr:

{-# LANGUAGE OverloadedStrings #-}

import Control.Monad.Logger (logInfoN)
import Data.CLI.Class
import Data.CLI.Impl (execCLIParser, mkCommand, usage)
import Data.Error.CLI (CLIError, displayCLIError)
import Data.Text qualified as T
import Data.Text.IO qualified as T
import Effectful
import Effectful.Error.Static (runErrorNoCallStack)
import Effectful.HttpClient (runHttpClientTls)
import Effectful.Logger (runStderrLogger)
import Effectful.Reader.Static (runReader)
import Options.Applicative (hsubparser, strArgument)

data Config = Config

instance CLIConfig Config where
  autoAccept _ = False
  autoDecline _ = False

newtype Hello = Hello String

instance Command Config CLIError Hello where
  cmdname _ = "hello"
  doc _ = "greet someone"
  parser _ = Hello <$> strArgument mempty
  runner (Hello name) = logInfoN ("hello " <> T.pack name)

main :: IO ()
main = do
  cmd <- execCLIParser
         (usage "hello" "0.1.0" "greeter" (hsubparser (mkCommand (Hello ""))))
  res <-
    runEff .
    runHttpClientTls .
    runStderrLogger .
    runReader Config .
    runErrorNoCallStack @CLIError .
    runErrorNoCallStack @CLIError $
    runner cmd
  either (T.putStrLn . displayCLIError) pure (res >>= id)
stack run -- hello world

See the Effectful.CLI module docs for the walkthrough.

Build

stack build --test

Release

Requires just and a Hackage token in HACKAGE_KEY.

just docs       # build Haddock tarball
just candidate  # upload package + docs as Hackage candidate
just release    # publish package + docs to Hackage

About

A CLI toolkit bundled in an `effectful` effect

Resources

Readme
GPL-3.0 license
Activity
Custom properties

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.