Add main() entrypoint for all scripts under bin
This commit is contained in:
parent
be4267c295
commit
02a6acbeab
@ -44,7 +44,7 @@ syslog.addHandler(stderr_handler)
|
|||||||
|
|
||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--cachedir", help="alternative directory to use for moving package"
|
"-c", "--cachedir", help="alternative directory to use for moving package"
|
||||||
@ -116,3 +116,7 @@ if __name__ == "__main__":
|
|||||||
|
|
||||||
for pkgfile in (*pkg_tarballs, *sigfiles):
|
for pkgfile in (*pkg_tarballs, *sigfiles):
|
||||||
pkgfiles.add(pkgfile, cachedir)
|
pkgfiles.add(pkgfile, cachedir)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
@ -42,7 +42,7 @@ syslog.addHandler(stderr_handler)
|
|||||||
|
|
||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c", "--cachedir", help="alternative directory to use for deleting package"
|
"-c", "--cachedir", help="alternative directory to use for deleting package"
|
||||||
@ -109,3 +109,7 @@ if __name__ == "__main__":
|
|||||||
repos.db_modify("remove", db, *opts, *pkgs)
|
repos.db_modify("remove", db, *opts, *pkgs)
|
||||||
except repos.RepoAddError as e:
|
except repos.RepoAddError as e:
|
||||||
syslog.error(e)
|
syslog.error(e)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
27
bin/fqo
27
bin/fqo
@ -51,17 +51,22 @@ def locate_files(patterns):
|
|||||||
|
|
||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
parser = argparse.ArgumentParser()
|
def main():
|
||||||
parser.add_argument("patterns", nargs="+", help="file pattern to search for")
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("patterns", nargs="+", help="file pattern to search for")
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
files = locate_files(args.patterns)
|
files = locate_files(args.patterns)
|
||||||
# Locate binary is optional for package, but required for script
|
# Locate binary is optional for package, but required for script
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
print("locate binary not found, install and re-run script")
|
print("locate binary not found, install and re-run script")
|
||||||
else:
|
else:
|
||||||
selected_file = run_fzf(files)
|
selected_file = run_fzf(files)
|
||||||
|
|
||||||
subprocess.run([PACMAN_CMD, "-Qo", selected_file])
|
subprocess.run([PACMAN_CMD, "-Qo", selected_file])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
6
bin/pug2
6
bin/pug2
@ -75,7 +75,7 @@ def package_lists_match(gist_id, package_list):
|
|||||||
|
|
||||||
|
|
||||||
# ========== Main Script ==========
|
# ========== Main Script ==========
|
||||||
if __name__ == "__main__":
|
def main():
|
||||||
parser = argparse.ArgumentParser(description=DESCRIPTION)
|
parser = argparse.ArgumentParser(description=DESCRIPTION)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"-c",
|
"-c",
|
||||||
@ -146,3 +146,7 @@ if __name__ == "__main__":
|
|||||||
sys.exit(e.returncode)
|
sys.exit(e.returncode)
|
||||||
else:
|
else:
|
||||||
print("Update complete.")
|
print("Update complete.")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user