wikibase-cli 16.0.2 → 16.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/bin/wb-merge-entity
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
const program = require('commander')
|
|
3
3
|
const polymorphicCommandArgsParser = require('../lib/polymorphic_command_args_parser')
|
|
4
|
-
|
|
4
|
+
|
|
5
|
+
const inlineArgsParser = args => {
|
|
6
|
+
if (program.keepOldest) {
|
|
7
|
+
const [ newest, oldest ] = getSortedEntitiesIds(args)
|
|
8
|
+
return [ { from: newest, to: oldest } ]
|
|
9
|
+
} else {
|
|
10
|
+
return [ { from: args[0], to: args[1] } ]
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getSortedEntitiesIds = args => {
|
|
15
|
+
return args
|
|
16
|
+
.slice(0, 2)
|
|
17
|
+
.sort((a, b) => getNumericId(b) - getNumericId(a))
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const getNumericId = id => parseInt(id.replace(/^[A-Z]+/i, ''))
|
|
21
|
+
|
|
5
22
|
program.customArgsParser = polymorphicCommandArgsParser(inlineArgsParser)
|
|
6
23
|
program.customHelpOption = require('../lib/command_with_template_custom_help')
|
|
7
24
|
require('../lib/edit/edit_command')('entity', 'merge')
|
|
@@ -11,5 +11,6 @@ module.exports = {
|
|
|
11
11
|
summary: [ '-s, --summary <text>', 'set the edit summary' ],
|
|
12
12
|
baserevid: [ '--baserevid <id>', 'set the baserevid' ],
|
|
13
13
|
maxlag: [ '--maxlag <num>', 'set the maxlag value' ],
|
|
14
|
-
rank: [ '--rank <rank>', 'set the claim rank' ]
|
|
14
|
+
rank: [ '--rank <rank>', 'set the claim rank' ],
|
|
15
|
+
keepOldest: [ '--keep-oldest', 'Merge the newest entity in the oldest one. By default, the arguments order determins which entity is kept: the first entity is merged into the second entity' ],
|
|
15
16
|
}
|
package/metadata/merge-entity.js
CHANGED