Skip to content

Commit

Permalink
Fix readme + fix Yegor
Browse files Browse the repository at this point in the history
  • Loading branch information
lyriccoder committed Aug 27, 2020
1 parent c138bed commit a1e219b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 22 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,11 @@ You can get full report with `--full` command, then all patterns will be include
$ aibolit recommend --folder src/java --full
```

You can exclude folder with `--exclude_folder` command.
You must use `--exclude_glob` command to set glob patterns to ignore:
You can exclude files with `--exclude` command.
You to set glob patterns to ignore:

```bash
$ aibolit recommend --folder src/java --exclude_glob=**/*Test*.java --exclude=**/*Impl*.java --exclude_folder=/mnt/d/src/java/tests
$ aibolit recommend --folder src/java --exclude=**/*Test*.java --exclude=**/*Impl*.java
```

If you need help, run
Expand Down
28 changes: 9 additions & 19 deletions aibolit/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -666,25 +666,15 @@ def check():
default=[],
help='Suppress certain patterns (comma separated value)'
)

exclude_group = parser.add_argument_group('exclude options')
exclude_group.add_argument(
'--exclude_glob',
parser.add_argument(
'--exclude',
action='append',
nargs='+',
default=[],
help='Glob folder to ignore. '
)
exclude_group.add_argument(
'--exclude_folder',
default='',
help='Glob patterns to ignore. '
)
args = parser.parse_args(sys.argv[2:])

if bool(args.exclude_glob) ^ bool(args.exclude_folder):
print('Error: exclude_folder and exclude_glob params must be given together')
sys.exit(2)

if args.suppress:
args.suppress = args.suppress.strip().split(',')

Expand Down Expand Up @@ -723,13 +713,13 @@ def check():


def handle_exclude_command_line(args):
files_to_exclude = []
folders_to_exclude = args.exclude_folder
full_path_to_exclude = Path(os.getcwd(), folders_to_exclude) if folders_to_exclude else None
glob_patterns = args.exclude_glob
files_to_exclude: List[str] = []
full_path_to_exclude = args.folder
glob_patterns = args.exclude
for glob_p in glob_patterns:
files_to_exclude.extend([str(x.absolute()) for x in Path(full_path_to_exclude).glob(glob_p)])

pattern = glob_p[0]
files_to_exclude.extend([str(x.absolute()) for x in Path(full_path_to_exclude).glob(pattern)])
print("ignore:", files_to_exclude)
return files_to_exclude


Expand Down

0 comments on commit a1e219b

Please sign in to comment.