Minor improvments on eachf and show_ip
This commit is contained in:
22
eachf
22
eachf
@ -3,8 +3,8 @@ import sys, os
|
||||
|
||||
if sys.argv[1] in ["--help", "-h"]:
|
||||
print("\nWelcome to the cli helper for foreach loops.")
|
||||
print("\nUsage:\neachf [path] [filter] [command1] [command2]")
|
||||
print("\nDescription:\nIn between the two command-arguments, the filename will be inserted.\n")
|
||||
print("\nUsage:\neachf [path] [filter] [command1] [command2] [command3] [test]")
|
||||
print("\nDescription:\nIn between the command-arguments, the filename will be inserted.\n")
|
||||
exit()
|
||||
|
||||
files = os.listdir(sys.argv[1])
|
||||
@ -17,11 +17,17 @@ for file in files:
|
||||
filtered_files.append(file)
|
||||
|
||||
for f in filtered_files:
|
||||
if len(sys.argv) == 4:
|
||||
c = sys.argv[3] + " " + f
|
||||
else:
|
||||
c = sys.argv[3] + " " + f + " " + sys.argv[4]
|
||||
c = sys.argv[3] + f
|
||||
if len(sys.argv) >= 5:
|
||||
c = c + sys.argv[4]
|
||||
if len(sys.argv) >= 6:
|
||||
c = c + f + sys.argv[5]
|
||||
commands.append(c)
|
||||
|
||||
for command in commands:
|
||||
os.system(command)
|
||||
|
||||
if sys.argv[-1] in ["test", "-t", "--test"]:
|
||||
for command in commands:
|
||||
print(command)
|
||||
else:
|
||||
for command in commands:
|
||||
os.system(command)
|
||||
|
Reference in New Issue
Block a user