packages feed

yeganesh-2.4: strip.hs

module Main where

import Data.Map (mapKeysWith)
import System.Environment (getArgs)
import Version (versionStrip)
import Yeganesh (Options, deprecate, inFileName, merge, profile, outFileName,
    parseOptions, readPossiblyNonExistent, stripNewline)

runWithOptions :: Options -> IO ()
runWithOptions opts = do
    inFile      <- inFileName  (profile opts)
    outFile     <- outFileName (profile opts)
    (t, cmd)    <- readPossiblyNonExistent inFile
    writeFile outFile (show (t, mapKeysWith merge stripNewline cmd))
    deprecate inFile (profile opts)

introText :: String
introText = unlines $ [
    versionStrip,
    "Usage: yeganesh-strip [-p profile]",
    "The other options described below are accepted, but ignored.",
    "Profiles are stored in the XDG data home for yeganesh."]

main :: IO ()
main = getArgs >>= either putStrLn runWithOptions . parseOptions introText versionStrip