General Python: make a cli from python package like rasa

I am writing my question here because a ways back, after install rasa via a process such as pip, that enabled us to write commands such as rasa init.

I am curious, how do we go about generating a cli from our python packages in a similar fashion? I don’t want users to have to go through a flow like python main.py --arg1 --arg2

In short, I am curious as to how rasa was able to generate the CLI, which I think is absolutely fantastic.