Skip to content

Commit

Permalink
Merge branch 'master' of github.com:josip/kano
Browse files Browse the repository at this point in the history
Conflicts:
	io/Utilites.io
  • Loading branch information
josip committed May 1, 2010
2 parents 0d52b89 + d5c9b24 commit 94c3f58
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 2 deletions.
10 changes: 8 additions & 2 deletions io/Kano.io
Expand Up @@ -31,11 +31,17 @@ Kano := Object clone do(
ns := Namespaces getSlot(nsName)
ns isNil ifTrue(
Exception raise("Unknown namespace: " .. nsName .. ". Try -ns option"))

# If only namespace name is provided, "list" task
# should be called.
ns hasLocalSlot(taskName) ifFalse(
taskName = "list")

if(ns hasLocalSlot(taskName),
if(ns getSlot(taskName) type == "Block",
ns getSlot(taskName) performWithArgList("call", taskArgs)),
Exception raise("Unknown task: " .. taskName)))
ns getSlot(taskName) performWithArgList("call", taskArgs))
,
Exception raise("Unknown task: " .. taskName)))

findKanofiles := method(dir,
dir isNil ifTrue(return(list()))
Expand Down
25 changes: 25 additions & 0 deletions io/Utilites.io
@@ -0,0 +1,25 @@
/*doc Sequence colourize(colour[, option])
Prints the string to stdout with bash colors.<br/>
Example: "Fire!!!" colourize("red", "bold") printlnColours
*/
Sequence colours := list("black", "red", "green", "yellow", "blue", "purple", "cyan", "white")
Sequence colourize := method(colour, option,
out := "\\e[" asMutable
if(colour isNil, out appendSeq("0;3"))
if(option == "bold", out appendSeq("1;3"))
if(option == "underline", out appendSeq("4;3"))
if(option == "background", out appendSeq("4"))

out appendSeq(self colours indexOf(colour) .. "m")
out appendSeq(self)
out appendSeq("\\e[0m")

out)

(System platform asLowercase == "darwin") ifFalse(
Sequence colourize = method(self))

Sequence printlnColours := method(
System system("echo \"#{self}\"" interpolate)
self)

0 comments on commit 94c3f58

Please sign in to comment.