Skip to content

Commit

Permalink
Verbose fix
Browse files Browse the repository at this point in the history
  • Loading branch information
droideck committed Feb 3, 2024
1 parent 1f95b57 commit 93a64a2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/lib389/cli/dsctl
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ from lib389.cli_ctl.instance import instance_remove_all
from lib389.cli_base import (
disconnect_instance,
setup_script_logger,
format_error_to_dict)
format_error_to_dict,
CustomArgumentParser)
from lib389._constants import DSRC_CONTAINER

parser = argparse.ArgumentParser(allow_abbrev=False)
parser.add_argument('-v', '--verbose',
help="Display verbose operation tracing during command execution",
action='store_true', default=False
)
parser = CustomArgumentParser(allow_abbrev=False)
parser.add_argument('instance', nargs='?', default=False,
help="The name of the instance to act upon",
).completer = instance_choices
parser.add_argument('-v', '--verbose',
help="Display verbose operation tracing during command execution",
action='store_true', default=False)
parser.add_argument('-j', '--json',
help="Return result in JSON object",
default=False, action='store_true'
Expand Down
10 changes: 10 additions & 0 deletions src/lib389/lib389/cli_base/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# See LICENSE for details.
# --- END COPYRIGHT BLOCK ---

import argparse
import ast
import logging
import sys
Expand Down Expand Up @@ -473,3 +474,12 @@ def format_error_to_dict(exception):
except Exception:
msg = {'desc': errmsg}
return msg


class CustomArgumentParser(argparse.ArgumentParser):
def format_help(self):
original_help = super().format_help()
global_options = '[-v] '
if 'usage:' in original_help:
return original_help.replace('usage: ', 'usage: ' + global_options, 1)
return original_help

0 comments on commit 93a64a2

Please sign in to comment.