Reputation: 46
I have created a directory 'prince' which consists of a subdirectory 'src' containing 'main.py' file in it. This main.py uses Click command for input from user using command line. So currently I have to set current working directory to 'prince' in terminal and then execute my module using the command
'$ python -m src.main run --s 10 20 30'
where 'run', '--s' are my click command inputs.
Is there an easy way to wrap 'python -m src.main' to something short to execute my module along with inputs using click command ? Or any better way to execute my module along with inputs from user ?
Upvotes: 0
Views: 1656
Reputation: 660
I hope this will answer your question.
In your src/main.py file you could add a #!/usr/bin/env python3 shebang which means that your program is run by python by default.
And you should give it execute permissions via
chmod +x src/main.py
That means you can now run
src/main run --s 10 20 30
Instead of
$ python -m src.main run --s 10 20 30
Antother way to achieve this would be:
Create a file in the "prince" directory named "start" with Content:
python3 -m src.main "$@"
Give it executable permissions:
chmod +x start
Now you can run:
./start run --s 10 20 30
Upvotes: 1