wikibase-cli 19.4.2 → 20.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -4
- package/bin/wb-claims.js +1 -1
- package/bin/wb-config.js +1 -1
- package/bin/wb-graph-path.js +85 -0
- package/bin/wb-props.js +1 -1
- package/bin/wb-query.js +6 -1
- package/bin/wb-search.js +1 -1
- package/lib/common_errors.js +1 -1
- package/lib/config/config.js +1 -1
- package/lib/config/credentials_config.js +1 -1
- package/lib/debug.js +1 -1
- package/lib/edit/assert_credentials.js +1 -1
- package/lib/edit/edit_command.js +1 -1
- package/lib/edit/init_credentials.js +1 -1
- package/lib/edit/prompt.js +1 -1
- package/lib/entity_attribute_command.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/exit_on_missing.js +1 -1
- package/lib/fetch_lang_props.js +1 -1
- package/lib/get_claims_texts.js +1 -3
- package/lib/log_claims.js +1 -1
- package/lib/log_command_examples.js +1 -1
- package/lib/make_sparql_query.js +1 -1
- package/lib/object_arg_parser.js +1 -1
- package/lib/output.js +1 -1
- package/lib/properties.js +1 -1
- package/lib/reset_properties.js +1 -1
- package/lib/summary_parser.js +2 -2
- package/lib/tabularize.js +1 -1
- package/metadata/add-alias.js +3 -3
- package/metadata/add-badge.js +1 -1
- package/metadata/add-claim.js +2 -2
- package/metadata/add-qualifier.js +7 -7
- package/metadata/add-reference.js +3 -3
- package/metadata/aliases.js +3 -3
- package/metadata/badges.js +1 -1
- package/metadata/claims.js +7 -7
- package/metadata/config.js +11 -11
- package/metadata/convert.js +4 -4
- package/metadata/create-entity.js +3 -3
- package/metadata/data.js +8 -8
- package/metadata/delete-entity.js +2 -2
- package/metadata/description.js +3 -3
- package/metadata/edit-entity.js +5 -5
- package/metadata/generate-template.js +6 -6
- package/metadata/graph-path.js +18 -0
- package/metadata/id.js +3 -3
- package/metadata/label.js +4 -4
- package/metadata/lang.js +3 -3
- package/metadata/lemma.js +3 -3
- package/metadata/merge-entity.js +1 -1
- package/metadata/move-claim.js +7 -7
- package/metadata/move-qualifier.js +3 -3
- package/metadata/open.js +12 -12
- package/metadata/props.js +10 -10
- package/metadata/query.js +15 -15
- package/metadata/remove-alias.js +3 -3
- package/metadata/remove-badge.js +1 -1
- package/metadata/remove-claim.js +2 -2
- package/metadata/remove-description.js +1 -1
- package/metadata/remove-label.js +1 -1
- package/metadata/remove-qualifier.js +3 -3
- package/metadata/remove-reference.js +3 -3
- package/metadata/remove-sitelink.js +1 -1
- package/metadata/revisions.js +5 -5
- package/metadata/search.js +5 -5
- package/metadata/set-alias.js +3 -3
- package/metadata/set-description.js +2 -2
- package/metadata/set-label.js +2 -2
- package/metadata/set-sitelink.js +1 -1
- package/metadata/sparql.js +9 -9
- package/metadata/summary.js +4 -4
- package/metadata/update-claim.js +3 -3
- package/metadata/update-qualifier.js +7 -7
- package/package.json +3 -3
- package/lib/chalk.js +0 -13
package/README.md
CHANGED
|
@@ -55,7 +55,7 @@ See [CHANGELOG.md](CHANGELOG.md) for version info
|
|
|
55
55
|
## Dependencies
|
|
56
56
|
|
|
57
57
|
### General
|
|
58
|
-
* [
|
|
58
|
+
* [NodeJS](https://nodejs.org) **>= v20.12.0** (Older NodeJS versions can be used for older wikibase-cli version, see [changelogs](./CHANGELOG.md). Recommendable way to install NodeJS: you may use [NVM](https://github.com/creationix/nvm) to install the latest LTS version `nvm install --lts`)
|
|
59
59
|
* [Git](https://git-scm.com/)
|
|
60
60
|
|
|
61
61
|
### Per feature
|
|
@@ -124,9 +124,7 @@ export DEBUG=wikibase-cli:request ; wd label Q1
|
|
|
124
124
|
* [wikibase-sdk](https://www.npmjs.com/package/wikibase-sdk): A javascript tool suite to query and work with Wikibase data, heavily used by wikibase-cli
|
|
125
125
|
* [wikibase-edit](https://www.npmjs.com/package/wikibase-edit): Edit Wikibase from NodeJS, used in wikibase-cli for all [write operations](docs/write_operations.md)
|
|
126
126
|
* [wikibase-dump-filter](https://npmjs.com/package/wikibase-dump-filter): Filter and format a newline-delimited JSON stream of Wikibase entities
|
|
127
|
-
* [wikidata-
|
|
128
|
-
* [wikidata-taxonomy](https://github.com/nichtich/wikidata-taxonomy): A command-line tool to extract taxonomies from Wikidata
|
|
129
|
-
* [import-wikidata-dump-to-couchdb](https://github.com/maxlath/import-wikidata-dump-to-couchdb): Import a subset or a full Wikidata dump into a CouchDB database
|
|
127
|
+
* [wikidata-taxonomy](https://www.npmjs.com/package/wikidata-taxonomy): A command-line tool to extract taxonomies from Wikidata
|
|
130
128
|
* [Other Wikidata external tools](https://www.wikidata.org/wiki/Wikidata:Tools/External_tools)
|
|
131
129
|
|
|
132
130
|
## You may also like
|
package/bin/wb-claims.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { yellow } from 'tiny-chalk'
|
|
2
3
|
import { isPropertyId, simplifyClaims, simplifyPropertyClaims, getStatementsKey } from 'wikibase-sdk'
|
|
3
|
-
import { yellow } from '#lib/chalk'
|
|
4
4
|
import errors_ from '#lib/errors'
|
|
5
5
|
import { exitOnMissingInstance } from '#lib/exit_on_missing'
|
|
6
6
|
import getEntities from '#lib/get_entities'
|
package/bin/wb-config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { green } from '
|
|
2
|
+
import { green } from 'tiny-chalk'
|
|
3
3
|
import { checkConfigFileExistance } from '#lib/config/check_config_file_existance'
|
|
4
4
|
import { config } from '#lib/config/config'
|
|
5
5
|
import { configurateCredentials } from '#lib/config/credentials_config'
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { map, partition, uniq, values, without } from 'lodash-es'
|
|
3
|
+
import { grey } from 'tiny-chalk'
|
|
4
|
+
import { isEntityId, isPropertyId } from 'wikibase-sdk'
|
|
5
|
+
import errors_ from '#lib/errors'
|
|
6
|
+
import { getEntitiesLabels } from '#lib/get_entities_labels'
|
|
7
|
+
import { makeSparqlQuery } from '#lib/make_sparql_query'
|
|
8
|
+
import program from '#lib/program'
|
|
9
|
+
|
|
10
|
+
await program
|
|
11
|
+
.option('-f, --format <format>', 'Available alternative formats: mermaid')
|
|
12
|
+
.process('graph-path')
|
|
13
|
+
|
|
14
|
+
const { args, format } = program
|
|
15
|
+
const [ subject, property, joinedObjects ] = args
|
|
16
|
+
|
|
17
|
+
if (!(subject && property && joinedObjects)) {
|
|
18
|
+
program.helpAndExit(0)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const objects = joinedObjects.split(',')
|
|
22
|
+
|
|
23
|
+
if (!isEntityId(subject)) throw new Error(`invalid subject id: ${subject}`)
|
|
24
|
+
if (!isPropertyId(property)) throw new Error(`invalid property id: ${property}`)
|
|
25
|
+
objects.forEach(object => {
|
|
26
|
+
if (!isEntityId(object)) throw new Error(`invalid object id: ${object}`)
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
const rows = await makeSparqlQuery(`SELECT DISTINCT ?intermediary ?next {
|
|
30
|
+
VALUES (?object) { ${objects.map(object => `(wd:${object})`).join(' ')} }
|
|
31
|
+
wd:${subject} wdt:${property}* ?intermediary .
|
|
32
|
+
?object ^wdt:${property}* ?intermediary .
|
|
33
|
+
OPTIONAL {
|
|
34
|
+
?intermediary wdt:${property} ?next .
|
|
35
|
+
}
|
|
36
|
+
}`)
|
|
37
|
+
|
|
38
|
+
if (rows.length === 0) {
|
|
39
|
+
errors_.exitMessage('no path found')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const intermediaries = uniq(map(rows, 'intermediary'))
|
|
43
|
+
const relevantRows = rows.filter(row => intermediaries.includes(row.next))
|
|
44
|
+
|
|
45
|
+
const allEntityIds = uniq(relevantRows.flatMap(row => values(row)))
|
|
46
|
+
const labels = await getEntitiesLabels(allEntityIds, program.lang)
|
|
47
|
+
|
|
48
|
+
if (format === 'mermaid') {
|
|
49
|
+
let output = 'graph LR\n'
|
|
50
|
+
const getNodeLabel = id => `${labels[id]} (${id})`
|
|
51
|
+
for (const { intermediary, next } of relevantRows) {
|
|
52
|
+
output += `${getNodeLabel(intermediary)} --> ${getNodeLabel(next)}\n`
|
|
53
|
+
}
|
|
54
|
+
console.log(output.trim())
|
|
55
|
+
} else {
|
|
56
|
+
let remainingRows = relevantRows
|
|
57
|
+
let nextSubjects = [ subject ]
|
|
58
|
+
let paths = [ subject ]
|
|
59
|
+
const replacedPaths = []
|
|
60
|
+
|
|
61
|
+
while (remainingRows.length > 0) {
|
|
62
|
+
const newPaths = []
|
|
63
|
+
const [ nextRows, rest ] = partition(remainingRows, ({ intermediary }) => {
|
|
64
|
+
return nextSubjects.includes(intermediary)
|
|
65
|
+
})
|
|
66
|
+
if (rest.length === remainingRows.length) throw new Error('stuck')
|
|
67
|
+
remainingRows = rest
|
|
68
|
+
nextRows.forEach(({ intermediary, next }) => {
|
|
69
|
+
const relevantPaths = paths.filter(path => {
|
|
70
|
+
const pathParts = path.split('.')
|
|
71
|
+
return pathParts.at(-1) === intermediary
|
|
72
|
+
})
|
|
73
|
+
const updatedPaths = relevantPaths.map(path => `${path}.${next}`)
|
|
74
|
+
// Leave the relevantPaths in paths, to let other rows fork them if needed
|
|
75
|
+
replacedPaths.push(...relevantPaths)
|
|
76
|
+
newPaths.push(...updatedPaths)
|
|
77
|
+
})
|
|
78
|
+
nextSubjects = uniq(map(nextRows, 'next'))
|
|
79
|
+
paths = [ ...without(paths, ...replacedPaths), ...newPaths ]
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
for (const path of paths) {
|
|
83
|
+
console.log(path.split('.').map(part => `${labels[part]} ${grey(`(${part})`)}`).join(' → '))
|
|
84
|
+
}
|
|
85
|
+
}
|
package/bin/wb-props.js
CHANGED
package/bin/wb-query.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { grey } from '
|
|
2
|
+
import { grey } from 'tiny-chalk'
|
|
3
|
+
import errors_ from '#lib/errors'
|
|
3
4
|
import { generateDescribeSparqlQuery } from '#lib/generate_describe_sparql_query'
|
|
4
5
|
import { generateSampleSparqlQuery } from '#lib/generate_sample_sparql_query'
|
|
5
6
|
import { generateSelectSparqlQuery } from '#lib/generate_select_sparql_query'
|
|
@@ -30,6 +31,10 @@ await program
|
|
|
30
31
|
.option('-x, --index <variable>', "Return the result as an index, instead of a list, using the passed variable as key (can't be used with the 'raw' option)")
|
|
31
32
|
.process('query')
|
|
32
33
|
|
|
34
|
+
if (program.args.length > 0) {
|
|
35
|
+
errors_.exitMessage('wb query can not have positional arguments', `found positional arguments: ${program.args}`)
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
if (!(program.subject || program.property || program.object || program.describe || program.sample || program.statementProperty)) {
|
|
34
39
|
program.helpAndExit(0)
|
|
35
40
|
}
|
package/bin/wb-search.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { padEnd } from 'lodash-es'
|
|
3
|
-
import { red, grey } from '
|
|
3
|
+
import { red, grey } from 'tiny-chalk'
|
|
4
4
|
import { entityDataParser } from '#lib/entity_data_parser'
|
|
5
5
|
import { exitOnMissingInstance } from '#lib/exit_on_missing'
|
|
6
6
|
import parseEntityType from '#lib/parse_entity_type'
|
package/lib/common_errors.js
CHANGED
package/lib/config/config.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { yellow, green } from '
|
|
1
|
+
import { yellow, green } from 'tiny-chalk'
|
|
2
2
|
import { initCredentials } from '#lib/edit/init_credentials'
|
|
3
3
|
import validateInstanceCredentials from '../edit/validate_instance_credentials.js'
|
|
4
4
|
import errors_ from '../errors.js'
|
package/lib/debug.js
CHANGED
package/lib/edit/edit_command.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { inspect } from 'node:util'
|
|
2
2
|
import split from 'split'
|
|
3
|
+
import { red } from 'tiny-chalk'
|
|
3
4
|
import wbEdit from 'wikibase-edit'
|
|
4
|
-
import { red } from '#lib/chalk'
|
|
5
5
|
import { debug } from '#lib/debug'
|
|
6
6
|
import { config } from '../config/config.js'
|
|
7
7
|
import errors_ from '../errors.js'
|
package/lib/edit/prompt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { max, padEnd, values } from 'lodash-es'
|
|
2
|
-
import { grey, red } from '
|
|
2
|
+
import { grey, red } from 'tiny-chalk'
|
|
3
3
|
import { debug } from '#lib/debug'
|
|
4
4
|
import entityAttributeParser from './entity_attribute_parser.js'
|
|
5
5
|
import { entityDataParser } from './entity_data_parser.js'
|
package/lib/errors.js
CHANGED
package/lib/exit_on_missing.js
CHANGED
package/lib/fetch_lang_props.js
CHANGED
package/lib/get_claims_texts.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
1
|
+
import chalk, { grey, bgWhite, black } from 'tiny-chalk'
|
|
2
2
|
import { isEntityId } from 'wikibase-sdk'
|
|
3
3
|
import { missingProperty } from './common_errors.js'
|
|
4
4
|
import getPropertiesData from './get_properties_data.js'
|
|
5
5
|
import { propTypes } from './properties.js'
|
|
6
6
|
|
|
7
|
-
const { grey, bgWhite, black } = chalk
|
|
8
|
-
|
|
9
7
|
export default async ({ labels, simplifiedClaims, resort, lang }) => {
|
|
10
8
|
const propertiesIds = Object.keys(simplifiedClaims)
|
|
11
9
|
const propertiesData = await getPropertiesData(propertiesIds, lang)
|
package/lib/log_claims.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { chain, compact, max, padEnd, uniq } from 'lodash-es'
|
|
2
|
-
import { bgMagenta, grey } from '
|
|
2
|
+
import { bgMagenta, grey } from 'tiny-chalk'
|
|
3
3
|
import filterClaimsProperties from '#lib/filter_claims_properties'
|
|
4
4
|
import getClaimsTexts from '#lib/get_claims_texts'
|
|
5
5
|
import { getEntitiesLabels } from './get_entities_labels.js'
|
package/lib/make_sparql_query.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { grey } from 'tiny-chalk'
|
|
1
2
|
import { simplifySparqlResults, minimizeSimplifiedSparqlResults, buildBlazeGraphSparqlQueryUrl, buildQLeverSparqlQueryUrl } from 'wikibase-sdk'
|
|
2
|
-
import { grey } from '#lib/chalk'
|
|
3
3
|
import errors_ from '#lib/errors'
|
|
4
4
|
import { exitOnMissingSparqlEndpoint } from '#lib/exit_on_missing'
|
|
5
5
|
import { outputFactory } from '#lib/output'
|
package/lib/object_arg_parser.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync } from 'node:fs'
|
|
2
|
-
import { red } from '
|
|
2
|
+
import { red } from 'tiny-chalk'
|
|
3
3
|
import { readJsonFile } from '#lib/json'
|
|
4
4
|
import { isJsonString, getAbsoluteFileUrl, validateTemplateCommand } from '#lib/utils'
|
|
5
5
|
import { parseReconciliationArg } from './edit/reconciliation.js'
|
package/lib/output.js
CHANGED
package/lib/properties.js
CHANGED
package/lib/reset_properties.js
CHANGED
package/lib/summary_parser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { pick, values } from 'lodash-es'
|
|
2
|
+
import { bgGreen, bgMagenta, bgBlue, grey, white } from 'tiny-chalk'
|
|
2
3
|
import { simplify, getSitelinkUrl } from 'wikibase-sdk'
|
|
3
|
-
import { bgGreen, bgMagenta, bgBlue, grey, white } from '#lib/chalk'
|
|
4
4
|
import entityAttributeParser from '#lib/entity_attribute_parser'
|
|
5
5
|
import logClaims from '#lib/log_claims'
|
|
6
6
|
import { mainProps } from '#lib/properties'
|
|
@@ -69,7 +69,7 @@ const parseEntity = async (entity, params) => {
|
|
|
69
69
|
if (instanceMainProps) properties = instanceMainProps
|
|
70
70
|
}
|
|
71
71
|
claims = program.verbose ? claims : pick(claims, properties)
|
|
72
|
-
const simplifiedClaims = simplify.claims(claims, { keepTypes: true })
|
|
72
|
+
const simplifiedClaims = simplify.claims(claims, { keepTypes: true, timeConverter: 'simple-day' })
|
|
73
73
|
|
|
74
74
|
const extraData = {}
|
|
75
75
|
if (type === 'lexeme') {
|
package/lib/tabularize.js
CHANGED
package/metadata/add-alias.js
CHANGED
|
@@ -3,10 +3,10 @@ import { editCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'aa',
|
|
5
5
|
args: '<entity> <language> <aliases>',
|
|
6
|
-
description: '
|
|
6
|
+
description: 'Add one or several aliases to the list of aliases of an entity in a given language',
|
|
7
7
|
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: 'Q4115189 fr foo', comment: "
|
|
10
|
-
{ args: 'Q4115189 fr "foo|bar|buzz', comment: "
|
|
9
|
+
{ args: 'Q4115189 fr foo', comment: "Add 'foo' to the Sandbox entity (Q4115189) French aliases" },
|
|
10
|
+
{ args: 'Q4115189 fr "foo|bar|buzz', comment: "Add 'foo', 'bar', and 'buzz' to the Sandbox entity (Q4115189) French aliases" },
|
|
11
11
|
],
|
|
12
12
|
}
|
package/metadata/add-badge.js
CHANGED
|
@@ -3,7 +3,7 @@ import { editCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'ab',
|
|
5
5
|
args: '<entity> <site> [badges]',
|
|
6
|
-
description: '
|
|
6
|
+
description: 'Add badges on an existing sitelink, without removing other badges that might already have been set',
|
|
7
7
|
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
9
|
{ args: 'Q4115189 enwikiquote Q17437796,Q17437798', comment: 'Add Q17437796 and Q17437798 badges on Q4115189 enwikiquote sitelink' },
|
package/metadata/add-claim.js
CHANGED
|
@@ -3,9 +3,9 @@ import { editCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'ac',
|
|
5
5
|
args: '<entity> <property> <value>',
|
|
6
|
-
description: '
|
|
6
|
+
description: 'Add a claim to an entity',
|
|
7
7
|
options: { rank: true, reconciliation: true, ...editCommandsOptions },
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: 'Q4115189 P2002 Zorglub', comment: "
|
|
9
|
+
{ args: 'Q4115189 P2002 Zorglub', comment: "Add the Twitter account (P2002) 'Zorglub' to the Sandbox (Q4115189) entity" },
|
|
10
10
|
],
|
|
11
11
|
}
|
|
@@ -3,14 +3,14 @@ import { editCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'aq',
|
|
5
5
|
args: '<claim-guid> <property> <value>',
|
|
6
|
-
description: '
|
|
6
|
+
description: 'Add a qualifier to a claim',
|
|
7
7
|
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P155 'Q13406268'", comment: '
|
|
10
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P1545 'A-123'", comment: '
|
|
11
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P580 '1802-02-26'", comment: '
|
|
12
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 123", comment: '
|
|
13
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 '{\"amount\":123,\"unit\":\"Q4916\"}'", comment: '
|
|
14
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P3132 \"text=les sanglots long des violons de l'automne&language=fr\"", comment: '
|
|
9
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P155 'Q13406268'", comment: 'Entity qualifier' },
|
|
10
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P1545 'A-123'", comment: 'String qualifier' },
|
|
11
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P580 '1802-02-26'", comment: 'Time qualifier' },
|
|
12
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 123", comment: 'Quantity qualifier' },
|
|
13
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P2130 '{\"amount\":123,\"unit\":\"Q4916\"}'", comment: 'Quantity qualifier with a unit' },
|
|
14
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P3132 \"text=les sanglots long des violons de l'automne&language=fr\"", comment: 'Monolingualtext qualifier' },
|
|
15
15
|
],
|
|
16
16
|
}
|
|
@@ -3,10 +3,10 @@ import { editCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'ar',
|
|
5
5
|
args: '<claim-guid> <property> <value>',
|
|
6
|
-
description: '
|
|
6
|
+
description: 'Add a reference to a claim',
|
|
7
7
|
options: editCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P854 'https://example.org/rise-and-box-of-the-holy-sand-box'", comment: '
|
|
10
|
-
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P143 Q60856", comment: '
|
|
9
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P854 'https://example.org/rise-and-box-of-the-holy-sand-box'", comment: 'Add a reference URL (P854) to this claim' },
|
|
10
|
+
{ args: "'Q4115189$E66DBC80-CCC1-4899-90D4-510C9922A04F' P143 Q60856", comment: 'Reference the claim as imported from (P143) Wikipedia in Uyghur (Q60856)' },
|
|
11
11
|
],
|
|
12
12
|
}
|
package/metadata/aliases.js
CHANGED
|
@@ -3,10 +3,10 @@ import { entityAttributeCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'a',
|
|
5
5
|
args: '<entity>',
|
|
6
|
-
description: "
|
|
6
|
+
description: "Display the entity's aliases",
|
|
7
7
|
options: entityAttributeCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: 'Q123', comment: '
|
|
10
|
-
{ args: 'Q123 --lang ja', comment: '
|
|
9
|
+
{ args: 'Q123', comment: 'Fetch the aliases for the entity Q123' },
|
|
10
|
+
{ args: 'Q123 --lang ja', comment: 'Fetch the aliases for the entity Q123 in Japanese' },
|
|
11
11
|
],
|
|
12
12
|
}
|
package/metadata/badges.js
CHANGED
package/metadata/claims.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
alias: 'c',
|
|
3
3
|
args: '<entity> [property]',
|
|
4
|
-
description: '
|
|
4
|
+
description: 'Display the claims of an entity',
|
|
5
5
|
options: {
|
|
6
6
|
lang: true,
|
|
7
7
|
verbose: true,
|
|
@@ -11,11 +11,11 @@ export default {
|
|
|
11
11
|
sparqlEndpoint: true,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
|
-
{ args: 'Q2001', comment: '
|
|
15
|
-
{ args: 'Q2001 P106', comment: '
|
|
16
|
-
{ args: 'Q2001 --type Url', comment: '
|
|
17
|
-
{ args: 'Q2001 library', comment: '
|
|
18
|
-
{ args: 'Q2001 website', comment: '
|
|
19
|
-
{ args: 'Q2001 --lang de', comment: '
|
|
14
|
+
{ args: 'Q2001', comment: 'Fetch all claims for the entity Q2001' },
|
|
15
|
+
{ args: 'Q2001 P106', comment: 'Or just the claims for the property P106' },
|
|
16
|
+
{ args: 'Q2001 --type Url', comment: 'Or just the claims from properties of type Url (other possible types: ExternalId, String, WikibaseItem, WikibaseProperty, Time, Monolingualtext, Quantity, CommonsMedia, GlobeCoordinate)' },
|
|
17
|
+
{ args: 'Q2001 library', comment: 'Or just the claims from properties with labels matching "library"' },
|
|
18
|
+
{ args: 'Q2001 website', comment: 'Or website, etc' },
|
|
19
|
+
{ args: 'Q2001 --lang de', comment: 'Fetch all claims for the entity Q2001 with properties labels in German' },
|
|
20
20
|
],
|
|
21
21
|
}
|
package/metadata/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { grey } from '
|
|
1
|
+
import { grey } from 'tiny-chalk'
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
4
|
args: '<key> [value]',
|
|
5
|
-
description: '
|
|
5
|
+
description: 'Get and set configuration parameters',
|
|
6
6
|
options: {
|
|
7
7
|
lang: false,
|
|
8
8
|
verbose: false,
|
|
@@ -12,15 +12,15 @@ export default {
|
|
|
12
12
|
sparqlEndpoint: false,
|
|
13
13
|
},
|
|
14
14
|
examples: [
|
|
15
|
-
{ args: 'clipboard true', comment: '
|
|
16
|
-
{ args: 'lang nl', comment: '
|
|
17
|
-
{ args: 'instance reset', comment: '
|
|
18
|
-
{ args: 'credentials https://www.wikidata.org', comment: '
|
|
19
|
-
{ args: 'credentials https://localhost:8181 reset', comment: '
|
|
20
|
-
{ args: 'credentials http://localhost:8181 test', comment: '
|
|
21
|
-
{ args: 'path', comment: '
|
|
22
|
-
{ args: 'reset', comment: '
|
|
23
|
-
{ args: `--json > config.json.backup\n ${grey('# to restore it, simply override the current config file')}\n cp config.json.backup $(wb config path)`, comment: '
|
|
15
|
+
{ args: 'clipboard true', comment: 'Always copy results to the clipboard when possible' },
|
|
16
|
+
{ args: 'lang nl', comment: 'Set prefered language to Dutch' },
|
|
17
|
+
{ args: 'instance reset', comment: 'Reset the instance setting to its default value' },
|
|
18
|
+
{ args: 'credentials https://www.wikidata.org', comment: 'Get the credentials for an instance' },
|
|
19
|
+
{ args: 'credentials https://localhost:8181 reset', comment: 'Reset the credentials for an instance' },
|
|
20
|
+
{ args: 'credentials http://localhost:8181 test', comment: 'Test the validity of your credentials for an instance' },
|
|
21
|
+
{ args: 'path', comment: 'Get configuration path' },
|
|
22
|
+
{ args: 'reset', comment: 'Reset configuration' },
|
|
23
|
+
{ args: `--json > config.json.backup\n ${grey('# to restore it, simply override the current config file')}\n cp config.json.backup $(wb config path)`, comment: 'Can be used to backup the config' },
|
|
24
24
|
],
|
|
25
25
|
doc: 'https://github.com/maxlath/wikibase-cli/blob/main/docs/config.md#config',
|
|
26
26
|
}
|
package/metadata/convert.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
args: '',
|
|
3
|
-
description: '
|
|
3
|
+
description: 'Convert batches of external ids to Wikidata ids and vice versa',
|
|
4
4
|
options: {
|
|
5
5
|
lang: false,
|
|
6
6
|
verbose: true,
|
|
@@ -10,8 +10,8 @@ export default {
|
|
|
10
10
|
sparqlEndpoint: true,
|
|
11
11
|
},
|
|
12
12
|
examples: [
|
|
13
|
-
{ args: '-p P268 -o 11865344k 11932251d', comment: '
|
|
14
|
-
{ args: '-p P268 -s Q45 Q140', comment: '
|
|
15
|
-
{ args: '-p P268 -o < ids_list', comment: '
|
|
13
|
+
{ args: '-p P268 -o 11865344k 11932251d', comment: 'Get the Wikidata ids corresponding to those BNF ids' },
|
|
14
|
+
{ args: '-p P268 -s Q45 Q140', comment: 'Get the BNF ids corresponding to those Wikidata ids' },
|
|
15
|
+
{ args: '-p P268 -o < ids_list', comment: 'The same but taking the ids from a file' },
|
|
16
16
|
],
|
|
17
17
|
}
|
|
@@ -8,15 +8,15 @@ export default {
|
|
|
8
8
|
examples: [
|
|
9
9
|
{
|
|
10
10
|
args: "'{\"labels\":{\"en\":\"a label\",\"fr\":\"un label\"},\"descriptions\":{\"en\":\"some description\",\"fr\":\"une description\"},\"claims\":{\"P1775\":[\"Q3576110\",\"Q12206942\"],\"P2002\":\"bulgroz\"}}'",
|
|
11
|
-
comment: '
|
|
11
|
+
comment: 'Pass data as JSON',
|
|
12
12
|
},
|
|
13
13
|
{
|
|
14
14
|
args: './new_entity_data.json',
|
|
15
|
-
comment: '
|
|
15
|
+
comment: 'Pass data as a JSON file path',
|
|
16
16
|
},
|
|
17
17
|
{
|
|
18
18
|
args: './new_entity_data.json --instance http://some/wikibase/instance/w/api.php --sparql-endpoint http://some/sparql/endpoint',
|
|
19
|
-
comment: '
|
|
19
|
+
comment: 'In case you use are not editing wikidata.org, make sure to specify the custom Wikibase instance and its SPARQL endpoint, as claims formatting and validation will depend on properties types that are retrieved from the SPARQL endpoint',
|
|
20
20
|
},
|
|
21
21
|
],
|
|
22
22
|
}
|
package/metadata/data.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export default {
|
|
2
2
|
alias: 'd',
|
|
3
3
|
args: '<entity>',
|
|
4
|
-
description: "
|
|
4
|
+
description: "Output the entity's data",
|
|
5
5
|
options: {
|
|
6
6
|
lang: false,
|
|
7
7
|
verbose: false,
|
|
@@ -11,12 +11,12 @@ export default {
|
|
|
11
11
|
sparqlEndpoint: false,
|
|
12
12
|
},
|
|
13
13
|
examples: [
|
|
14
|
-
{ args: 'Q123', comment: "
|
|
15
|
-
{ args: '--props labels,claims,sitelinks Q123', comment: "
|
|
16
|
-
{ args: '--simplify Q123', comment: '
|
|
17
|
-
{ args: '--simplify --keep ids,references,qualifiers,hashes,nontruthy Q123', comment: '
|
|
18
|
-
{ args: '--simplify --keep all Q123', comment: '
|
|
19
|
-
{ args: 'Q1496 | jq .labels.pt', comment: "
|
|
20
|
-
{ args: '--simplify --keep ids Q123 | jq .claims.P138 -j', comment: '
|
|
14
|
+
{ args: 'Q123', comment: "Fetch Q123's raw data" },
|
|
15
|
+
{ args: '--props labels,claims,sitelinks Q123', comment: "Fetch Q123's labels, claims, and sitelinks only" },
|
|
16
|
+
{ args: '--simplify Q123', comment: 'Fetch Q123 simplified data' },
|
|
17
|
+
{ args: '--simplify --keep ids,references,qualifiers,hashes,nontruthy Q123', comment: 'Simplified Q123 data, but keep some attributes' },
|
|
18
|
+
{ args: '--simplify --keep all Q123', comment: 'Same as above' },
|
|
19
|
+
{ args: 'Q1496 | jq .labels.pt', comment: "Take advantage of the raw data being output as JSON\n # to pass it to jq (a JSON parsers https://jqlang.github.io/jq/)\n # and get only the piece of data you're looking for" },
|
|
20
|
+
{ args: '--simplify --keep ids Q123 | jq .claims.P138 -j', comment: 'Get Q123 P138 claims ids' },
|
|
21
21
|
],
|
|
22
22
|
}
|
package/metadata/description.js
CHANGED
|
@@ -3,10 +3,10 @@ import { entityAttributeCommandsOptions } from '#lib/common_options'
|
|
|
3
3
|
export default {
|
|
4
4
|
alias: 'desc',
|
|
5
5
|
args: '<entity>',
|
|
6
|
-
description: "
|
|
6
|
+
description: "Display the entity's description",
|
|
7
7
|
options: entityAttributeCommandsOptions,
|
|
8
8
|
examples: [
|
|
9
|
-
{ args: 'Q123', comment: '
|
|
10
|
-
{ args: 'Q123 --lang ja', comment: '
|
|
9
|
+
{ args: 'Q123', comment: 'Fetch the description for the entity Q123' },
|
|
10
|
+
{ args: 'Q123 --lang ja', comment: 'Fetch the description for the entity Q123 in Japanese' },
|
|
11
11
|
],
|
|
12
12
|
}
|