Skip to content

Commit

Permalink
Add fuzzy search to environment variables
Browse files Browse the repository at this point in the history
  • Loading branch information
jaimebuelta committed Aug 29, 2017
1 parent f07ea99 commit 58e0de1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 16 deletions.
27 changes: 13 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,25 +107,24 @@ Setting these environment variables, you'll set options by default. For example:

- FFIND_SORT: Return the results sorted. This is slower, and is mainly thought to ensure
consistency on the tests, as some filesystems may order files differently
- FFIND_CASE_SENSITIVE: Search is case sensitive. Equivalent to -c flag
- FFIND_CASE_INSENSITIVE: Search is case insensitive. Equivalent to -i flag.
- FFIND_SEARCH_HIDDEN: Search in hidden directories. Equivalent to --hidden flag.
- FFIND_SEARCH_PATH: Search in the whole path. Equivalent to -p flag.
- FFIND_IGNORE_VCS: Ignore paths in version control. Equivalent to --ignore-vcs
- FFIND_NO_SYMLINK: Do not follow symlinks. Equivalent to --nosymlinks flag.
- FFIND_NO_COLOR: Do not show colors. Equivalent to --nocolor flag.

If the environment is present, when calling ffind -h, the option will display [SET] at the end.


Install
---
pip install ffind
- FFIND_CASE_SENSITIVE: Search is case sensitive. Equivalent to `-c` flag
- FFIND_CASE_INSENSITIVE: Search is case insensitive. Equivalent to `-i` flag.
- FFIND_SEARCH_HIDDEN: Search in hidden directories. Equivalent to `--hidden` flag.
- FFIND_SEARCH_PATH: Search in the whole path. Equivalent to `-p` flag.
- FFIND_IGNORE_VCS: Ignore paths in version control. Equivalent to `--ignore-vcs`
- FFIND_NO_SYMLINK: Do not follow symlinks. Equivalent to `--nosymlinks` flag.
- FFIND_NO_COLOR: Do not show colors. Equivalent to `--nocolor` flag.
- FFIND_FUZZY_SEARCH: Enable fuzzy search. Equivalent to `-f` flag.

If an environment variable is present, when calling `ffind -h`, the option will display [SET] at the end.

Manual Install
---

From the source code directory
```
python setup.py install
```

Test
---
Expand Down
7 changes: 5 additions & 2 deletions ffind/ffind.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,13 +410,16 @@ def parse_params_and_search():
# Default False
default=env_var)

env_var = bool(os.environ.get('FFIND_FUZZY_SEARCH'))
parser.add_argument('-f',
action='store_true',
dest='fuzzy',
help='Experimental fuzzy search. '
'Increases the matches, use with care. '
'Combining it with regex may give crazy results',
default=False)
'Combining it with regex may give crazy results '
'{0}'.format('[SET]' if env_var else ''),
# Default False
default=env_var)

parser.add_argument('--return-results',
action='store_true',
Expand Down
6 changes: 6 additions & 0 deletions tests/fuzzy.t
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ Run test
$ $PYTHON $TESTDIR/../ffind/ffind.py -f e1
./test_dir/test1.py
./test_dir/second_level/stest1.py

Using environment variable

$ FFIND_FUZZY_SEARCH=1 $PYTHON $TESTDIR/../ffind/ffind.py -f e1
./test_dir/test1.py
./test_dir/second_level/stest1.py

0 comments on commit 58e0de1

Please sign in to comment.