Add main() entrypoint for all scripts under bin
This commit is contained in:
27
bin/fqo
27
bin/fqo
@@ -51,17 +51,22 @@ def locate_files(patterns):
|
||||
|
||||
|
||||
# ========== Main Script ==========
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("patterns", nargs="+", help="file pattern to search for")
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("patterns", nargs="+", help="file pattern to search for")
|
||||
|
||||
args = parser.parse_args()
|
||||
args = parser.parse_args()
|
||||
|
||||
try:
|
||||
files = locate_files(args.patterns)
|
||||
# Locate binary is optional for package, but required for script
|
||||
except FileNotFoundError:
|
||||
print("locate binary not found, install and re-run script")
|
||||
else:
|
||||
selected_file = run_fzf(files)
|
||||
try:
|
||||
files = locate_files(args.patterns)
|
||||
# Locate binary is optional for package, but required for script
|
||||
except FileNotFoundError:
|
||||
print("locate binary not found, install and re-run script")
|
||||
else:
|
||||
selected_file = run_fzf(files)
|
||||
|
||||
subprocess.run([PACMAN_CMD, "-Qo", selected_file])
|
||||
subprocess.run([PACMAN_CMD, "-Qo", selected_file])
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
Reference in New Issue
Block a user