marginalia-io 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -0
- data/lib/marginalia-io/api.rb +4 -0
- data/lib/marginalia-io/cli.rb +15 -0
- data/lib/marginalia-io/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
@@ -23,6 +23,7 @@ Or install it yourself as:
|
|
23
23
|
```
|
24
24
|
Tasks:
|
25
25
|
marginalia append ID # Append to the given note
|
26
|
+
marginalia create TITLE # Create a ntew note with the given title
|
26
27
|
marginalia edit ID # Edit the given note in the editor
|
27
28
|
marginalia help [TASK] # Describe available tasks or one specific task
|
28
29
|
marginalia list # List all notes
|
@@ -50,6 +51,9 @@ note_5 = api.get(5) # Get the note with id 5
|
|
50
51
|
api.append(5, "Hi There") # Append "Hi There" with a timestamp to the end of not 5
|
51
52
|
|
52
53
|
api.update(5, "Hello There") # replace the body of note 5 with "Hello There"
|
54
|
+
|
55
|
+
api.create("Title", "Body") # create a note with the given title and body
|
56
|
+
|
53
57
|
```
|
54
58
|
|
55
59
|
|
data/lib/marginalia-io/api.rb
CHANGED
@@ -22,6 +22,10 @@ module Marginalia
|
|
22
22
|
self.class.post("/notes/#{id}/append.json", :body => {:body => body})
|
23
23
|
end
|
24
24
|
|
25
|
+
def create(title, body)
|
26
|
+
self.class.post("/notes.json", :body => {:note => {:body => body, :title => title}})
|
27
|
+
end
|
28
|
+
|
25
29
|
def all
|
26
30
|
self.class.get("/notes.json").parsed_response
|
27
31
|
end
|
data/lib/marginalia-io/cli.rb
CHANGED
@@ -96,6 +96,21 @@ updated: #{note['updated_at']}
|
|
96
96
|
api.append(id, body)
|
97
97
|
end
|
98
98
|
|
99
|
+
desc "create TITLE", "Create a note with the given title"
|
100
|
+
def create(*args)
|
101
|
+
title = args.join(" ")
|
102
|
+
temp = Tempfile.new(['journal', '.md'])
|
103
|
+
system(ENV['EDITOR'], temp.path)
|
104
|
+
body = temp.read
|
105
|
+
if body.strip == ""
|
106
|
+
exit 0
|
107
|
+
end
|
108
|
+
|
109
|
+
resp = api.create(title, body).parsed_response
|
110
|
+
puts "Created note #{resp['id']}"
|
111
|
+
|
112
|
+
end
|
113
|
+
|
99
114
|
default_task :list
|
100
115
|
|
101
116
|
no_tasks do
|