Check for errors
This commit is contained in:
parent
876be881ca
commit
5f17734898
1 changed files with 8 additions and 3 deletions
|
@ -7,9 +7,14 @@ class Multi():
|
||||||
self.files = files
|
self.files = files
|
||||||
|
|
||||||
def print_matches(self, patterns, files):
|
def print_matches(self, patterns, files):
|
||||||
for pattern in patterns: print(pattern, end=", ")
|
error = "Invalid input.\nExample: shellnotes -m pattern1,pattern2,pattern3 file1,file2,file3"
|
||||||
|
for pattern in patterns:
|
||||||
|
if pattern == "": return error
|
||||||
|
print(pattern, end=", ")
|
||||||
print()
|
print()
|
||||||
for file in files: print(file, end=", ")
|
for file in files:
|
||||||
|
if file == "": return error
|
||||||
|
print(file, end=", ")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(','))
|
newMulti = Multi(sys.argv[1].split(','), sys.argv[2].split(','))
|
||||||
|
@ -17,6 +22,6 @@ try:
|
||||||
except IndexError:
|
except IndexError:
|
||||||
patterns = input("Enter patterns, separated by a comma: ")
|
patterns = input("Enter patterns, separated by a comma: ")
|
||||||
files = input("Enter files, separated by a comma: ")
|
files = input("Enter files, separated by a comma: ")
|
||||||
newMulti = Multi(patterns, files)
|
newMulti = Multi(patterns.split(','), files.split(','))
|
||||||
newMulti.print_matches(patterns.split(','), files.split(','))
|
newMulti.print_matches(patterns.split(','), files.split(','))
|
||||||
|
|
Loading…
Reference in a new issue