Added invalid flags' usage error message

This commit is contained in:
Tomasz Górecki 2017-07-05 09:17:22 +02:00
parent f2d78eafe9
commit ed3a5cfc7c

View file

@ -192,6 +192,14 @@ sort_dirs_first = args.include?('-sd') || args.include?('--sort-dirs')
show_files_only = args.include?('-f') || args.include?('--files') show_files_only = args.include?('-f') || args.include?('--files')
show_dirs_only = args.include?('-d') || args.include?('--dirs') show_dirs_only = args.include?('-d') || args.include?('--dirs')
if sort_dirs_first && sort_files_first
raise ArgumentError, 'Restrain from using -sd and -sf flags together'
end
if show_files_only && show_dirs_only
raise ArgumentError, 'Restrain from using -d and -f flags together'
end
sort = if sort_files_first sort = if sort_files_first
'files' 'files'
elsif sort_dirs_first elsif sort_dirs_first