Got questions, comments, patches, etc.?
Contact Jason Woofenden
gitweb
/
af-coffee.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
5741a5d
)
errors and warnings to stderr
author
Jason Woofenden
<jason@jasonwoof.com>
Mon, 11 Feb 2013 21:09:43 +0000
(16:09 -0500)
committer
Jason Woofenden
<jason@jasonwoof.com>
Mon, 11 Feb 2013 21:09:43 +0000
(16:09 -0500)
client.coffee
patch
|
blob
|
history
diff --git
a/client.coffee
b/client.coffee
index
8ae4715
..
ccb26b3
100755
(executable)
--- a/
client.coffee
+++ b/
client.coffee
@@
-68,7
+68,7
@@
login = (callback) ->
# wait for file write so there's no race condition if get_token gets called soon
fs.writeFile token_file, token, (err) ->
if err
# wait for file write so there's no race condition if get_token gets called soon
fs.writeFile token_file, token, (err) ->
if err
- console.log "Warning: couldn't cache auth token in #{token_file}: ", err
+ process.stderr.write "Warning: couldn't cache auth token in #{token_file}: #{err}\n"
# don't pass on error, it's ok if we can't cache it
callback null, token
], callback
# don't pass on error, it's ok if we can't cache it
callback null, token
], callback
@@
-78,10
+78,10
@@
exports.new_session = ->
return new Session()
usage = ->
return new Session()
usage = ->
- console.log "usage: #{process.argv[0]} #{process.argv[1]} command [args...]"
- console.log "valid commands are:"
+ process.stderr.write "usage: #{process.argv[0]} #{process.argv[1]} command [args...]\n"
+ process.stderr.write "valid commands are:\n"
for k, v of af
for k, v of af
- console.log "\t#{k}" unless k is 'login'
+ process.stderr.write "\t#{k}\n" unless k is 'login'
# parse and act on commandline arguments unless we were require()d as a module
if require.main is module
# parse and act on commandline arguments unless we were require()d as a module
if require.main is module
@@
-89,12
+89,15
@@
if require.main is module
if args.length is 0
usage()
else if not af[args[0]]
if args.length is 0
usage()
else if not af[args[0]]
- console.log "unknown command \"#{args[0]}\""
+ process.stderr.write "unknown command \"#{args[0]}\"\n"
usage()
else
session = new Session()
session.api args[0], args[1..], (err, result) ->
if err?
usage()
else
session = new Session()
session.api args[0], args[1..], (err, result) ->
if err?
- console.log "error: ", err
+ process.stderr.write "Error: #{JSON.stringify err}\n"
if result?
if result?
- console.log "result: ", result
+ if typeof result is 'string'
+ process.stdout.write result
+ else
+ process.stdout.write JSON.stringify result