#!/usr/bin/python3 ############################################################################### # # # libloc - A library to determine the location of someone on the Internet # # # # Copyright (C) 2020 IPFire Development Team # # # # This library is free software; you can redistribute it and/or # # modify it under the terms of the GNU Lesser General Public # # License as published by the Free Software Foundation; either # # version 2.1 of the License, or (at your option) any later version. # # # # This library is distributed in the hope that it will be useful, # # but WITHOUT ANY WARRANTY; without even the implied warranty of # # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # # Lesser General Public License for more details. # # # ############################################################################### import argparse import logging import sys # Load our location module import location from location.i18n import _ # Initialise logging log = logging.getLogger("location.importer") log.propagate = 1 class CLI(object): def parse_cli(self): parser = argparse.ArgumentParser( description=_("Location Importer Command Line Interface"), ) # Global configuration flags parser.add_argument("--debug", action="store_true", help=_("Enable debug output")) # version parser.add_argument("--version", action="version", version="%(prog)s @VERSION@") args = parser.parse_args() # Enable debug logging if args.debug: log.setLevel(logging.DEBUG) return args def run(self): # Parse command line arguments args = self.parse_cli() # Call function ret = self.handle_import(args) # Return with exit code if ret: sys.exit(ret) # Otherwise just exit sys.exit(0) def handle_import(self, ns): pass def main(): # Run the command line interface c = CLI() c.run() main()