sourcegraph / src-cli

Sourcegraph CLI
https://sourcegraph.com
Apache License 2.0
278 stars 62 forks source link

src-cli doesn't accept numeric arguments #30

Open dadlerj opened 6 years ago

dadlerj commented 6 years ago

Running the following command:

echo 'query DependencyReferences($repoPath: String!, $commitID: String!, $filePath: String!, $mode: String!, $line: Int!, $character: Int!) {
    repository(uri: $repoPath) {
      commit(rev: $commitID) {
        file(path: $filePath) {
          dependencyReferences(Language: $mode, Line: $line, Character: $character) {
            repoData {
              repos {
                id
                uri
                lastIndexedRevOrLatest {
                  oid
                }
              }
              repoIds
            }
          }
        }
      }
    }
  }
  ' | src api 'repoPath=github.com/gorilla/mux' 'commitID=cb4698366aa625048f3b815af6a0dea8aef9280a' 'mode=go' 'filePath=mux.go' 'line=23' 'char=5'

Returns:

{
  "data": {
    "repository": {
      "commit": {
        "file": {}
      }
    }
  },
  "errors": [
    {
      "message": "could not unmarshal \"23\" (string) into int32: incompatible type"
    }
  ]
}

Is there a way to specify types for args?

(not urgent, just noticed this while working on https://github.com/sourcegraph/sourcegraph/issues/11753)

slimsag commented 6 years ago

I agree this looks like an oversight/bug and should be possible.


One immediate workaround is to use the -vars flag to pass JSON variables. e.g.

echo ... | src api -vars '{"repoPath":"github.com/gorilla/mux", "commitID":"cb4698366aa625048f3b815af6a0dea8aef9280a", "mode":"go", "filePath":"mux.go", "line": 23, "char": 5}'
dadlerj commented 6 years ago

Nice, missed that option!

stale[bot] commented 6 years ago

This issue has not had any recent activity. To keep our open issue list representative of our actual priorities, it will be closed if no further activity occurs. If this issue should stay open, simply remove the stale label. Thank you for your contributions.

stale[bot] commented 6 years ago

This issue has not had any recent activity. To keep our open issue list representative of our actual priorities, it will be closed if no further activity occurs. If this issue should stay open, simply remove the stale label. Thank you for your contributions.