Created
April 25, 2014 07:56
-
-
Save littleq0903/11281330 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/env lsc | |
/* | |
Link Preview for command-line | |
*/ | |
require! readability: "node-readability" | |
require! program: commander | |
require! request | |
# Functions | |
show-info = (title, url) !-> | |
console.log "Title: #{title}" if program.title? | |
console.log "URL: #{url}" if program.url? | |
parse = (url) -> | |
http-option = do | |
uri: url | |
error, res, body <-! request http-option | |
ed-error, parse-result, meta <-! readability body | |
show-info parse-result.title, url | |
# Commander | |
program | |
.command '*' | |
.description "url to fetch" | |
.action (preview-url) -> | |
parse preview-url | |
program | |
.version '0.0.1' | |
.option '-t, --title', 'Show title' | |
.option '-u, --url', 'Show URL' | |
program.parse process.argv | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment