import argparse parser = argparse.ArgumentParser() parser.add_argument('-v','--version',action='version', version='demo',help='Print version information') parser.add_argument('-d','--debug', help='Enable Debug Mode') parser.add_argument('a','arg', help="Argument Documentation") args = parser.parse_args()
If you can live with additional dependencies, then I like the node [1] commander package, which is very readable and nice to work with in my opinion.
#!/usr/bin/env node const { program } = require('commander'); program .command('clone <source> [destination]') .description('clone a repository') .action((source, destination) => { console.log('clone command called'); });
[1] https://github.com/tj/commander.js/