7e16a2eb7c
[Yarn] has a handful of subcommand [aliases], but does not automatically
[correct] them for the user. This makes it so that `fuck` will do the
trick. For example:
$ yarn ls
yarn ls v0.20.3
error Did you mean `yarn list`?
info Visit https://yarnpkg.com/en/docs/cli/list for documentation about this command.
$ fuck
yarn list [enter/?/?/ctrl+c]
[Yarn]: https://yarnpkg.com/en/
[aliases]: https://github.com/yarnpkg/yarn/blob/0adbc59b18b38b6ac6e4b248e19788ed1d2e80da/src/cli/aliases.js
[correct]: https://github.com/yarnpkg/yarn/pull/1044#issuecomment-253763230
15 lines
358 B
Python
15 lines
358 B
Python
import re
|
|
from thefuck.utils import replace_argument, for_app
|
|
|
|
|
|
@for_app('yarn', at_least=1)
|
|
def match(command):
|
|
return ('Did you mean' in command.stderr)
|
|
|
|
|
|
def get_new_command(command):
|
|
broken = command.script_parts[1]
|
|
fix = re.findall(r'Did you mean `yarn ([^`]*)`', command.stderr)[0]
|
|
|
|
return replace_argument(command.script, broken, fix)
|