Add a display_name attribute to Setting
This commit is contained in:
parent
d07cf9949b
commit
fe7c821605
25
settngs.py
25
settngs.py
@ -93,11 +93,35 @@ class Setting:
|
||||
metavar: str | None = None,
|
||||
dest: str | None = None,
|
||||
# ComicTagger
|
||||
display_name: str = '',
|
||||
cmdline: bool = True,
|
||||
file: bool = True,
|
||||
group: str = '',
|
||||
exclusive: bool = False,
|
||||
):
|
||||
"""
|
||||
|
||||
Args:
|
||||
*names: Passed directly to argparse
|
||||
action: Passed directly to argparse
|
||||
nargs: Passed directly to argparse
|
||||
const: Passed directly to argparse
|
||||
default: Passed directly to argparse
|
||||
type: Passed directly to argparse
|
||||
choices: Passed directly to argparse
|
||||
required: Passed directly to argparse
|
||||
help: Passed directly to argparse
|
||||
metavar: Passed directly to argparse, defaults to `dest` uppercased
|
||||
dest: This is the name used to retrieve the value from a `Config` object as a dictionary
|
||||
display_name: This is not used by settngs. This is a human-readable name to be used when generating a GUI.
|
||||
Defaults to `dest`.
|
||||
cmdline: If this setting can be set via the commandline
|
||||
file: If this setting can be set via a file
|
||||
group: The group this option is in.
|
||||
This is an internal argument and should only be set by settngs
|
||||
exclusive: If this setting is exclusive to other settings in this group.
|
||||
This is an internal argument and should only be set by settngs
|
||||
"""
|
||||
if not names:
|
||||
raise ValueError('names must be specified')
|
||||
# We prefix the destination name used by argparse so that there are no conflicts
|
||||
@ -130,6 +154,7 @@ class Setting:
|
||||
self.argparse_args = args
|
||||
self.group = group
|
||||
self.exclusive = exclusive
|
||||
self.display_name = display_name or dest
|
||||
|
||||
self.argparse_kwargs = {
|
||||
'action': action,
|
||||
|
@ -78,6 +78,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test_setting', # dest is calculated by Setting and is not used by argparse
|
||||
'display_name': 'test_setting', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -117,6 +118,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'testing', # dest is calculated by Setting and is not used by argparse
|
||||
'display_name': 'testing', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -155,6 +157,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test', # dest is calculated by Setting and is not used by argparse
|
||||
'display_name': 'test', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -194,6 +197,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test', # dest is calculated by Setting and is not used by argparse
|
||||
'display_name': 'test', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -232,6 +236,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test',
|
||||
'display_name': 'test', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -270,6 +275,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test',
|
||||
'display_name': 'test', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': 'tst',
|
||||
@ -306,6 +312,7 @@ success = [
|
||||
'const': None,
|
||||
'default': None,
|
||||
'dest': 'test',
|
||||
'display_name': 'test', # defaults to dest
|
||||
'exclusive': False,
|
||||
'file': True,
|
||||
'group': '',
|
||||
|
Loading…
Reference in New Issue
Block a user