-
-
Save tzarskyz/7404103 to your computer and use it in GitHub Desktop.
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
-------------------------------------------------- | |
-- createnote.applescript | |
-- Evernote Command Line Proxy | |
-- by Maripo Goda <goda.mariko[at]gmail.com> | |
-- Required: | |
-- Mac OS X + AppleScript | |
-- Evernote for Mac OS X | |
-- Perl + JSON.pm | |
-- Usage: | |
-- Create a note with text | |
-- > osascript createnote.applescript '{"title":"Sample Note 1" , "text":"Hello Evernote Local API!"}' | |
-- Create a note with HTML | |
-- > osascript createnote.applescript '{"title":"Sample Note 2" , "html":"<strong>HELLO!!!</strong>"}' | |
-- Create a note from URL | |
-- > osascript createnote.applescript '{"title":"Sample Note 3" , "url":"http://blog.maripo.org"}' | |
-- Create a note from a local file | |
-- > osascript createnote.applescript '{"title":"Sample Note 4" , "file":"/foo/bar/baz.txt"}' | |
-------------------------------------------------- | |
to getJsonPrpoerty(json, propertyName) | |
set shell to "echo '" & json & "' | perl -e \"use JSON;print from_json(<STDIN>)->{" & propertyName & "}\"" | |
set val to do shell script shell | |
return val | |
end getJsonPrpoerty | |
on run argv | |
set myTitle to getJsonPrpoerty(item 1 of argv, "title") | |
set myText to getJsonPrpoerty(item 1 of argv, "text") | |
set myHtml to getJsonPrpoerty(item 1 of argv, "html") | |
set myUrl to getJsonPrpoerty(item 1 of argv, "url") | |
set myFile to getJsonPrpoerty(item 1 of argv, "file") | |
log "title:" & myTitle | |
log "text:" & myText | |
log "html:" & myHtml | |
log "url:" & myUrl | |
log "file:" & myFile | |
tell application "Evernote" | |
set myNote to null | |
if myText is not equal to "" then | |
set myNote to create note title myTitle with text myText | |
else if myHtml is not equal to "" then | |
set myNote to create note title myTitle with html myHtml | |
else if myUrl is not equal to "" then | |
set myNote to create note title myTitle from url myUrl | |
else if myFile is not equal to "" then | |
set myNote to create note title myTitle from file myFile | |
end if | |
end tell | |
end run |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment