| 12 | |
| 13 | @dataclass |
| 14 | class PacmanConfiguration(SubConfig): |
| 15 | parallel_downloads: int = 5 |
| 16 | color: bool = True |
| 17 | |
| 18 | @classmethod |
| 19 | def default(cls) -> Self: |
| 20 | return cls() |
| 21 | |
| 22 | @override |
| 23 | def json(self) -> PacmanConfigSerialization: |
| 24 | return { |
| 25 | 'parallel_downloads': self.parallel_downloads, |
| 26 | 'color': self.color, |
| 27 | } |
| 28 | |
| 29 | @override |
| 30 | def summary(self) -> str | None: |
| 31 | if self.color: |
| 32 | return tr('Color enabled') |
| 33 | return None |
| 34 | |
| 35 | def preview(self) -> str: |
| 36 | color_str = str(self.color) |
| 37 | output = '{}: {}\n'.format(tr('Parallel Downloads'), self.parallel_downloads) |
| 38 | output += '{}: {}'.format(tr('Color'), color_str) |
| 39 | return output |
| 40 | |
| 41 | @classmethod |
| 42 | def parse_arg(cls, args: PacmanConfigSerialization) -> Self: |
| 43 | config = cls.default() |
| 44 | |
| 45 | if 'parallel_downloads' in args: |
| 46 | config.parallel_downloads = int(args['parallel_downloads']) |
| 47 | if 'color' in args: |
| 48 | config.color = bool(args['color']) |
| 49 | |
| 50 | return config |
no outgoing calls