maxlath / wikibase-cli

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

adding reference in add-claim batch mode #121

Closed rwst closed 4 years ago

rwst commented 4 years ago

The line wd add-claim <foo with foo being:

["Q24616886", "P921", {"value": "Q29812866", "references": {"P248": "Q96105165"}}]

does add the claim but not the ref. There was no example with ref in the batch mode documentation that I could follow. Can you please clarify?

maxlath commented 4 years ago

wd add-claim is coupled to the wbcreateclaim Wikibase API module which doesn't support adding qualifiers or references. For this kind of edit, you would have more luck with wb entity-edit:

foo:

{"id":"Q24616886","claims":{"P921":{"value":"Q29812866","references":{"P248":"Q96105165"}}}}
{"id":"Q24616887","claims":{"P921":{"value":"Q29812867","references":{"P248":"Q96105165"}}}}
{"id":"Q24616888","claims":{"P921":{"value":"Q29812868","references":{"P248":"Q96105165"}}}}
wd edit-entity --batch < foo
rwst commented 4 years ago

No, actually with foo:

{id:"Q36735136", "claims":{"P921":{"value": "Q29813109", "references": {"P248": "Q96105165"}}}}

ralf@ark:~/wikidata> wd edit-entity --batch <foo
edit group: https://tools.wmflabs.org/editgroups/b/wikibase-cli/2c9ec8f462747/
processing line 1: {id:"Q36735136", "claims":{"P921":{"value": "Q29813109", "references": {"P248": "Q96105165"}}}}
{ Error: Cannot find module '/home/ralf/wikidata/{id:"Q36735136", "claims":{"P921":{"value": "Q29813109", "references": {"P248": "Q96105165"}}}}'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Command.module.exports.args [as customArgsParser] (/usr/lib/node_modules/wikibase-cli/lib/entity_command_args_parser.js:21:26)
    at runOnce (/usr/lib/node_modules/wikibase-cli/lib/edit/edit_command.js:49:20)
    at Stream.<anonymous> (/usr/lib/node_modules/wikibase-cli/lib/edit/edit_command.js:125:15)
    at Stream.emit (events.js:198:13)
    at drain (/usr/lib/node_modules/wikibase-cli/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/usr/lib/node_modules/wikibase-cli/node_modules/through/index.js:45:5) code: 'MODULE_NOT_FOUND' }

I have seen this before...

rwst commented 4 years ago

Argh, the quotes around "id". Sorry!

maxlath commented 4 years ago

@rwst I published a fix 3d2016f in v13.0.1 to get a more relevant error message: a JSON syntax error instead of a "module not found" error

rwst commented 4 years ago

Thanks!