packages feed

commander-cli-0.1.0.0: app/Main.hs

{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE BlockArguments #-}
module Main where

import Options.Commander 
import Prelude

type File = Named "file"
          & Arg "filename" FilePath 
          & ("write" & Arg "contents" String & Raw
          +  "read"  & Raw) 

file :: ProgramT File IO ()
file = named $ arg \a -> (sub $ arg (raw . writeFile a)) :+: (sub . raw $ readFile a >>= putStrLn)

main :: IO ()
main = command_ (file :+: usage @File)