Created
May 19, 2017 17:45
-
-
Save hmm01i/79e340ad5557992ebf0971646b3764d9 to your computer and use it in GitHub Desktop.
snippet example of using optparse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# just a short example of using optparse | |
import getpass | |
import optparse | |
# def parseCmdArgs(): | |
cmdOpts = optparse.OptionParser(usage = '%prog [options]') | |
cmdOpts.add_option('-i', dest = 'ipaddr', help = 'IP address of CIMC') | |
cmdOpts.add_option('-u', dest = 'user', help = 'Username') | |
cmdOpts.add_option('-p', dest = 'passwd', help = 'Password (Optional. If not provided you will be prompted.)') | |
cmdOpts.add_option('-l', action = 'store_true', dest = 'list', help = 'Just query running firmware.') | |
cmdOpts.add_option('-v', action = 'store_true', dest = 'verbose', help = 'Verbose output') | |
cmdOpts.add_option('-n', action = 'store_true', dest = 'dry', help = 'Dry run') | |
(opts, args) = cmdOpts.parse_args() | |
def getpassword(prompt = "CIMC Password: "): | |
return getpass.unix_getpass(prompt)% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment