capstone-coal / pycoal

Python toolkit for characterizing Coal and Open-pit surface mining impacts on American Lands

Home Page:http://capstone-coal.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Create CLI and enable upon install

lewismc opened this issue · comments

mineral.py, mining.py and environment.py should each have a CLI. Upon successful installation of pycoal, the CLI tools should be available on the path for easy execution.

An example of how we did this elsewhere can be seen at the pycovjson cli module.

Really, the main function of our existing examples should really be extracted from the examples and moved to a new cli module.

Additionally, in order to enable execution of these CLI upon install, we need to add the following code to the setup.py

...
_zip_safe = False
_entry_points = {'console_scripts' : ['pycoal-mineral = pycoal.cli.mineral:main', 'pycoal-mining = pycoal.cli.mining:main', 'pycoal-environment = pycoal.cli.environment:main']}

we then need to append the variable to setup.py's setup dictionary as follows

...
zip_safe=_zip_safe,
_entry_points = entry_points

@bdegley4789 how is this going?

@lewismc this issue is going alright. I have tried following the example you gave from pycovjson. I'm probably getting things wrong but I pushed the changed I've worked on to my branch
Am I correct in thinking that I would put all the Command Line Options into the .py scripts in the CLI repo and then remove them from the .py scripts in the example directory?

OK, these are the steps to address the task

  1. add entries (as I previously described) to setup.py which expose the _entry_points, this is so that upon installation, these tools are available via the CLI,
  2. create a cli directory within the existing pycoal source directory. This will be used to house the _entry_points you've defined in 1 above
  3. create the _entry_points e.g. pycoal.cli.mineral, pycoal.cli.mining and pycoal.cli.environment within the new pycoal/cli directory created in 2 above,
  4. ensure that pycoal.cli.mineral, pycoal.cli.mining and pycoal.cli.environment files contain main methods which provide a CLI. Examples of how to do this are provided within the existing examples already. This is literally a copy and paste job.

Does the above make sense? This is not a complex task, so please tell me if I am not explaining it correctly. Thanks