Last active
June 9, 2023 23:51
-
-
Save arpieb/3009e13115426ce73d96467c5049c4f4 to your computer and use it in GitHub Desktop.
Python 3 CLI starter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import logging | |
import argparse | |
import sys | |
from text2kg import text2kg, plot_kg | |
def setup_logging(): | |
""" | |
Util function to set up logging for this module | |
:return: None; sets global logger config | |
""" | |
loglevel = os.environ.get('LOGLEVEL', 'INFO').upper() | |
logging.basicConfig( | |
format='%(asctime)s - %(levelname)s: %(message)s', | |
level=loglevel, | |
handlers=[logging.StreamHandler(sys.stdout)] | |
) | |
def parse_args(): | |
""" | |
Util function to parse our arguments | |
:return: Parsed args | |
""" | |
parser = argparse.ArgumentParser( | |
description='CLI tool for cataloging markdown files in repos.' | |
) | |
parser.add_argument( | |
'datafiles', | |
help='Datafiles to process', | |
nargs='+', | |
metavar='DATAFILE' | |
) | |
return parser.parse_args() | |
def apply_config(args): | |
""" | |
Util function to apply config from args and/or files | |
""" | |
pass | |
def main(): | |
setup_logging() | |
args = parse_args() | |
logging.info(args) | |
apply_config(args) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment