mw-tool-tourbot

2.2.0 • Public • Published

Build Status Tested with QUnit

mw-tool-tourbot

Usage

Screen shot

Getting started

Install the npm package:

npm install -g mw-tool-tourbot

To start the interactive process, run the tourbot program. Pass parameters like tourbot --file path/to/results.txt.

Options

  • --config FILE: Where to store your credentials. Default: $HOME/.config/tourbot/.mwauth.json.
  • --file FILE: File that contains a list of pages to process. Default: results.txt.
  • --all: Enable interactive mode for all page names, even without matches.
  • --contains TEXT: Limit the all iteration to pages that currently contain the given text.
  • --match TEXT: Similar to the contains parameter, but interpreted as a regular expression.
  • --auto: Enable remembering of decisions and re-apply them automatically to similar diffs. Default: off.
  • --help: Show the help page, instead of running the tourbot.

Automation

Once you're comfortable with the basics of Tourbot, there is a great deal of automation you can enable.

Note: If one or more proposed changes on a given file were accepted through automation, Tourbot will always ask for final confirmation before publishing the edit to the wiki. This basically allows you to monitor the automation in real-time without being delayed by keyboard interaction. Then, once done, you can scan through it if desired, and then either accept it all, or cancel the edit.

  • Decision reuse

    When enabling the --auto option (short: -x), Tourbot will remember your Yes/No decision for a proposed change (for the lifetime of the current process).

    Then, when the same line-replacement with the same 5 lines of context is encounted another time (e.g. in another file, on another wiki), it will automatically assume the same decision.

  • Accept all changes (per pattern, per file)

    When you encounter a change, such as replacing $j with $, where it is likely that there are many of these throughout the file, but all slightly different. Then, --auto might not help much. Instead, you could use the "a" (Accept all) response, instead of a regular "y" (Yes).

    In "Accept all" mode, Tourbot will accept all instances of the current pattern over the current file. After that, it will continue as normal for the remaining patterns (not auto-accepted). If there are no further replacement suggestions, it will wait for your final confirmation, to give you a chance to review the auto-accepted changes.

  • Reject all (per pattern, per file)

    When you encounter a proposed change you prefer not to apply, you can choose "n" (No) to reject the change. For example, because the pattern is falsely matching, or because the change might be unsafe. If a pattern has lots of matches like this in the single file, use "r" (Reject all) to skip this pattern, and continue with another.

Examples

Global Search tool

You can use the Global Search tool to find instances of a particular pattern (I recommend the "JS/CSS" preset). Use its "Export as JSON" to save the result to a file, and feed that to Tourbot to get started:

$ tourbot -f global-search.json

  Reading ./global-search.json

  …

mwgrep file

Tourbot was originally developed for use with mwgrep, which is a Wikimedia Foundation production CLI that uses search index and produces results with a pair of (wiki-id, pagename) on each line.

For example:

testwiki            MediaWiki:Gadgets-definition
test2wiki           MediaWiki:Gadget-teahouse/content.js

I sometimes publish search results from that in a Gist. These can be used, like so:

$ curl -O -L 'https://gist.github.com/Krinkle/a18e726fc3af30f30bf9b2ba919820b5/raw/c8c72d371c80c701eb4f6f5422c6ac51c6264f1f/mwgrep.escapeRE.txt'

$ tourbot -f mwgrep.escapeRE.txt

  Reading …/mwgrep.mwCustomEditButtons.txt

  …

Contributing

Install from Git

git clone https://github.com/Krinkle/mw-tool-tourbot.git

Run npm ci once to set up dependencies.

To start the interactive process from source, use ./bin/tourbot.js.

For example, pass parameters like ./bin/tourbot.js --config .mwauth.json --file results.txt.

Development

There is a test suite with good test coverage. Run it with npm test.

See also

Readme

Keywords

Package Sidebar

Install

npm i mw-tool-tourbot

Weekly Downloads

1

Version

2.2.0

License

MIT

Unpacked Size

165 kB

Total Files

16

Last publish

Collaborators

  • krinkle