Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix argument passing and result parsing to work with new go-guru binary #39

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/go-oracle-view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class GoOracleView extends View
@li class: 'source', "data-uri": parts[0], parts[1]

@oracle.on 'what-complete', (data) =>
@availableModes = data.what.modes
@availableModes = data.modes

@modes.on 'change', =>
# TODO maybe validate the modes since it shells out?
Expand Down
13 changes: 7 additions & 6 deletions lib/oracle-command.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ module.exports =
class OracleCommand
Emitter.includeInto(this)

oracleCommand: (cmd, format, importPath) ->
oracleCommand: (cmd, format) ->
path = @getPath()
[startOffset, endOffset] = @getPosition()

Expand All @@ -14,16 +14,17 @@ class OracleCommand
oracleCmd = atom.config.get('go-oracle.oraclePath')
oracleCmd = oracleCmd.replace(/^\$GOPATH\//i, gopath)

args = ["-pos=#{path}:##{startOffset}", "-format=#{format}", cmd]
args.push(importPath) if importPath?
args = []
args.push(format) if format
args.push(cmd, "#{path}:##{startOffset}")

console.log "#{oracleCmd} -pos=#{path}:##{startOffset} -format=plain #{cmd} #{importPath}"
console.log "#{oracleCmd} #{args}"

return spawn(oracleCmd, args, {"env": env})

constructor: ->
this.on 'what-complete', (whatData) =>
cmd = @oracleCommand(@nextCommand, "plain", whatData.what.importpath)
cmd = @oracleCommand(@nextCommand)
parsedData = ''
cmd.stdout.on 'data', (data) =>
parsedData = data
Expand All @@ -33,7 +34,7 @@ class OracleCommand
@emit "oracle-complete", @nextCommand, parsedData

what: ->
what = @oracleCommand("what", "json")
what = @oracleCommand("what", "-json")
parsedData = ''
what.stdout.on 'data', (data) =>
parsedData = JSON.parse(data)
Expand Down