The cmd-item package

[Tags:library, mit, test]

Library to compose and reuse command line fragments


[Skip to Readme]

Properties

Versions 0.0.1.0
Dependencies base (>=4.5 && <4.9), containers (>=0.5), templater, text (>=1.1) [details]
License MIT
Copyright Copyright (C) 2015 Geraud Boyer
Author Geraud Boyer
Maintainer Geraud Boyer <geraud@gmail.com>
Category System
Home page https://github.com/geraud/cmd-item
Bug tracker https://github.com/geraud/cmd-item/issues
Source repository head: git clone git://github.com/geraud/cmd-item.git
Uploaded Thu Apr 30 15:11:19 UTC 2015 by geraud
Distributions NixOS:0.0.1.0
Downloads 181 total (3 in the last 30 days)
Votes
0 []
Status Docs available [build log]
Last success reported on 2015-04-30 [all 1 reports]

Modules

[Index]

Downloads

Maintainer's Corner

For package maintainers and hackage trustees

Readme for cmd-item

Readme for cmd-item-0.0.1.0

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}"