cmd-item: Library to compose and reuse command line fragments

[ library, mit, system ] [ Propose Tags ] [ Report a vulnerability ]

Library to compose and reuse command line fragments


[Skip to Readme]

Modules

[Index]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.0.1.0
Dependencies base (>=4.5 && <4.9), containers (>=0.5), templater, text (>=1.1) [details]
Tested with ghc ==7.6, ghc ==7.8, ghc ==7.10
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 repo head: git clone git://github.com/geraud/cmd-item.git
Uploaded by geraud at 2015-04-30T15:11:19Z
Distributions
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 1032 total (3 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2015-04-30 [all 1 reports]

Readme for cmd-item-0.0.1.0

[back to package description]

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