visualize_tree-backup_6.py 1.2 KB

1234567891011121314151617181920212223242526272829
  1. def main():
  2. """Parse command line arguments, instantiate graph and dump image"""
  3. parser = argparse.ArgumentParser()
  4. parser.add_argument("packages",
  5. help="Full path to a package in the Nix store. "
  6. "This package will be diagrammed", nargs='+')
  7. parser.add_argument("--configfile", "-c", help="ini file with layout and "
  8. "style configuration", required=False)
  9. parser.add_argument("--configsection", "-s", help="section from ini file "
  10. "to read")
  11. parser.add_argument("--output", "-o", help="output filename, will be "
  12. "a png", default="frame.png", required=False)
  13. parser.add_argument('--verbose', dest='verbose', action='store_true')
  14. parser.add_argument('--no-verbose', dest='verbose', action='store_false')
  15. parser.set_defaults(verbose=False)
  16. args = parser.parse_args()
  17. init_logger(debug=args.verbose)
  18. try:
  19. graph = Graph(args.packages, (args.configfile, args.configsection),
  20. args.output)
  21. except util.TreeCLIError as e:
  22. sys.stderr.write("ERROR: {}\n".format(e.message))
  23. sys.exit(1)
  24. if __name__ == "__main__":
  25. main()