forked from JoshCheek/Play
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
3 changed files
with
142 additions
and
0 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 +1,2 @@ | ||
craigslist-watcher/*.yml | ||
simple-task/*.yml |
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,70 @@ | ||
Description | ||
=========== | ||
|
||
A very very simple task manager. I am hoping to turn this into a more | ||
comprehensive tool, but for now it just keeps track of a list of tasks. | ||
Note that it will create a .yml file wherever you store it, which is how | ||
it will propagate the tasks. | ||
|
||
Usage | ||
===== | ||
|
||
These examples assume you have this script set up to run as `$ task` | ||
|
||
There are 5 ways to use this script: | ||
|
||
* List out the tasks with `$ task` or `$ task [cmd]` where | ||
cmd is 'show' , 'list' , 'all' , or 'display' | ||
* Create a new task with `$ task [cmd] [position] [task]` where | ||
cmd is 'new' , 'add' , 'create' , or 'touch' | ||
|
||
The position will default to the last element. | ||
Examples: | ||
|
||
* `$ task add Finish assignment for Friday` | ||
* `$ task create 0 Pick up milk` | ||
* Reorder the task list with `$ task [cmd] [from index] [to index]` | ||
where from command is 'mv' , 'move' , 'switch' , 'swap' , | ||
'prioritize' , 'reprioritize' , 'pr' , 'promote' , or 'emphasize' | ||
|
||
The to index will default to zero, so that prioritizing any given | ||
task will cause it to become the first task in the list if a destination | ||
is not specified. | ||
* Delete a task with `$ task [cmd] [index]` where cmd is 'del' , 'delete' , | ||
'complte' , 'finish' , 'done' , 'rm' , 'destroy' , or 'mark' | ||
Example: `$ task del 0` will mark off the task in index 0 | ||
* Clear the task list with `$ task [cmd]` where cmd is 'cl' , 'clear' , | ||
'clean' , 'wipe' , 'erase' , 'delete-all' , 'delete_all' , 'destroy-all' , | ||
'destroy_all' , or 'reset' | ||
* Get help with `$ task [cmd]` where cmd is anything not in the above list | ||
(ie `$ taskhelp` will work) The help command simply prints out the case | ||
statement that determines how to handle the input | ||
|
||
|
||
--------------------------------------- | ||
|
||
**This code is unmaintained.** | ||
|
||
_If you do something interesting with it, let me know so I can be happy._ | ||
|
||
--------------------------------------- | ||
|
||
Copyright (c) 2010 Joshua Cheek | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,71 @@ | ||
#! /usr/bin/env ruby | ||
require 'yaml' | ||
YAML_FILE = File.dirname(__FILE__) + '/tasks.yml' | ||
|
||
module Task | ||
|
||
def all | ||
reset unless File.exist? YAML_FILE | ||
@tasks ||= YAML.load File.read(YAML_FILE) | ||
end | ||
|
||
def reset | ||
@tasks = [] | ||
save | ||
end | ||
|
||
def save | ||
File.open(YAML_FILE,'w') { |file| file.print YAML.dump(all) } | ||
end | ||
|
||
def add( task , position=nil ) | ||
if position.nil? | ||
all << task | ||
else | ||
all.insert position.to_i , task | ||
end | ||
save | ||
end | ||
|
||
def swap( index1 , index2 ) | ||
index1 , index2 = index1.to_i , index2.to_i | ||
all[index1] , all[index2] = all[index2] , all[index1] | ||
save | ||
end | ||
|
||
def delete(index) | ||
task = all.delete_at index.to_i | ||
save | ||
end | ||
|
||
def count | ||
all.size | ||
end | ||
|
||
def print | ||
all.each_with_index { |task,index| printf "%#{count.to_s.size}d - #{task}\n" , index } | ||
end | ||
|
||
end | ||
include Task | ||
|
||
|
||
case ARGV.shift | ||
when nil , 'show' , 'list' , 'all' , 'display' | ||
when 'new' , 'add' , 'create' , 'touch' | ||
location = if ARGV.first =~ /\A\d+\Z/ then ARGV.shift.to_i else nil end | ||
add ARGV.join(' ') , location | ||
when 'mv' , 'move' , 'switch' , 'swap' , 'prioritize' , 'reprioritize' , 'pr' , 'promote' , 'emphasize' | ||
ARGV << 0 if ARGV.size == 1 | ||
swap *ARGV | ||
when 'del' , 'delete' , 'complte' , 'finish' , 'done' , 'rm' , 'destroy' , 'mark' | ||
delete ARGV.shift | ||
when 'cl' , 'clear' , 'clean' , 'wipe' , 'erase' , 'delete-all' , 'delete_all' , 'destroy-all' , 'destroy_all' , 'reset' | ||
reset | ||
else | ||
puts File.read(__FILE__)[/^case.*\Z/m] | ||
end |