Add yarn_help rule

Yarn likes to keep its documentation online, rather than in `yarn help`
output. For example, `yarn help clean` doesn't tell you anything about
the `clean` subcommand. Instead, it points you towards
https://yarnpkg.com/en/docs/cli/clean

This rule detects when that happens, and suggests opening the URL. One
caveat is the currently only OSX is supported, as Linux uses `xdg-open`
instead of `open`.
This commit is contained in:
Joseph Frazier
2017-03-10 12:54:15 -05:00
parent 7d3ddfc8d9
commit 35ea4dce71
3 changed files with 69 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
import re
from thefuck.utils import for_app
@for_app('yarn', at_least=2)
def match(command):
return command.script_parts[1] == 'help' and ('for documentation about this command.' in command.stdout)
def get_new_command(command):
fix = re.findall(r'Visit ([^ ]*) for documentation about this command.', command.stdout)[0]
return 'open ' + fix