founderswap / swap-anything

A mix and match (swap) library to empower swapping-based projects.
MIT License
5 stars 0 forks source link

Implementation of CLI interface #32

Open ggbaro opened 7 months ago

ggbaro commented 7 months ago

Is your feature request related to a problem? Please describe. As showed in the README concept, we shall make the CLI interface.

Describe the solution you'd like I usually adopt click, a modern and elegant CLI interface library.

Describe alternatives you've considered

Additional context

ggbaro commented 7 months ago

@LFK01 let's work together on this! What do you think?

LFK01 commented 6 months ago

Yes, I'm happy to help on this issue. I'll work on this after we have completed the modelling of the matching problem.

~~In the meantime, I already have some doubts for the future. How does python modules work when invoked from the CLI? I'm used to have a main.py file or a file with the if name == 'main' wrapper called to be executed. How will the code of the python module be called? I have little to no experience in python packaging so I will be satisfied with a partial quick answer and any reference to python documentation. Thank you in advance for the help :)~~

I asked ChatGPT for help. It suggested to specify an entry point in pyproject.toml or setup.py. I asked also for alternatives and it suggested flit among other third party libraries. Do we have any preference among these possible solutions?

LFK01 commented 5 months ago

I've drafted the first version of the CLI in commit https://github.com/founderswap/swap-anything/commit/b1932998f4e7c10be6e93a5e3a88ed64c470e24a and https://github.com/founderswap/swap-anything/commit/ba965971bc15f12dc567b147ab36ad61dbab61a0. I'd like to receive any comments about the implemented functionalities and its correctness before creating a pull-request.

The command execution requires the package installation can be obtained with the following command inside the cloned repository directory: pip install -e . The -e flag allows the developer to change the code and observe the changes without reinstalling the package. . is the cloned repository directory where pip will search for the pyproject.toml file.

I've tried it locally with the command inside the project folder: swapanything tests/unit_test/data/faker_availabilities.csv output.csv --headers --index-col --subject-col "Nome e Cognome" --slot-col "Availabilities"

And it should print the selected matches in the file output.csv. Remember to delete or to exclude the file output.csv when committing to the branch or change its path to another position.

Thanks for any help or suggestion :)