Click にコマンドライン オプションを登録しようとしています。params
コンストラクターに引数を追加するまで、すべてが正常に機能しています。
class InitCommand(click.Command):
def __init__(self):
super().__init__(
name='init',
short_help='Initialize the needed scaffolding.',
help='something helpful, but longer',
# params=[] ### <-- Works fine
params=[click.Option('--force', default=False)]
)
次のエラーが表示されます。
Traceback (most recent call last):
File "/usr/local/bin/aquapy", line 11, in <module>
load_entry_point('aquapy-cli', 'console_scripts', 'aquapy')()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2631, in load_entry_point
return ep.load()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2291, in load
return self.resolve()
File "/usr/local/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2297, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/Users/******/__main__.py", line 3, in <module>
from .bootstrap import main
File "/Users/******/bootstrap.py", line 17, in <module>
main.add_command(InitCommand())
File "/Users/******/commands/init_command.py", line 10, in __init__
params=[click.Option('--force', default=False)]
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1460, in __init__
Parameter.__init__(self, param_decls, type=type, **attrs)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1266, in __init__
self._parse_decls(param_decls or (), expose_value)
File "/usr/local/lib/python3.6/site-packages/click/core.py", line 1533, in _parse_decls
raise TypeError('Name defined twice')
TypeError: Name defined twice