Revision 4a25486d

b/kamaki/cli/argument/__init__.py
213 213

214 214
```    @value.setter
```
215 215
```    def value(self, newvalue):
```
216
```        if newvalue == self.default:
```
217
```            self._value = newvalue
```
218
```            return
```
216 219
```        try:
```
217
```            self._value = self.default if (
```
218
```                newvalue == self.default) else int(newvalue)
```
220
```            if int(newvalue) == float(newvalue):
```
221
```                self._value = int(newvalue)
```
222
```            else:
```
223
```                raise ValueError('Raise int argument error')
```
219 224
```        except ValueError:
```
220 225
```            raiseCLIError(CLISyntaxError(
```
221 226
```                'IntArgument Error',
```
b/kamaki/cli/argument/test.py
228 228
```    def test_value(self):
```
229 229
```        ia = argument.IntArgument(parsed_name='--ia')
```
230 230
```        self.assertEqual(ia.value, None)
```
231
```        for v in (1, 0, -1, 923455555555555555555555555555555):
```
231
```        for v in (1, 0, -1):
```
232 232
```            ia.value = v
```
233 233
```            self.assertEqual(ia.value, v)
```
234
```        for v in ('1', '-1', 2.8):
```
234
```        for v in ('1', '-1'):
```
235 235
```            ia.value = v
```
236 236
```            self.assertEqual(ia.value, int(v))
```
237 237
```        for v, err in (
```
238 238
```                ('invalid', errors.CLIError),
```
239
```                (2.8, errors.CLIError),
```
240
```                (923455555555555555555555555555555, errors.CLIError),
```
239 241
```                (None, TypeError), (False, TypeError), ([1, 2, 3], TypeError)):
```
240 242
```            try:
```
241 243
```                ia.value = v
```
b/kamaki/cli/commands/snf-astakos.py
43 43
```    _command_init, errors, _optional_json, addLogSettings)
```
44 44
```from kamaki.cli.command_tree import CommandTree
```
45 45
```from kamaki.cli.utils import print_dict, format_size
```
46
```from kamaki.cli.argument import FlagArgument, ValueArgument
```
46
```from kamaki.cli.argument import FlagArgument, ValueArgument, IntArgument
```
47 47
```from kamaki.cli.argument import CommaSeparatedListArgument
```
48 48
```from kamaki.cli.logger import get_logger
```
49 49

......
655 655
```    """List all applications (old and new)"""
```
656 656

657 657
```    arguments = dict(
```
658
```        project=ValueArgument('Filter by project id', '--with-project-id')
```
658
```        project=IntArgument('Filter by project id', '--with-project-id')
```
659 659
```    )
```
660 660

661 661
```    @errors.generic.all
```
......
732 732
```    """List all memberships"""
```
733 733

734 734
```    arguments = dict(
```
735
```        project=ValueArgument('Filter by project id', '--with-project-id')
```
735
```        project=IntArgument('Filter by project id', '--with-project-id')
```
736 736
```    )
```
737 737

738 738
```    @errors.generic.all
```
739 739
```    @astakoserror
```
740 740
```    def _run(self):
```
741
```        project = self['project']
```
742
```        if project is not None:
```
743
```            project = int(project)
```
744
```        self._print(self.client.get_memberships(self.token, project))
```
741
```        self._print(self.client.get_memberships(self.token, self['project']))
```
745 742

746 743
```    def main(self):
```
747 744
```        super(self.__class__, self)._run()
```

Also available in: Unified diff