openmc-data-storage / openmc_data

Python package for processing nuclear data distribution in ACE and ENDF format into HDF5 format for use in OpenMC. Adapted from the openmc data repo.
MIT License
4 stars 2 forks source link

Implement CLI for Module Invocation #9

Open ahnaf-tahmid-chowdhury opened 4 weeks ago

ahnaf-tahmid-chowdhury commented 4 weeks ago

Description

Currently, the scripts in the this repository require the full module name to be specified when invoking conversions or generations. This can be cumbersome and may lead to errors in typing.

Proposal

I suggest implementing a Command Line Interface (CLI) that allows users to invoke each module based on arguments instead of needing to specify the full module name. This would streamline the process and enhance user experience.

Benefits

shimwell commented 4 weeks ago

just to check i understand can you give an example of what the user would provide for the full module name

thanks

ahnaf-tahmid-chowdhury commented 4 weeks ago

Step 1: Base Command

When the user types openmc/openmc-data and presses Tab, they would see all the primary subcommands:

openmc <TAB>
convert        generate       download       chain         help

Step 2: Subcommand Options

Once the user selects a subcommand (e.g., convert), pressing Tab again will show the libraries available for conversion:

openmc convert <TAB>
mcnp70       mcnp71       endf         lib80x       jeff32       jeff33       fendl       tendl

Step 3: Further Options (Flags and Arguments)

When the user selects a specific library, pressing Tab will reveal relevant flags or arguments. For example:

openmc convert endf <TAB>
-d            --destination    -p           --particles        --download    --no-download     --cleanup   --help

Example Flow with Tab Completion

  1. Start with the base command:

    openmc <TAB>

    Output:

    convert        generate       download       chain         help
  2. Select a subcommand (e.g., convert):

    openmc convert <TAB>

    Output:

    mcnp70       mcnp71       endf         lib80x       jeff32       jeff33       fendl       tendl
  3. Select a library (e.g., endf):

    openmc convert endf <TAB>

    Output:

    -d            --destination    -p           --particles        --download    --no-download     --cleanup   --help
  4. Add a flag (e.g., -d for destination):

    openmc convert endf -d <path>

Implementing This

To achieve this, we will need libraries like argparse (Python) or click, which are compatible with generating shell completion scripts.

shimwell commented 4 weeks ago

The code uses argparse at the moment Also when the user does pip install then they already get access to cli commands so they don't have to type openmc/...

Perhaps I've miss understood

ahnaf-tahmid-chowdhury commented 3 weeks ago

Thank you for the clarification! The current version has multiple base commands like convert_mcnp70, convert_mcnp71, etc. I suggest consolidating these under a single base command, such as openmc-data <others>. This change would simplify usage and enhance the user experience, allowing for a cleaner command structure.

shimwell commented 3 weeks ago

Ah yes I understand now. Yes that is something I would be keen to see.