Giter Club home page Giter Club logo

mrtodotxt's Introduction

mrtodotxt

This app loads a todo.txt file and provides easy ways to manipulate the data. Uses any todo.txt file following the standard format.

This is literate coffeescript! Give it a go with coffee -l README.litcoffee

Create a todo list instance

mrt = require "./" # or "mrtodotxt"
todo = new mrt.TodoList {}, "./todo.txt"

Add some new items

todo.create "milk @grocerystore"
todo.create "coffee @grocerystore"
todo.create "code @computer +mrtodotxt"

Selectors

Below, we find all todo items with the @grocerystore context. Then, we log them out with the log helper. Selectors can take the form of:

  • @context - search for all items with a context of @context
  • +project - search for all items with a project of +project
  • text - search in the item body for text (not case sensitive)

Oh, and mrt.log is a helper for prettyprinting todo.txt lists.

todo.select ["@grocerystore"], (all) ->
  mrt.log all, "All with @grocerystore"

Marking Items

Next, after selecting all the items that contain the word code and the context @computer, we mark the items as completed. Then, we log out our changes. (todo.unmark exists to unmark items as completed)

todo.select ["code", "@computer"], (code) ->
  todo.mark code, (m) ->
    mrt.log m, "Marked code item"

todo.select ["code", "@computer"], (code) ->
  todo.unmark code, (m) ->
    mrt.log m, "Marked code item"

Updating

In this snippet, the item with text content of "milk" is updated to 2% milk, and logged out. Also, this example demonstrates that methods can be used synchronously.

todo.select ["milk"], (milk) ->
  items = todo.update milk, "2% milk @grocerystore"
  mrt.log items, "Updated Milk"

Deleting

Lastly, we delete coffee from the list.

todo.select ["coffee"], (coffee) ->
  todo.delete coffee, (items) ->
    mrt.log items, "Deleted Coffee"

mrtodotxt's People

Contributors

1egoman avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.