| 1954 | """ |
| 1955 | |
| 1956 | def __call__(self, parser, namespace, values, option_string=None): |
| 1957 | # 1. Get the list that's already stored in the namespace. |
| 1958 | # 'default=[]' in add_argument ensures this is always a list. |
| 1959 | current = getattr(namespace, self.dest) |
| 1960 | |
| 1961 | # 2. Split the new value(s) by comma |
| 1962 | # Use strip() to remove any whitespace around items |
| 1963 | new_items = [item.strip() for item in values.split(',')] |
| 1964 | |
| 1965 | # 3. Extend the existing list with the new items |
| 1966 | if isinstance(current, list): |
| 1967 | current.extend(new_items) |
| 1968 | elif isinstance(current, set): |
| 1969 | current.update(new_items) |
| 1970 | else: |
| 1971 | raise NotImplementedError("type not supported") |
| 1972 | |
| 1973 | def main(): |
| 1974 | epilog_text = textwrap.dedent(""" |