Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't use more 'items' sections #208

Closed
lukaszachy opened this issue Nov 12, 2019 · 2 comments
Closed

Can't use more 'items' sections #208

lukaszachy opened this issue Nov 12, 2019 · 2 comments
Assignees
Labels

Comments

@lukaszachy
Copy link
Collaborator

When two 'items' type sections are used, did ends up with traceback. It looks as did is trying to register first section again.

Command did --config items

Traceback (most recent call last):
  File "/usr/local/bin/did", line 42, in <module>
    did.cli.main()
  File "/usr/local/lib/python3.7/site-packages/did/cli.py", line 188, in main
    options, header = Options(arguments).parse()
  File "/usr/local/lib/python3.7/site-packages/did/cli.py", line 62, in __init__
    self.sample_stats.add_option(self.parser)
  File "/usr/local/lib/python3.7/site-packages/did/stats.py", line 225, in add_option
    stat.add_option(parser)
  File "/usr/local/lib/python3.7/site-packages/did/stats.py", line 149, in add_option
    stat.add_option(group)
  File "/usr/local/lib/python3.7/site-packages/did/stats.py", line 55, in add_option
    "--{0}".format(self.option), action="store_true", help=self.name)
  File "/usr/lib64/python3.7/argparse.py", line 1373, in add_argument
    return self._add_action(action)
  File "/usr/lib64/python3.7/argparse.py", line 1577, in _add_action
    action = super(_ArgumentGroup, self)._add_action(action)
  File "/usr/lib64/python3.7/argparse.py", line 1387, in _add_action
    self._check_conflict(action)
  File "/usr/lib64/python3.7/argparse.py", line 1526, in _check_conflict
    conflict_handler(action, confl_optionals)
  File "/usr/lib64/python3.7/argparse.py", line 1535, in _handle_conflict_error
    raise ArgumentError(action, message % conflict_string)
argparse.ArgumentError: argument --foo: conflicting option string: --foo

Configuration file items

[foo]
type = items
header = Work on this
item1 = foo - A
item2 = foo -A

[bar]
type = items
header = Work on that
item1 = foo - A
item2 = foo -A
@psss psss self-assigned this Nov 14, 2019
@psss psss added the bug label Nov 14, 2019
@psss
Copy link
Owner

psss commented Nov 14, 2019

Seems we have to handle items type as a special case because the options are gathered under a single option group. In the future we could consider creating a separate group for each if it makes sense. For now I just made it working the old way with the new plugin detection.

@psss
Copy link
Owner

psss commented Nov 14, 2019

Example output with your config:

* Work on this
    * foo - A
    * foo -A

* Work on that
    * foo - A
    * foo -A

Help message looks fine as well:

Custom stats:
  --foo            Work on this
  --bar            Work on that
  --custom         All above

@psss psss closed this as completed in 4397668 Nov 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants