简体   繁体   中英

How to create a command line application like awscli with python in windows?

I would like to create an application running from CLI in windows like the awscli program.

It should be built with python script and when running that it showld perform soma action like

samplepgm login -u akhil -p raju

Like this, Could you guide me in creating this kind of cli application in Windows with python.

Check out argparse for something basic: https://docs.python.org/3/library/argparse.html

For a better library check out Click : https://click.palletsprojects.com/en/7.x/

Others:

I have implemented this using Pyinstaller which will build an exe file of the python files. Will work with all versions of Python

First you need to create your python cli script for the task, then build the exe using

pyinstaller --onefile -c -F -n Cli-latest action.py

If you need to get inputs from users then you can do a infinite loop which will request for input

(Try input("My Dev:-$ " )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM