Skip to content

Commit

Permalink
Adding command line main program
Browse files Browse the repository at this point in the history
  • Loading branch information
chazeon committed Nov 15, 2019
1 parent 59cfad2 commit 0d1b18b
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions cij/cli/main.py
Original file line number Diff line number Diff line change
@@ -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)
5 changes: 4 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}
)

0 comments on commit 0d1b18b

Please sign in to comment.