maxlath / wikibase-cli

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

Editing ranks #113

Closed generalist closed 4 years ago

generalist commented 4 years ago

Another small feature request: is it possible to let us edit ranks using wb update-claim or wb add-claim?

It would be really useful to be able to change ranks for specific claims using their guid - for example, when adding newer data, to add a new claim, set the new claim to preferred, and set the old preferred one to normal.

(& thanks! wb-cli remains a really useful tool all the time)

maxlath commented 4 years ago

so it was already possible to edit ranks using wb edit-entity:

wb edit-entity '{"id": "Q4115189", "claims":{"P6089": { "rank": "preferred", "value": 123}}}'

but now (v14.1.0) it's also possible from wb add-claim and wb update-claim with the --rank parameter:

# Add a statement with a preferred rank
wd ac Q4115189 P527 Q34679 --rank preferred
# Update both the claim rank and value
wd uc 'Q4115189$F00E22C2-AEF7-4145-A743-2AB6292ABFA3' foo --rank preferred
# Only update the rank
wd uc 'Q4115189$F00E22C2-AEF7-4145-A743-2AB6292ABFA3' --rank preferred
maxlath commented 4 years ago

It is now also possible with the object interface:

wb uc '{ "guid": "Q1$EB704042-9821-44FB-96CB-7E1D7B7741C5", "rank": "deprecated" }'

meaning that it can also be used in batch with different ranks:

echo '
{ "guid": "Q1$d941fe74-4a76-a143-6766-a24d2ef2ddad", "newValue": "foo", "rank": "preferred" }
{ "guid": "Q1$63ef3ef4-4499-110a-3f66-33b352b61520", "newValue": "bar" }
{ "guid": "Q1$aaa3162d-4faa-6761-a8e6-f5e6a639afd5", "rank": "deprecated" }
{ "guid": "Q1$b1a0d905-4f20-065d-4aa7-787ea29c5af1", "rank": "normal" }
' | wb uc --batch