thefuck-leeguoo 3.41__py2.py3-none-any.whl

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.
Files changed (218) hide show
  1. thefuck/__init__.py +0 -0
  2. thefuck/ai.py +765 -0
  3. thefuck/argument_parser.py +96 -0
  4. thefuck/conf.py +141 -0
  5. thefuck/const.py +111 -0
  6. thefuck/corrector.py +92 -0
  7. thefuck/entrypoints/__init__.py +0 -0
  8. thefuck/entrypoints/alias.py +28 -0
  9. thefuck/entrypoints/fix_command.py +105 -0
  10. thefuck/entrypoints/main.py +50 -0
  11. thefuck/entrypoints/not_configured.py +201 -0
  12. thefuck/entrypoints/setup.py +227 -0
  13. thefuck/entrypoints/shell_logger.py +79 -0
  14. thefuck/exceptions.py +10 -0
  15. thefuck/logs.py +255 -0
  16. thefuck/output_readers/__init__.py +20 -0
  17. thefuck/output_readers/read_log.py +108 -0
  18. thefuck/output_readers/rerun.py +72 -0
  19. thefuck/output_readers/shell_logger.py +60 -0
  20. thefuck/rules/__init__.py +0 -0
  21. thefuck/rules/adb_unknown_command.py +54 -0
  22. thefuck/rules/ag_literal.py +10 -0
  23. thefuck/rules/apt_get.py +50 -0
  24. thefuck/rules/apt_get_search.py +14 -0
  25. thefuck/rules/apt_invalid_operation.py +63 -0
  26. thefuck/rules/apt_list_upgradable.py +16 -0
  27. thefuck/rules/apt_upgrade.py +16 -0
  28. thefuck/rules/aws_cli.py +17 -0
  29. thefuck/rules/az_cli.py +17 -0
  30. thefuck/rules/brew_cask_dependency.py +33 -0
  31. thefuck/rules/brew_install.py +24 -0
  32. thefuck/rules/brew_link.py +15 -0
  33. thefuck/rules/brew_reinstall.py +19 -0
  34. thefuck/rules/brew_uninstall.py +14 -0
  35. thefuck/rules/brew_unknown_command.py +82 -0
  36. thefuck/rules/brew_update_formula.py +12 -0
  37. thefuck/rules/cargo.py +6 -0
  38. thefuck/rules/cargo_no_command.py +15 -0
  39. thefuck/rules/cat_dir.py +14 -0
  40. thefuck/rules/cd_correction.py +61 -0
  41. thefuck/rules/cd_cs.py +21 -0
  42. thefuck/rules/cd_mkdir.py +21 -0
  43. thefuck/rules/cd_parent.py +16 -0
  44. thefuck/rules/chmod_x.py +15 -0
  45. thefuck/rules/choco_install.py +25 -0
  46. thefuck/rules/composer_not_command.py +22 -0
  47. thefuck/rules/conda_mistype.py +17 -0
  48. thefuck/rules/cp_create_destination.py +15 -0
  49. thefuck/rules/cp_omitting_directory.py +15 -0
  50. thefuck/rules/cpp11.py +12 -0
  51. thefuck/rules/dirty_untar.py +53 -0
  52. thefuck/rules/dirty_unzip.py +60 -0
  53. thefuck/rules/django_south_ghost.py +8 -0
  54. thefuck/rules/django_south_merge.py +8 -0
  55. thefuck/rules/dnf_no_such_command.py +37 -0
  56. thefuck/rules/docker_image_being_used_by_container.py +20 -0
  57. thefuck/rules/docker_login.py +13 -0
  58. thefuck/rules/docker_not_command.py +49 -0
  59. thefuck/rules/dry.py +15 -0
  60. thefuck/rules/fab_command_not_found.py +38 -0
  61. thefuck/rules/fix_alt_space.py +15 -0
  62. thefuck/rules/fix_file.py +80 -0
  63. thefuck/rules/gem_unknown_command.py +36 -0
  64. thefuck/rules/git_add.py +27 -0
  65. thefuck/rules/git_add_force.py +13 -0
  66. thefuck/rules/git_bisect_usage.py +16 -0
  67. thefuck/rules/git_branch_0flag.py +24 -0
  68. thefuck/rules/git_branch_delete.py +13 -0
  69. thefuck/rules/git_branch_delete_checked_out.py +19 -0
  70. thefuck/rules/git_branch_exists.py +25 -0
  71. thefuck/rules/git_branch_list.py +14 -0
  72. thefuck/rules/git_checkout.py +49 -0
  73. thefuck/rules/git_clone_git_clone.py +12 -0
  74. thefuck/rules/git_clone_missing.py +42 -0
  75. thefuck/rules/git_commit_add.py +17 -0
  76. thefuck/rules/git_commit_amend.py +11 -0
  77. thefuck/rules/git_commit_reset.py +11 -0
  78. thefuck/rules/git_diff_no_index.py +16 -0
  79. thefuck/rules/git_diff_staged.py +13 -0
  80. thefuck/rules/git_fix_stash.py +37 -0
  81. thefuck/rules/git_flag_after_filename.py +31 -0
  82. thefuck/rules/git_help_aliased.py +12 -0
  83. thefuck/rules/git_hook_bypass.py +27 -0
  84. thefuck/rules/git_lfs_mistype.py +18 -0
  85. thefuck/rules/git_main_master.py +16 -0
  86. thefuck/rules/git_merge.py +18 -0
  87. thefuck/rules/git_merge_unrelated.py +12 -0
  88. thefuck/rules/git_not_command.py +18 -0
  89. thefuck/rules/git_pull.py +16 -0
  90. thefuck/rules/git_pull_clone.py +13 -0
  91. thefuck/rules/git_pull_uncommitted_changes.py +14 -0
  92. thefuck/rules/git_push.py +44 -0
  93. thefuck/rules/git_push_different_branch_names.py +12 -0
  94. thefuck/rules/git_push_force.py +18 -0
  95. thefuck/rules/git_push_pull.py +20 -0
  96. thefuck/rules/git_push_without_commits.py +12 -0
  97. thefuck/rules/git_rebase_merge_dir.py +17 -0
  98. thefuck/rules/git_rebase_no_changes.py +13 -0
  99. thefuck/rules/git_remote_delete.py +13 -0
  100. thefuck/rules/git_remote_seturl_add.py +12 -0
  101. thefuck/rules/git_rm_local_modifications.py +19 -0
  102. thefuck/rules/git_rm_recursive.py +16 -0
  103. thefuck/rules/git_rm_staged.py +19 -0
  104. thefuck/rules/git_stash.py +15 -0
  105. thefuck/rules/git_stash_pop.py +18 -0
  106. thefuck/rules/git_tag_force.py +13 -0
  107. thefuck/rules/git_two_dashes.py +14 -0
  108. thefuck/rules/go_run.py +16 -0
  109. thefuck/rules/go_unknown_command.py +28 -0
  110. thefuck/rules/gradle_no_task.py +34 -0
  111. thefuck/rules/gradle_wrapper.py +13 -0
  112. thefuck/rules/grep_arguments_order.py +23 -0
  113. thefuck/rules/grep_recursive.py +10 -0
  114. thefuck/rules/grunt_task_not_found.py +37 -0
  115. thefuck/rules/gulp_not_task.py +22 -0
  116. thefuck/rules/has_exists_script.py +13 -0
  117. thefuck/rules/heroku_multiple_apps.py +12 -0
  118. thefuck/rules/heroku_not_command.py +11 -0
  119. thefuck/rules/history.py +15 -0
  120. thefuck/rules/hostscli.py +27 -0
  121. thefuck/rules/ifconfig_device_not_found.py +23 -0
  122. thefuck/rules/java.py +17 -0
  123. thefuck/rules/javac.py +18 -0
  124. thefuck/rules/lein_not_task.py +19 -0
  125. thefuck/rules/ln_no_hard_link.py +23 -0
  126. thefuck/rules/ln_s_order.py +26 -0
  127. thefuck/rules/long_form_help.py +27 -0
  128. thefuck/rules/ls_all.py +10 -0
  129. thefuck/rules/ls_lah.py +12 -0
  130. thefuck/rules/man.py +33 -0
  131. thefuck/rules/man_no_space.py +10 -0
  132. thefuck/rules/mercurial.py +27 -0
  133. thefuck/rules/missing_space_before_subcommand.py +21 -0
  134. thefuck/rules/mkdir_p.py +13 -0
  135. thefuck/rules/mvn_no_command.py +11 -0
  136. thefuck/rules/mvn_unknown_lifecycle_phase.py +30 -0
  137. thefuck/rules/nixos_cmd_not_found.py +15 -0
  138. thefuck/rules/no_command.py +41 -0
  139. thefuck/rules/no_such_file.py +30 -0
  140. thefuck/rules/npm_missing_script.py +17 -0
  141. thefuck/rules/npm_run_script.py +17 -0
  142. thefuck/rules/npm_wrong_command.py +42 -0
  143. thefuck/rules/omnienv_no_such_command.py +35 -0
  144. thefuck/rules/open.py +40 -0
  145. thefuck/rules/pacman.py +17 -0
  146. thefuck/rules/pacman_invalid_option.py +20 -0
  147. thefuck/rules/pacman_not_found.py +26 -0
  148. thefuck/rules/path_from_history.py +53 -0
  149. thefuck/rules/php_s.py +11 -0
  150. thefuck/rules/pip_install.py +15 -0
  151. thefuck/rules/pip_unknown_command.py +19 -0
  152. thefuck/rules/port_already_in_use.py +40 -0
  153. thefuck/rules/prove_recursively.py +27 -0
  154. thefuck/rules/python_command.py +17 -0
  155. thefuck/rules/python_execute.py +15 -0
  156. thefuck/rules/python_module_error.py +13 -0
  157. thefuck/rules/quotation_marks.py +12 -0
  158. thefuck/rules/rails_migrations_pending.py +14 -0
  159. thefuck/rules/react_native_command_unrecognized.py +34 -0
  160. thefuck/rules/remove_shell_prompt_literal.py +23 -0
  161. thefuck/rules/remove_trailing_cedilla.py +11 -0
  162. thefuck/rules/rm_dir.py +16 -0
  163. thefuck/rules/rm_root.py +16 -0
  164. thefuck/rules/scm_correction.py +32 -0
  165. thefuck/rules/sed_unterminated_s.py +18 -0
  166. thefuck/rules/sl_ls.py +14 -0
  167. thefuck/rules/ssh_known_hosts.py +37 -0
  168. thefuck/rules/sudo.py +47 -0
  169. thefuck/rules/sudo_command_from_user_path.py +21 -0
  170. thefuck/rules/switch_lang.py +117 -0
  171. thefuck/rules/systemctl.py +22 -0
  172. thefuck/rules/terraform_init.py +13 -0
  173. thefuck/rules/terraform_no_command.py +16 -0
  174. thefuck/rules/test.py.py +10 -0
  175. thefuck/rules/tmux.py +18 -0
  176. thefuck/rules/touch.py +14 -0
  177. thefuck/rules/tsuru_login.py +12 -0
  178. thefuck/rules/tsuru_not_command.py +15 -0
  179. thefuck/rules/unknown_command.py +13 -0
  180. thefuck/rules/unsudo.py +15 -0
  181. thefuck/rules/vagrant_up.py +21 -0
  182. thefuck/rules/whois.py +34 -0
  183. thefuck/rules/workon_doesnt_exists.py +32 -0
  184. thefuck/rules/wrong_hyphen_before_subcommand.py +20 -0
  185. thefuck/rules/yarn_alias.py +14 -0
  186. thefuck/rules/yarn_command_not_found.py +43 -0
  187. thefuck/rules/yarn_command_replaced.py +13 -0
  188. thefuck/rules/yarn_help.py +17 -0
  189. thefuck/rules/yum_invalid_operation.py +39 -0
  190. thefuck/shells/__init__.py +52 -0
  191. thefuck/shells/bash.py +94 -0
  192. thefuck/shells/fish.py +131 -0
  193. thefuck/shells/generic.py +154 -0
  194. thefuck/shells/powershell.py +43 -0
  195. thefuck/shells/tcsh.py +44 -0
  196. thefuck/shells/zsh.py +98 -0
  197. thefuck/specific/__init__.py +0 -0
  198. thefuck/specific/apt.py +3 -0
  199. thefuck/specific/archlinux.py +48 -0
  200. thefuck/specific/brew.py +15 -0
  201. thefuck/specific/dnf.py +3 -0
  202. thefuck/specific/git.py +32 -0
  203. thefuck/specific/nix.py +3 -0
  204. thefuck/specific/npm.py +21 -0
  205. thefuck/specific/sudo.py +18 -0
  206. thefuck/specific/yum.py +3 -0
  207. thefuck/system/__init__.py +7 -0
  208. thefuck/system/unix.py +57 -0
  209. thefuck/system/win32.py +43 -0
  210. thefuck/types.py +261 -0
  211. thefuck/ui.py +116 -0
  212. thefuck/utils.py +385 -0
  213. thefuck_leeguoo-3.41.dist-info/METADATA +681 -0
  214. thefuck_leeguoo-3.41.dist-info/RECORD +218 -0
  215. thefuck_leeguoo-3.41.dist-info/WHEEL +6 -0
  216. thefuck_leeguoo-3.41.dist-info/entry_points.txt +3 -0
  217. thefuck_leeguoo-3.41.dist-info/licenses/LICENSE.md +22 -0
  218. thefuck_leeguoo-3.41.dist-info/top_level.txt +1 -0
@@ -0,0 +1,16 @@
1
+ from thefuck.utils import for_app
2
+ # Appends .go when compiling go files
3
+ #
4
+ # Example:
5
+ # > go run foo
6
+ # error: go run: no go files listed
7
+
8
+
9
+ @for_app('go')
10
+ def match(command):
11
+ return (command.script.startswith('go run ')
12
+ and not command.script.endswith('.go'))
13
+
14
+
15
+ def get_new_command(command):
16
+ return command.script + '.go'
@@ -0,0 +1,28 @@
1
+ from itertools import dropwhile, islice, takewhile
2
+ import subprocess
3
+
4
+ from thefuck.utils import get_closest, replace_argument, for_app, which, cache
5
+
6
+
7
+ def get_golang_commands():
8
+ proc = subprocess.Popen('go', stderr=subprocess.PIPE)
9
+ lines = [line.decode('utf-8').strip() for line in proc.stderr.readlines()]
10
+ lines = dropwhile(lambda line: line != 'The commands are:', lines)
11
+ lines = islice(lines, 2, None)
12
+ lines = takewhile(lambda line: line, lines)
13
+ return [line.split(' ')[0] for line in lines]
14
+
15
+
16
+ if which('go'):
17
+ get_golang_commands = cache(which('go'))(get_golang_commands)
18
+
19
+
20
+ @for_app('go')
21
+ def match(command):
22
+ return 'unknown command' in command.output
23
+
24
+
25
+ def get_new_command(command):
26
+ closest_subcommand = get_closest(command.script_parts[1], get_golang_commands())
27
+ return replace_argument(command.script, command.script_parts[1],
28
+ closest_subcommand)
@@ -0,0 +1,34 @@
1
+ import re
2
+ from subprocess import Popen, PIPE
3
+ from thefuck.utils import for_app, eager, replace_command
4
+
5
+ regex = re.compile(r"Task '(.*)' (is ambiguous|not found)")
6
+
7
+
8
+ @for_app('gradle', 'gradlew')
9
+ def match(command):
10
+ return regex.findall(command.output)
11
+
12
+
13
+ @eager
14
+ def _get_all_tasks(gradle):
15
+ proc = Popen([gradle, 'tasks'], stdout=PIPE)
16
+ should_yield = False
17
+ for line in proc.stdout.readlines():
18
+ line = line.decode().strip()
19
+ if line.startswith('----'):
20
+ should_yield = True
21
+ continue
22
+
23
+ if not line.strip():
24
+ should_yield = False
25
+ continue
26
+
27
+ if should_yield and not line.startswith('All tasks runnable from root project'):
28
+ yield line.split(' ')[0]
29
+
30
+
31
+ def get_new_command(command):
32
+ wrong_task = regex.findall(command.output)[0][0]
33
+ all_tasks = _get_all_tasks(command.script_parts[0])
34
+ return replace_command(command, wrong_task, all_tasks)
@@ -0,0 +1,13 @@
1
+ import os
2
+ from thefuck.utils import for_app, which
3
+
4
+
5
+ @for_app('gradle')
6
+ def match(command):
7
+ return (not which(command.script_parts[0])
8
+ and 'not found' in command.output
9
+ and os.path.isfile('gradlew'))
10
+
11
+
12
+ def get_new_command(command):
13
+ return u'./gradlew {}'.format(' '.join(command.script_parts[1:]))
@@ -0,0 +1,23 @@
1
+ import os
2
+ from thefuck.utils import for_app
3
+
4
+
5
+ def _get_actual_file(parts):
6
+ for part in parts[1:]:
7
+ if os.path.isfile(part) or os.path.isdir(part):
8
+ return part
9
+
10
+
11
+ @for_app('grep', 'egrep')
12
+ def match(command):
13
+ return ': No such file or directory' in command.output \
14
+ and _get_actual_file(command.script_parts)
15
+
16
+
17
+ def get_new_command(command):
18
+ actual_file = _get_actual_file(command.script_parts)
19
+ parts = command.script_parts[::]
20
+ # Moves file to the end of the script:
21
+ parts.remove(actual_file)
22
+ parts.append(actual_file)
23
+ return ' '.join(parts)
@@ -0,0 +1,10 @@
1
+ from thefuck.utils import for_app
2
+
3
+
4
+ @for_app('grep')
5
+ def match(command):
6
+ return 'is a directory' in command.output.lower()
7
+
8
+
9
+ def get_new_command(command):
10
+ return u'grep -r {}'.format(command.script[5:])
@@ -0,0 +1,37 @@
1
+ import re
2
+ from subprocess import Popen, PIPE
3
+ from thefuck.utils import for_app, eager, get_closest, cache
4
+
5
+ regex = re.compile(r'Warning: Task "(.*)" not found.')
6
+
7
+
8
+ @for_app('grunt')
9
+ def match(command):
10
+ return regex.findall(command.output)
11
+
12
+
13
+ @cache('Gruntfile.js')
14
+ @eager
15
+ def _get_all_tasks():
16
+ proc = Popen(['grunt', '--help'], stdout=PIPE)
17
+ should_yield = False
18
+ for line in proc.stdout.readlines():
19
+ line = line.decode().strip()
20
+
21
+ if 'Available tasks' in line:
22
+ should_yield = True
23
+ continue
24
+
25
+ if should_yield and not line:
26
+ return
27
+
28
+ if ' ' in line:
29
+ yield line.split(' ')[0]
30
+
31
+
32
+ def get_new_command(command):
33
+ misspelled_task = regex.findall(command.output)[0].split(':')[0]
34
+ tasks = _get_all_tasks()
35
+ fixed = get_closest(misspelled_task, tasks)
36
+ return command.script.replace(' {}'.format(misspelled_task),
37
+ ' {}'.format(fixed))
@@ -0,0 +1,22 @@
1
+ import re
2
+ import subprocess
3
+ from thefuck.utils import replace_command, for_app, cache
4
+
5
+
6
+ @for_app('gulp')
7
+ def match(command):
8
+ return 'is not in your gulpfile' in command.output
9
+
10
+
11
+ @cache('gulpfile.js')
12
+ def get_gulp_tasks():
13
+ proc = subprocess.Popen(['gulp', '--tasks-simple'],
14
+ stdout=subprocess.PIPE)
15
+ return [line.decode('utf-8')[:-1]
16
+ for line in proc.stdout.readlines()]
17
+
18
+
19
+ def get_new_command(command):
20
+ wrong_task = re.findall(r"Task '(\w+)' is not in your gulpfile",
21
+ command.output)[0]
22
+ return replace_command(command, wrong_task, get_gulp_tasks())
@@ -0,0 +1,13 @@
1
+ import os
2
+ from thefuck.specific.sudo import sudo_support
3
+
4
+
5
+ @sudo_support
6
+ def match(command):
7
+ return command.script_parts and os.path.exists(command.script_parts[0]) \
8
+ and 'command not found' in command.output
9
+
10
+
11
+ @sudo_support
12
+ def get_new_command(command):
13
+ return u'./{}'.format(command.script)
@@ -0,0 +1,12 @@
1
+ import re
2
+ from thefuck.utils import for_app
3
+
4
+
5
+ @for_app('heroku')
6
+ def match(command):
7
+ return 'https://devcenter.heroku.com/articles/multiple-environments' in command.output
8
+
9
+
10
+ def get_new_command(command):
11
+ apps = re.findall('([^ ]*) \\([^)]*\\)', command.output)
12
+ return [command.script + ' --app ' + app for app in apps]
@@ -0,0 +1,11 @@
1
+ import re
2
+ from thefuck.utils import for_app
3
+
4
+
5
+ @for_app('heroku')
6
+ def match(command):
7
+ return 'Run heroku _ to run' in command.output
8
+
9
+
10
+ def get_new_command(command):
11
+ return re.findall('Run heroku _ to run ([^.]*)', command.output)[0]
@@ -0,0 +1,15 @@
1
+ from thefuck.utils import get_close_matches, get_closest, \
2
+ get_valid_history_without_current
3
+
4
+
5
+ def match(command):
6
+ return len(get_close_matches(command.script,
7
+ get_valid_history_without_current(command)))
8
+
9
+
10
+ def get_new_command(command):
11
+ return get_closest(command.script,
12
+ get_valid_history_without_current(command))
13
+
14
+
15
+ priority = 9999
@@ -0,0 +1,27 @@
1
+ import re
2
+ from thefuck.specific.sudo import sudo_support
3
+ from thefuck.utils import replace_command, for_app
4
+
5
+ no_command = "Error: No such command"
6
+ no_website = "hostscli.errors.WebsiteImportError"
7
+
8
+
9
+ @sudo_support
10
+ @for_app('hostscli')
11
+ def match(command):
12
+ errors = [no_command, no_website]
13
+ for error in errors:
14
+ if error in command.output:
15
+ return True
16
+ return False
17
+
18
+
19
+ @sudo_support
20
+ def get_new_command(command):
21
+ if no_website in command.output:
22
+ return ['hostscli websites']
23
+
24
+ misspelled_command = re.findall(
25
+ r'Error: No such command ".*"', command.output)[0]
26
+ commands = ['block', 'unblock', 'websites', 'block_all', 'unblock_all']
27
+ return replace_command(command, misspelled_command, commands)
@@ -0,0 +1,23 @@
1
+ import subprocess
2
+ from thefuck.utils import for_app, replace_command, eager
3
+
4
+
5
+ @for_app('ifconfig')
6
+ def match(command):
7
+ return 'error fetching interface information: Device not found' \
8
+ in command.output
9
+
10
+
11
+ @eager
12
+ def _get_possible_interfaces():
13
+ proc = subprocess.Popen(['ifconfig', '-a'], stdout=subprocess.PIPE)
14
+ for line in proc.stdout.readlines():
15
+ line = line.decode()
16
+ if line and line != '\n' and not line.startswith(' '):
17
+ yield line.split(' ')[0]
18
+
19
+
20
+ def get_new_command(command):
21
+ interface = command.output.split(' ')[0][:-1]
22
+ possible_interfaces = _get_possible_interfaces()
23
+ return replace_command(command, interface, possible_interfaces)
thefuck/rules/java.py ADDED
@@ -0,0 +1,17 @@
1
+ """Fixes common java command mistake
2
+
3
+ Example:
4
+ > java foo.java
5
+ Error: Could not find or load main class foo.java
6
+
7
+ """
8
+ from thefuck.utils import for_app
9
+
10
+
11
+ @for_app('java')
12
+ def match(command):
13
+ return command.script.endswith('.java')
14
+
15
+
16
+ def get_new_command(command):
17
+ return command.script[:-5]
thefuck/rules/javac.py ADDED
@@ -0,0 +1,18 @@
1
+ """Appends .java when compiling java files
2
+
3
+ Example:
4
+ > javac foo
5
+ error: Class names, 'foo', are only accepted if annotation
6
+ processing is explicitly requested
7
+
8
+ """
9
+ from thefuck.utils import for_app
10
+
11
+
12
+ @for_app('javac')
13
+ def match(command):
14
+ return not command.script.endswith('.java')
15
+
16
+
17
+ def get_new_command(command):
18
+ return command.script + '.java'
@@ -0,0 +1,19 @@
1
+ import re
2
+ from thefuck.utils import replace_command, get_all_matched_commands, for_app
3
+ from thefuck.specific.sudo import sudo_support
4
+
5
+
6
+ @sudo_support
7
+ @for_app('lein')
8
+ def match(command):
9
+ return (command.script.startswith('lein')
10
+ and "is not a task. See 'lein help'" in command.output
11
+ and 'Did you mean this?' in command.output)
12
+
13
+
14
+ @sudo_support
15
+ def get_new_command(command):
16
+ broken_cmd = re.findall(r"'([^']*)' is not a task",
17
+ command.output)[0]
18
+ new_cmds = get_all_matched_commands(command.output, 'Did you mean this?')
19
+ return replace_command(command, broken_cmd, new_cmds)
@@ -0,0 +1,23 @@
1
+ # -*- coding: utf-8 -*-
2
+ """Suggest creating symbolic link if hard link is not allowed.
3
+
4
+ Example:
5
+ > ln barDir barLink
6
+ ln: ‘barDir’: hard link not allowed for directory
7
+
8
+ --> ln -s barDir barLink
9
+ """
10
+
11
+ import re
12
+ from thefuck.specific.sudo import sudo_support
13
+
14
+
15
+ @sudo_support
16
+ def match(command):
17
+ return (command.output.endswith("hard link not allowed for directory") and
18
+ command.script_parts[0] == 'ln')
19
+
20
+
21
+ @sudo_support
22
+ def get_new_command(command):
23
+ return re.sub(r'^ln ', 'ln -s ', command.script)
@@ -0,0 +1,26 @@
1
+ import os
2
+ from thefuck.specific.sudo import sudo_support
3
+
4
+
5
+ def _get_destination(script_parts):
6
+ """When arguments order is wrong first argument will be destination."""
7
+ for part in script_parts:
8
+ if part not in {'ln', '-s', '--symbolic'} and os.path.exists(part):
9
+ return part
10
+
11
+
12
+ @sudo_support
13
+ def match(command):
14
+ return (command.script_parts[0] == 'ln'
15
+ and {'-s', '--symbolic'}.intersection(command.script_parts)
16
+ and 'File exists' in command.output
17
+ and _get_destination(command.script_parts))
18
+
19
+
20
+ @sudo_support
21
+ def get_new_command(command):
22
+ destination = _get_destination(command.script_parts)
23
+ parts = command.script_parts[:]
24
+ parts.remove(destination)
25
+ parts.append(destination)
26
+ return ' '.join(parts)
@@ -0,0 +1,27 @@
1
+ from thefuck.utils import replace_argument
2
+ import re
3
+
4
+ # regex to match a suggested help command from the tool output
5
+ help_regex = r"(?:Run|Try) '([^']+)'(?: or '[^']+')? for (?:details|more information)."
6
+
7
+
8
+ def match(command):
9
+ if re.search(help_regex, command.output, re.I) is not None:
10
+ return True
11
+
12
+ if '--help' in command.output:
13
+ return True
14
+
15
+ return False
16
+
17
+
18
+ def get_new_command(command):
19
+ if re.search(help_regex, command.output) is not None:
20
+ match_obj = re.search(help_regex, command.output, re.I)
21
+ return match_obj.group(1)
22
+
23
+ return replace_argument(command.script, '-h', '--help')
24
+
25
+
26
+ enabled_by_default = True
27
+ priority = 5000
@@ -0,0 +1,10 @@
1
+ from thefuck.utils import for_app
2
+
3
+
4
+ @for_app('ls')
5
+ def match(command):
6
+ return command.output.strip() == ''
7
+
8
+
9
+ def get_new_command(command):
10
+ return ' '.join(['ls', '-A'] + command.script_parts[1:])
@@ -0,0 +1,12 @@
1
+ from thefuck.utils import for_app
2
+
3
+
4
+ @for_app('ls')
5
+ def match(command):
6
+ return command.script_parts and 'ls -' not in command.script
7
+
8
+
9
+ def get_new_command(command):
10
+ command = command.script_parts[:]
11
+ command[0] = 'ls -lah'
12
+ return ' '.join(command)
thefuck/rules/man.py ADDED
@@ -0,0 +1,33 @@
1
+ from thefuck.utils import for_app
2
+
3
+
4
+ @for_app('man', at_least=1)
5
+ def match(command):
6
+ return True
7
+
8
+
9
+ def get_new_command(command):
10
+ if '3' in command.script:
11
+ return command.script.replace("3", "2")
12
+ if '2' in command.script:
13
+ return command.script.replace("2", "3")
14
+
15
+ last_arg = command.script_parts[-1]
16
+ help_command = last_arg + ' --help'
17
+
18
+ # If there are no man pages for last_arg, suggest `last_arg --help` instead.
19
+ # Otherwise, suggest `--help` after suggesting other man page sections.
20
+ if command.output.strip() == 'No manual entry for ' + last_arg:
21
+ return [help_command]
22
+
23
+ split_cmd2 = command.script_parts
24
+ split_cmd3 = split_cmd2[:]
25
+
26
+ split_cmd2.insert(1, ' 2 ')
27
+ split_cmd3.insert(1, ' 3 ')
28
+
29
+ return [
30
+ "".join(split_cmd3),
31
+ "".join(split_cmd2),
32
+ help_command,
33
+ ]
@@ -0,0 +1,10 @@
1
+ def match(command):
2
+ return (command.script.startswith(u'man')
3
+ and u'command not found' in command.output.lower())
4
+
5
+
6
+ def get_new_command(command):
7
+ return u'man {}'.format(command.script[3:])
8
+
9
+
10
+ priority = 2000
@@ -0,0 +1,27 @@
1
+ import re
2
+ from thefuck.utils import get_closest, for_app
3
+
4
+
5
+ def extract_possibilities(command):
6
+ possib = re.findall(r'\n\(did you mean one of ([^\?]+)\?\)', command.output)
7
+ if possib:
8
+ return possib[0].split(', ')
9
+ possib = re.findall(r'\n ([^$]+)$', command.output)
10
+ if possib:
11
+ return possib[0].split(' ')
12
+ return possib
13
+
14
+
15
+ @for_app('hg')
16
+ def match(command):
17
+ return ('hg: unknown command' in command.output
18
+ and '(did you mean one of ' in command.output
19
+ or "hg: command '" in command.output
20
+ and "' is ambiguous:" in command.output)
21
+
22
+
23
+ def get_new_command(command):
24
+ script = command.script_parts[:]
25
+ possibilities = extract_possibilities(command)
26
+ script[1] = get_closest(script[1], possibilities)
27
+ return ' '.join(script)
@@ -0,0 +1,21 @@
1
+ from thefuck.utils import get_all_executables, memoize
2
+
3
+
4
+ @memoize
5
+ def _get_executable(script_part):
6
+ for executable in get_all_executables():
7
+ if len(executable) > 1 and script_part.startswith(executable):
8
+ return executable
9
+
10
+
11
+ def match(command):
12
+ return (not command.script_parts[0] in get_all_executables()
13
+ and _get_executable(command.script_parts[0]))
14
+
15
+
16
+ def get_new_command(command):
17
+ executable = _get_executable(command.script_parts[0])
18
+ return command.script.replace(executable, u'{} '.format(executable), 1)
19
+
20
+
21
+ priority = 4000
@@ -0,0 +1,13 @@
1
+ import re
2
+ from thefuck.specific.sudo import sudo_support
3
+
4
+
5
+ @sudo_support
6
+ def match(command):
7
+ return ('mkdir' in command.script
8
+ and 'No such file or directory' in command.output)
9
+
10
+
11
+ @sudo_support
12
+ def get_new_command(command):
13
+ return re.sub('\\bmkdir (.*)', 'mkdir -p \\1', command.script)
@@ -0,0 +1,11 @@
1
+ from thefuck.utils import for_app
2
+
3
+
4
+ @for_app('mvn')
5
+ def match(command):
6
+ return 'No goals have been specified for this build' in command.output
7
+
8
+
9
+ def get_new_command(command):
10
+ return [command.script + ' clean package',
11
+ command.script + ' clean install']
@@ -0,0 +1,30 @@
1
+ from thefuck.utils import for_app, get_close_matches, replace_command
2
+ import re
3
+
4
+
5
+ def _get_failed_lifecycle(command):
6
+ return re.search(r'\[ERROR\] Unknown lifecycle phase "(.+)"',
7
+ command.output)
8
+
9
+
10
+ def _getavailable_lifecycles(command):
11
+ return re.search(
12
+ r'Available lifecycle phases are: (.+) -> \[Help 1\]', command.output)
13
+
14
+
15
+ @for_app('mvn')
16
+ def match(command):
17
+ failed_lifecycle = _get_failed_lifecycle(command)
18
+ available_lifecycles = _getavailable_lifecycles(command)
19
+ return available_lifecycles and failed_lifecycle
20
+
21
+
22
+ def get_new_command(command):
23
+ failed_lifecycle = _get_failed_lifecycle(command)
24
+ available_lifecycles = _getavailable_lifecycles(command)
25
+ if available_lifecycles and failed_lifecycle:
26
+ selected_lifecycle = get_close_matches(
27
+ failed_lifecycle.group(1), available_lifecycles.group(1).split(", "))
28
+ return replace_command(command, failed_lifecycle.group(1), selected_lifecycle)
29
+ else:
30
+ return []
@@ -0,0 +1,15 @@
1
+ import re
2
+ from thefuck.specific.nix import nix_available
3
+ from thefuck.shells import shell
4
+
5
+ regex = re.compile(r'nix-env -iA ([^\s]*)')
6
+ enabled_by_default = nix_available
7
+
8
+
9
+ def match(command):
10
+ return regex.findall(command.output)
11
+
12
+
13
+ def get_new_command(command):
14
+ name = regex.findall(command.output)[0]
15
+ return shell.and_('nix-env -iA {}'.format(name), command.script)