File tree Expand file tree Collapse file tree 3 files changed +42
-0
lines changed
Expand file tree Collapse file tree 3 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,7 @@ following rules are enabled by default:
184184* ` chmod_x ` &ndash ; add execution bit;
185185* ` choco_install ` &ndash ; append common suffixes for chocolatey packages;
186186* ` composer_not_command ` &ndash ; fixes composer command name;
187+ * ` conda_mistype ` &ndash ; fixes conda commands;
187188* ` cp_create_destination ` &ndash ; creates a new directory when you attempt to ` cp ` or ` mv ` to a non existent one
188189* ` cp_omitting_directory ` &ndash ; adds ` -a ` when you ` cp ` directory;
189190* ` cpp11 ` &ndash ; adds missing ` -std=c++11 ` to ` g++ ` or ` clang++ ` ;
Original file line number Diff line number Diff line change 1+ import pytest
2+
3+ from thefuck .rules .conda_mistype import match , get_new_command
4+ from thefuck .types import Command
5+
6+
7+ @pytest .fixture
8+ def mistype_response ():
9+ return """
10+
11+ CommandNotFoundError: No command 'conda lst'.
12+ Did you mean 'conda list'?
13+
14+ """
15+
16+
17+ def test_match (mistype_response ):
18+ assert match (Command ('conda lst' , mistype_response ))
19+ err_response = 'bash: codna: command not found'
20+ assert not match (Command ('codna list' , err_response ))
21+
22+
23+ def test_get_new_command (mistype_response ):
24+ assert (get_new_command (Command ('conda lst' , mistype_response )) == ['conda list' ])
Original file line number Diff line number Diff line change 1+ import re
2+ from thefuck .utils import replace_command , for_app
3+
4+
5+ @for_app ("conda" )
6+ def match (command ):
7+ """
8+ Match a mistyped command
9+ """
10+ return "Did you mean 'conda" in command .output
11+
12+
13+ def get_new_command (command ):
14+ match = re .findall (r"'conda ([^']*)'" , command .output )
15+ broken_cmd = match [0 ]
16+ correct_cmd = match [1 ]
17+ return replace_command (command , broken_cmd , [correct_cmd ])
You can’t perform that action at this time.
0 commit comments