wikibase-cli 15.15.6 → 15.16.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/bin/wb-claims +1 -0
- package/bin/wb-props +1 -1
- package/lib/get_pattern_filter.js +19 -2
- package/lib/log_claims.js +1 -1
- package/metadata/claims.js +1 -1
- package/metadata/props.js +1 -0
- package/package.json +2 -2
package/bin/wb-claims
CHANGED
package/bin/wb-props
CHANGED
|
@@ -4,7 +4,7 @@ const { red } = require('chalk')
|
|
|
4
4
|
|
|
5
5
|
program
|
|
6
6
|
.option('-d, --details', 'include properties labels, types, descriptions, and aliases')
|
|
7
|
-
.option('-t, --type', 'include properties types')
|
|
7
|
+
.option('-t, --type [type]', 'include properties types, or if a type is specified, keep only properties with that type')
|
|
8
8
|
.option('--no-cache', 'ignore properties cache')
|
|
9
9
|
.option('-r, --reset', 'clear properties cache')
|
|
10
10
|
.process('props')
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
const program = require('./program')
|
|
1
2
|
const { propTypes } = require('./properties')
|
|
2
3
|
|
|
3
4
|
module.exports = (pattern, includeTypes) => {
|
|
4
|
-
|
|
5
|
+
const { type } = program
|
|
6
|
+
if (!(pattern && pattern.length > 0)) {
|
|
7
|
+
if (typeof type === 'string') {
|
|
8
|
+
// Consider that what was passed as a type argument was actually a pattern
|
|
9
|
+
if (!(type.toLowerCase() in propTypes)) pattern = type
|
|
10
|
+
} else {
|
|
11
|
+
return
|
|
12
|
+
}
|
|
13
|
+
}
|
|
5
14
|
|
|
6
|
-
if (includeTypes && pattern in propTypes) {
|
|
15
|
+
if (includeTypes && pattern.toLowerCase() in propTypes) {
|
|
7
16
|
return propData => propData.type === pattern
|
|
8
17
|
}
|
|
9
18
|
|
|
@@ -13,7 +22,15 @@ module.exports = (pattern, includeTypes) => {
|
|
|
13
22
|
const flag = allLowercased ? 'ig' : 'g'
|
|
14
23
|
const filterRegex = new RegExp(pattern, flag)
|
|
15
24
|
|
|
25
|
+
let typeFilter
|
|
26
|
+
if (typeof type === 'string' && type.toLowerCase() in propTypes) {
|
|
27
|
+
typeFilter = propData => propData.type === type
|
|
28
|
+
} else {
|
|
29
|
+
typeFilter = () => true
|
|
30
|
+
}
|
|
31
|
+
|
|
16
32
|
const filterFn = propData => {
|
|
33
|
+
if (!typeFilter(propData)) return false
|
|
17
34
|
if (propData == null) return false
|
|
18
35
|
const { label, description, aliases } = propData
|
|
19
36
|
const propStr = [ label, description, aliases ].join(' ')
|
package/lib/log_claims.js
CHANGED
|
@@ -16,7 +16,7 @@ module.exports = async ({ program, simplifiedClaims, extraData = {}, pattern, re
|
|
|
16
16
|
|
|
17
17
|
logExtraData(extraData, labels)
|
|
18
18
|
|
|
19
|
-
if (pattern) {
|
|
19
|
+
if (pattern || program.type) {
|
|
20
20
|
simplifiedClaims = filterClaimsProperties(propertiesData, simplifiedClaims, pattern)
|
|
21
21
|
}
|
|
22
22
|
|
package/metadata/claims.js
CHANGED
|
@@ -13,7 +13,7 @@ module.exports = {
|
|
|
13
13
|
examples: [
|
|
14
14
|
{ args: 'Q2001', comment: 'fetch all claims for the entity Q2001' },
|
|
15
15
|
{ args: 'Q2001 P106', comment: 'or just the claims for the property P106' },
|
|
16
|
-
{ args: 'Q2001 Url', comment: 'or just the claims from properties of type Url (other possible types: ExternalId, String, WikibaseItem, WikibaseProperty, Time, Monolingualtext, Quantity, CommonsMedia, GlobeCoordinate)' },
|
|
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
17
|
{ args: 'Q2001 library', comment: 'or just the claims from properties with labels matching "library"' },
|
|
18
18
|
{ args: 'Q2001 website', comment: 'or website, etc' },
|
|
19
19
|
{ args: 'Q2001 --lang de', comment: 'fetch all claims for the entity Q2001 with properties labels in German' }
|
package/metadata/props.js
CHANGED
|
@@ -16,6 +16,7 @@ module.exports = {
|
|
|
16
16
|
{ args: '--details', comment: 'output all properties, with their labels, types, descriptions, and aliases' },
|
|
17
17
|
{ args: 'image', comment: 'filter the properties to keep only those with labels matching "image"' },
|
|
18
18
|
{ args: '--type Url', comment: 'filter the properties to keep only those of type Url (other possible types: ExternalId, String, WikibaseItem, WikibaseProperty, Time, Monolingualtext, Quantity, CommonsMedia, GlobeCoordinate)' },
|
|
19
|
+
{ args: '--type Url ref', comment: 'filter the properties to keep only those of type Url matching the pattern "ref"' },
|
|
19
20
|
{ args: '--lang sv', comment: 'output all the properties with their label in Swedish' },
|
|
20
21
|
{ args: '--no-cache', comment: 'ignore properties cache: fetch properties from the SPARQL endpoint, even if already cached' },
|
|
21
22
|
{ args: '--reset', comment: 'delete all the cached properties files to get fresh versions on the next execution' }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "wikibase-cli",
|
|
3
|
-
"version": "15.
|
|
3
|
+
"version": "15.16.0",
|
|
4
4
|
"description": "A command-line interface to Wikibase",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"read": "^1.0.7",
|
|
50
50
|
"split": "^1.0.1",
|
|
51
51
|
"through": "^2.3.8",
|
|
52
|
-
"wikibase-edit": "^4.
|
|
52
|
+
"wikibase-edit": "^4.16.0",
|
|
53
53
|
"wikibase-sdk": "^7.14.1",
|
|
54
54
|
"wikidata-lang": "^2.0.11"
|
|
55
55
|
},
|