Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
162 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,29 @@ | ||
# jot | ||
|
||
> jots down your thoughts so _you_ don't have to | ||
Simple local storage for all of those half baked ideas. | ||
|
||
move along, I'll publish this soon | ||
`jot`, `drop` and roll. | ||
|
||
## Install | ||
|
||
Add the following to your plugin definition | ||
|
||
addSbtPlugin("me.lessis" % "jot" % "0.1.0") | ||
|
||
And add following in your build definition | ||
|
||
seq(jotSettings:_*) | ||
|
||
## usage | ||
|
||
Below is a list of available settings | ||
|
||
jot # Appends an item to your jot file | ||
clean(for jot) or (clean in (SomeConfig, jot)) # Removes an item from your jot file | ||
jot-drop or (drop in SomeConfig)) # Drops a target item from your jot file | ||
jot-cat or (cat in (SomeConfig)) # Lists your jottings | ||
jot-file or (jotFile in (SomeConfig)) # File containing jottings | ||
target(for jot) or (target in (SomeConfig, jot)) # Directory containing generated jot file | ||
colors(for jot) or (colors in (SomeConfig, jot)) # Toggles ansii colored output | ||
|
||
Doug Tangren (softprops) 2011 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,39 @@ | ||
# initial release | ||
|
||
Jot tracks local project notes in a simple format. I will not make you a sandwich. | ||
|
||
- sbt plugins [best practices][bp] ✔ | ||
`Jot` tracks project notes locally. It will not make you a sandwich. | ||
|
||
- settings | ||
|
||
below is a list of available settings | ||
below is a list of available settings(*) | ||
|
||
jot # Appends an item to your jot file | ||
clean(for jot) or (clean in (SomeConfig, jot)) # Removes an item from your jot file | ||
jot-drop or (drop in SomeConfig)) # Drops a target item from your jot file | ||
jot-cat or (cat in SomeConfig) # Lists your jottings | ||
jot-file or (jotFile in SomeConfig) # File containing jottings | ||
target(for jot) or (target in (SomeConfig, jot)) # Directory containing jot-file | ||
colors(for jot) or (colors in (SomeConfig, jot)) # Toggles ansii colored output | ||
|
||
jot # Appends a thought to your jot file | ||
rm(for jot) or (rm in (SomeConfig, jot)) # Removes a thought from your jot file | ||
ls(for jot) or (ls in (SomeConfig, jot)) # Lists your jotted thoughts | ||
clear(for jot) or (ls in (SomeConfig, jot)) # Clears all jotted thoughts | ||
jot-file(for jot) or (jotFile in (SomeConfig, jot)) # File containing thoughts | ||
jot-directory(for jot) or (jotDirectory in (SomeConfig, jot)) # Directory containing jot file | ||
colors(for jot) or (colors in (SomeConfig, jot)) # Toggles ansii colored output | ||
(*) subject to change in the future. Some key interface combinations of `jot-x(for jot)` were kind of annoying so some keys are not | ||
scoped to jot. This may change in the future | ||
|
||
for more information see the projects [readme][rm] | ||
for more information see the project's [readme][rm]. | ||
|
||
- published for sbt [0.11][sbt11] | ||
- published for sbt [0.11.2][sbt112] | ||
|
||
Add the following to your plugin definition | ||
|
||
addSbtPlugin("me.lessis" % "jot" % "0.1.0") | ||
|
||
And add the settings in your build file with | ||
And add following in your build definition | ||
|
||
seq(jotSettings:_*) | ||
|
||
And you're done. | ||
|
||
If you want other support for other sbt versions [Let me know][issues] | ||
|
||
[bp]: https://github.com/harrah/xsbt/wiki/Plugins-Best-Practices | ||
[rm]: https://github.com/softprops/jot#readme | ||
[sbt11]: http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.11.0/sbt-launch.jar | ||
[sbt112]: http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/0.11.2/sbt-launch.jar | ||
[issues]: https://github.com/softprops/jot/issues |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
[jot][jot] simply keeps track of project notes. nothing more. | ||
[jot][jot] keeps track of project notes. nothing more. | ||
|
||
[jot]: github.com/softprops/jot#readme |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
libraryDependencies <+= sbtVersion("org.scala-tools.sbt" %% "scripted-plugin" % _) | ||
|
||
|
||
resolvers ++= Seq( | ||
"less is" at "http://repo.lessis.me", | ||
"coda" at "http://repo.codahale.com") | ||
|
||
addSbtPlugin("me.lessis" % "ls-sbt" % "0.1.1") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
|
||
{ | ||
"organization":"me.lessis", | ||
"name":"jot", | ||
"version":"0.1.0", | ||
"description":"Sbt interface for storing local project notes", | ||
"site":"https://github.com/softprops/jot/", | ||
"tags":["sbt"], | ||
"docs":"", | ||
"licenses": [], | ||
"resolvers": ["http://scala-tools.org/repo-releases"], | ||
"dependencies": [{ | ||
"organization":"org.scala-tools.sbt", | ||
"name": "scripted-sbt_2.9.1", | ||
"version": "0.11.2" | ||
}], | ||
"scalas": ["2.9.1"], | ||
"sbt": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,103 @@ | ||
package jot | ||
|
||
import sbt._ | ||
import Project.Initialize | ||
import java.io.File | ||
|
||
object Plugin extends sbt.Plugin { | ||
import sbt._ | ||
import sbt.Project.Initialize | ||
import sbt.Keys._ | ||
import JotKeys._ | ||
import JotKeys.{ jot => j, _ } | ||
import java.io.File | ||
|
||
object JotKeys { | ||
val jot = InputKey[Unit]("jot", "Appends an item your jot file") | ||
val rm = InputKey[Unit]("rm", "Removes an item from your jot file") | ||
val ls = TaskKey[Unit]("ls", "Enumerates the contents of your jot file") | ||
val clear = TaskKey[Unit]("clear", "Clears jot file") | ||
val jotFile = SettingKey[File]("jot-file", "File containing jotted items") | ||
val jotDirectory = SettingKey[File]("jot-directory", "Directory containing jot file") | ||
val drop = InputKey[Unit](key("drop"), "Removes an item from your jot file") | ||
val cat = TaskKey[Unit](key("cat"), "Enumerates the contents of your jot file") | ||
val jotFile = SettingKey[File](key("file"), "File containing jotted items") | ||
val colors = SettingKey[Boolean]("colors", "Toggles ansii colored output") | ||
} | ||
|
||
private def lines(f: File): Array[(String, Int)] = IO.read(f) match { | ||
case "" => Array.empty[(String, Int)] | ||
case str => str.split("\n\n").zipWithIndex | ||
private def key(name: String) = "jot-%s" format name | ||
} | ||
|
||
private def clearTask: Initialize[Task[Unit]] = | ||
(streams, jotFile in jot) map { | ||
private def lines(f: File): Array[(String, Int)] = | ||
IO.read(f) match { | ||
case "" => Array.empty[(String, Int)] | ||
case str => str.split("\n\n").zipWithIndex | ||
} | ||
|
||
private def cleanTask: Initialize[Task[Unit]] = | ||
(streams, jotFile) map { | ||
(out, jf) => | ||
IO.write(jf, "") | ||
out.log.info("jots cleared") | ||
out.log.info("Jots cleared") | ||
} | ||
|
||
private def lsTask: Initialize[Task[Unit]] = | ||
(streams, jotFile in jot, colors in jot) map { | ||
private def catTask: Initialize[Task[Unit]] = | ||
(streams, jotFile, colors in j) map { | ||
(out, jf, clrs) => | ||
out.log.info("jottings..") | ||
out.log.info("Jottings..") | ||
IO.touch(jf) | ||
lines(jf) match { | ||
case Array() => out.log.info("you have none. try `jot some ideas`") | ||
case ts => ts.foreach { _ match { | ||
case(l, n) => out.log.info( | ||
(if(clrs) "\033[0;36m%s\033[0m) \033[0;37m%s\033[0m" else "%s) %s") format(n, l) | ||
) | ||
} } | ||
case Array() => out.log.info("You have none. Try `jot some ideas`") | ||
case ts => ts.foreach { | ||
_ match { | ||
case(l, n) => out.log.info( | ||
(if(clrs) "\033[0;36m%s\033[0m) \033[0;37m%s\033[0m" else "%s) %s") format(n, l) | ||
) | ||
} | ||
} | ||
} | ||
} | ||
|
||
def jotSettings: Seq[Setting[_]] = | ||
jotSettingsIn(Compile) ++ jotSettingsIn(Test) | ||
|
||
def jotSettingsIn(c: Configuration) = inConfig(c)(jotSettings0) | ||
def jotSettingsIn(c: Configuration) = inConfig(c)(jotSettings0) ++ Seq( | ||
clean in j <<= (clean in (c, j)) | ||
) | ||
|
||
def jotSettings0: Seq[Setting[_]] = Seq( | ||
jotDirectory in jot <<= (baseDirectory).identity, | ||
jotFile in jot <<= (jotDirectory in jot)(_ / ".jot"), | ||
colors in jot := true, | ||
jot <<= inputTask { (argsTask: TaskKey[Seq[String]]) => | ||
(argsTask, streams, jotFile in jot, colors in jot) map { (args, out, jf, clrs) => | ||
args.mkString(" ").trim match { | ||
case "" => out.log.error("usage: `jot some ideas`") | ||
case item => | ||
IO.touch(jf) | ||
IO.append(jf, item + "\n\n") | ||
out.log.info( | ||
(if(clrs) "jotted, \033[0;37m%s\033[0m" else "jotted, %s") format item | ||
) | ||
} | ||
target in j <<= baseDirectory, | ||
jotFile <<= (target in j)(_ / ".jot"), | ||
colors in j := true, | ||
j <<= inputTask { (argsTask: TaskKey[Seq[String]]) => | ||
(argsTask, streams, jotFile, colors in j) map { | ||
(args, out, jf, clrs) => | ||
args.mkString(" ").trim match { | ||
case "" => out.log.error("usage: `jot some ideas`") | ||
case item => | ||
IO.touch(jf) | ||
IO.append(jf, item + "\n\n") | ||
out.log.info( | ||
(if(clrs) "jotted, \033[0;37m%s\033[0m" else "jotted, %s") format item | ||
) | ||
} | ||
} | ||
}, | ||
rm in jot <<= inputTask { (argsTask: TaskKey[Seq[String]]) => | ||
(argsTask, streams, jotFile in jot, colors in jot) map { (args, out, jf, clrs) => | ||
args match { | ||
case Seq(num) => | ||
IO.touch(jf) | ||
val lns = lines(jf) | ||
lns match { | ||
case Array() => out.log.info("nothing to remove") | ||
case many => IO.write(jf, many.filter( _ match { | ||
case (l, n) if(n == num.toInt) => | ||
out.log.info( | ||
(if(clrs) "removed, \033[0;37m%s\033[0m" else "removed, %s") format l | ||
) | ||
false | ||
case _ => true | ||
}).map(_._1) match { | ||
case Array() => "" | ||
case lns => lns.mkString("","\n\n","\n\n") | ||
}) | ||
} | ||
case _ => out.log.error("usage: rm(for jot) <num>") | ||
} | ||
drop <<= inputTask { (argsTask: TaskKey[Seq[String]]) => | ||
(argsTask, streams, jotFile, colors in j) map { | ||
(args, out, jf, clrs) => | ||
(args, out.log) match { | ||
case (Seq(num), log) => | ||
IO.touch(jf) | ||
val lns = lines(jf) | ||
lns match { | ||
case Array() => log.info("Nothing to drop") | ||
case many => IO.write(jf, many.filter( _ match { | ||
case (l, n) if(n == num.toInt) => | ||
log.info( | ||
(if(clrs) "Dropped, \033[0;37m%s\033[0m" else "removed, %s") format l | ||
) | ||
false | ||
case _ => true | ||
}).map(_._1) match { | ||
case Array() => "" | ||
case lns => lns.mkString("","\n\n","\n\n") | ||
}) | ||
} | ||
case (_, log) => log.error("usage: jot-drop <num>") | ||
} | ||
} | ||
}, | ||
ls in jot <<= lsTask, | ||
clear in jot <<= clearTask | ||
cat <<= catTask, | ||
clean in j <<= cleanTask | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
seq(jotSettings:_*) | ||
|
||
(JotKeys.jotFile in (Compile, JotKeys.jot)) <<= (baseDirectory)(_ / ".myjots") | ||
(JotKeys.jotFile in Compile) <<= (baseDirectory)(_ / ".myjots") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters