cmd-item

Library to compose and reuse command line fragments https://github.com/geraud/cmd-item

Latest on Hackage:0.0.1.0

This package is not currently in any snapshots. If you're interested in using it, we recommend adding it to Stackage Nightly. Doing so will make builds more reliable, and allow stackage.org to host generated Haddocks.

MIT licensed by Geraud Boyer
Maintained by Geraud Boyer

CmdItem

Build Status

CmdItem allows you to compose command lines by combining fragments of commands.

Installation

cabal update
cabal install cmd-item

Example

{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE OverloadedLists #-}

import Data.CmdItem
import System.Environment (getArgs)

main :: IO ()
main = do
    args <- getArgs
    case args of
    [] -> return ()
    (name:ns) -> do
        constants <- getConstants name
        makeProject constants

makeProject :: CmdItem -> IO ()
makeProject contants = do
    let cmdItem = pants <> "idea" <> ideaOptions <> constants
    shellCommand <- render cmdItem
    print shellcommand

getConstants :: Text -> IO CmdItem
getConstants name =  do
    home <- getHomeDirectory
    nCpu <- getNumProcessors
    let result = [ ("java_version", "7")
                 , ("project_root", T.pack $ home <> "/workspace/project")
                 , ("num_cpu", T.pack $ show nCpu)
                 , ("project_name", name)
                 ]
    return result

pants :: CmdItem
pants = "%{project_root}/pants"

ideaOptions :: CmdItem
ideaOptions = "--idea-java-language-level=%{java_version}"
            <> "--idea-java-maximum-heap-size=2096"
            <> "--idea-scala-maximum-heap-size=2096"
            <> "--idea-project-name=%{project_name}"
Used by 1 package:
comments powered byDisqus