nemesis 2010.10.4 → 2010.10.4.1.1
raw patch · 4 files changed
+35/−16 lines, 4 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ System.Nemesis: show_with_ljust :: Int -> Task -> String
Files
- Nemesis +5/−0
- nemesis.cabal +1/−1
- readme.md +18/−9
- src/System/Nemesis.hs +11/−6
Nemesis view
@@ -62,3 +62,8 @@ namespace "drink" - do task "coke" - putStrLn "drinking coke"+ + + desc "test"+ task "test" - do+ sh "runghc test/N1.hs"
nemesis.cabal view
@@ -1,5 +1,5 @@ Name: nemesis-Version: 2010.10.4+Version: 2010.10.4.1.1 Build-type: Simple Synopsis: a Rake like task management tool Description: smart per project code snippets
readme.md view
@@ -27,7 +27,8 @@ ### Install - cabal update; cabal install nemesis+ cabal update+ cabal install nemesis ### DSL @@ -97,12 +98,17 @@ eating bread +Hints+-----++Please add `.nemesis` to `.gitignore` or equivalents.+ Advance usage ------------- -### Use LANGUAGE progam+### Use LANGUAGE pragma -Put a `-- Nem` token after the `Langauge` progma+Put a `-- Nem` line after the `Langauge` pragma {-# LANGUAGE QuasiQuotes #-} @@ -113,25 +119,28 @@ currently the separator `-- Nem` is hard coded -### By pass preprocessing, e.g. use custom imports+### Bypass preprocessing, i.e. run as EDSL -Define `main`, i.e. add `main = run nemesis` in the code. The preprocessor look for the function main, if it's defined, it skip preprocessing, and Nemesis because pure EDSL that can be run by `runhaskell`.+Define `main`, i.e. add `main = run nemesis` in the code. The preprocessor looks for the function main, if it's defined, preprocessing is skipped. +This turns `Nemesis` into a pure EDSL in Haskell, which can be invoked by `runghc`.+ For example: import System.Nemesis (run) import System.Nemesis.DSL- import MPS.Light ((-))+ import MPS.Env ((-)) import Prelude hiding ((-)) nemesis = do- task "i" (sh "ghci -isrc src/System/Nemesis.hs")+ task "hello" - do+ sh "echo 'hello world'" main = run nemesis -Test out by:+Try: - runghc Nemesis+ runghc Nemesis hello ### Who is mnemosyne?
src/System/Nemesis.hs view
@@ -41,11 +41,7 @@ display_name t = (t.name : t.namespace).reverse.map (ljust 10 ' ') .join " " instance Show Task where- show x = case x.description of- Nothing -> title- Just s -> title ++ s- where- title = x.display_name.ljust 44 ' ' ++ ": "+ show = show_with_ljust 44 instance Eq Task where a == b = a.name == b.name@@ -55,6 +51,11 @@ type Unit = StateT Nemesis IO () +show_with_ljust :: Int -> Task -> String+show_with_ljust n task=+ case task.description of+ Nothing -> task.full_name+ Just x -> task.full_name.ljust n ' ' + x run :: Unit -> IO () run unit = do@@ -66,8 +67,12 @@ where help = execStateT unit def >>= list_task list_task n = do+ let _tasks = n.tasks.elems+ + _task_len = _tasks.map (full_name > length) .maximum + 5+ br- n.tasks.elems.sort.mapM_ print+ n.tasks.elems.sort.map (show_with_ljust _task_len) .mapM_ putStrLn br br = putStrLn ""