Permalink
6983ff3 Jun 26, 2018
2 contributors

Users who have contributed to this file

@maxlath @waldyrious
160 lines (132 sloc) 3.8 KB

Config

Allows to persist options

wd config <key> [value]

Summary

commands

get

# output the current config and the help menu
wd config
# output the config value for the key 'clipboard'
wd config clipboard

set

wd config clipboard true

reset

To reset an option to its current value without having to clear the whole config, pass it the value default

wd config instance default

path

get config file path

wd config path

clear

clear the whole config (use reset if you just want to reset one option)

wd config clear

options

username and password

Required for write operations (Alternatively, we might be able to use OAuth once this issue is resolved)

⚠️ the password is persisted on your file system as clear text (until we find a better way to do that)

wd config username myusername
wd config password myuserpassword

bot

Setting a bot flag on requests made by a bot account is required and can be done by setting the config.bot value:

# Default: false
wd config bot true

lang

set the prefered language (same as -l, --lang)

# Default: process.env.LANG.slice(0, 2)
wd config lang nl

json

format the output of commands as JSON, when possible (same as -j, --json)

# Default: false
wd config json true

clipboard

copy command results to the clipboard, when this option is available (same as -c, --clipboard)

# Default: false
wd config clipboard true

verbose

set commands to print verbose output (same as -v, --verbose)

# Default: false
wd config verbose true

custom Wikibase instance

You may want to use those commands against a different Wikibase than wikidata.org (same as -i, --instance)

# Default: https://wikidata.org/w/api.php
wd config instance https://mywikibase.instance/w/api.php
# Come back to the default setting
wd config instance default

You're all set to make requests against your custom instance:

wd label Q1
wd claims Q1
wd data Q1
wd open Q1

custom SPARQL endpoint

You can also set a custom SPARQL endpoint (same as -e, --sparql-endpoint)

# Default: https://query.wikidata.org/sparql
wd config sparql-endpoint https://example.com/sparql
# Come back to the default setting
wd config sparql-endpoint default

You're all set to make requests against your custom instance:

wd query --property P2002 --object timberners_lee

environment variables

Alternatively to using wd config, you can set environment variables. Priority is given to the command line options, then environment variables, then config values.

export WD_INSTANCE=https://wikibase-registry.wmflabs.org/w/api.php ; wd label Q2
# => Wikidata
export WD_INSTANCE=https://www.wikidata.org/w/api.php ; wd label Q2
# => Earth

Available variables:

  • WD_CLIPBOARD
  • WD_JSON
  • WD_VERBOSE
  • WD_INSTANCE
  • WD_SPARQL_ENDPOINT