Skip to content

Commit

Permalink
Update pki CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
edewata committed Jan 21, 2025
1 parent 8f8f733 commit dd4a765
Show file tree
Hide file tree
Showing 3 changed files with 205 additions and 171 deletions.
32 changes: 1 addition & 31 deletions base/common/python/pki/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#

import collections
import getopt
import logging
import sys
from six import itervalues
Expand Down Expand Up @@ -184,40 +183,11 @@ def parse_args(self, args):

return (module, module_args)

def execute(self, argv, args=None):
def execute(self, argv, args=None): # pylint: disable=W0613
'''
:param argv: Argument values
:param args: Parsed arguments
'''
try:
opts, args = getopt.getopt(argv, 'v', [
'verbose', 'help'])

except getopt.GetoptError as e:
logger.error(e)
self.print_help()
sys.exit(1)

if len(args) == 0:
self.print_help()
sys.exit()

for o, _ in opts:
if o == '--debug':
logging.getLogger().setLevel(logging.DEBUG)

elif o in ('-v', '--verbose'):
logging.getLogger().setLevel(logging.INFO)

elif o == '--help':
self.print_help()
sys.exit()

else:
logger.error('Unknown option: %s', o)
self.print_help()
sys.exit(1)

(module, module_argv) = self.parse_args(argv)

module.execute(module_argv)
Loading

0 comments on commit dd4a765

Please sign in to comment.