maxlath / wikibase-cli

read and edit a Wikibase instance from the command line
MIT License
223 stars 24 forks source link

wb data with claimid #142

Closed gitonthescene closed 3 years ago

gitonthescene commented 3 years ago

Reading the description of move qualifier it seems to suggest that wd data can be called with a claim id, but when I do I get all the output from the entity rather than just the info from the claim. I was able to filter out what I need with jq, but it might be nice if supplying the claim id took care of this for me. This obviously isn't critical, but I thought I'd mention it.

FWIW, it was an issue for me because I was operating on entities which had several claims with the same property which only differed on their qualifiers. The suggestion in the wd mq doc would have had me matching all of them.

maxlath commented 3 years ago

I suspect that you passed the command without single quotes around the claim id, which means that the dollar sign was interpreted as a shell argument, and that wb data, not finding a claim id, fall back on trying to find anything that looks like an entity id:

# Equivalent to `wb data Q4115189`, will fetch the whole entity data
wb data Q4115189$C654B493-7EAF-46FC-997B-560D8A50F67F
# You can see why by passing that same argument to echo
echo Q4115189$C654B493-7EAF-46FC-997B-560D8A50F67F
# outputs `Q4115189-7EAF-46FC-997B-560D8A50F67F` (unless you have a variable named C654B493 in your environment)

# will fetch only the desired claim
wb data 'Q4115189$C654B493-7EAF-46FC-997B-560D8A50F67F'

To not get into this kind of dollar sign interpretation issues, you may prefer to use the hyphenated claim id syntax, where $ is replaced with a -:

wb data Q4115189-C654B493-7EAF-46FC-997B-560D8A50F67F
gitonthescene commented 3 years ago

Thanks for replying. I'll double check next time.

gitonthescene commented 3 years ago

It might be worth mentioning that the doc for wb data doesn't mention that you can use claim ids. This is another reason I thought it might not yet be implemented. Thanks again.

maxlath commented 3 years ago

It does, but quite far down in the section