From 0d1b18b5870bd531e48c830ea9397a729b0225fa Mon Sep 17 00:00:00 2001 From: Chazeon Date: Fri, 15 Nov 2019 16:47:18 -0500 Subject: [PATCH] Adding command line main program --- README.md | 31 +++++++++++++++++++++++++++++++ cij/cli/main.py | 17 +++++++++++++++++ setup.py | 5 ++++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 cij/cli/main.py diff --git a/README.md b/README.md index bef46e9..1dc0d33 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,37 @@ Pint need to be updated to the GitHub master branch for the code to work with at ## Usage +### Configuration file + +```yml +qha: + input: input01 + settings: + # QHA INPUT FILE HERE ... +elast: + input: elast.dat +settings: + mode_gamma: + # Refer to cij.core.mode_gamma + interpolator: spline + order: 5 + cij_keys: [11, 22, 33, 12, 13, 23, 44, 55, 66] + disable_phonon_contribution: False +``` + +### Command line arguments + +```txt +usage: qha-cij [-h] [-V] CONF.yml + +positional arguments: + CONF.yml name of the configuration file + +optional arguments: + -h, --help show this help message and exit + -V, --version show program's version number and exit +``` + ## Documentation ## Author diff --git a/cij/cli/main.py b/cij/cli/main.py new file mode 100644 index 0000000..4cbdef4 --- /dev/null +++ b/cij/cli/main.py @@ -0,0 +1,17 @@ +import argparse +import logging + +def run(config_fname: str): + import cij.core.calculator + calculator = cij.core.calculator.Calculator(config_fname) + +def parse_args(): + import cij + parser = argparse.ArgumentParser() + parser.add_argument(dest="config_filename", metavar="CONF.yml", action="store", help="name of the configuration file") + parser.add_argument('-V', '--version', action='version', version=f'Cij v.{cij.__version__}') + return parser.parse_args() + +def main(): + parsed = parse_args() + run(parsed.config_filename) \ No newline at end of file diff --git a/setup.py b/setup.py index 43db0c8..e26b940 100644 --- a/setup.py +++ b/setup.py @@ -14,5 +14,8 @@ "qha", "lazy_property", "pint @ git+https://github.com/hgrecco/pint.git#egg=pint" - ] + ], + entry_points = { + 'console_scripts': ['qha-cij=cij.cli.main:main'], + } )