How to use the cleo.inputs.input_argument.InputArgument function in cleo

To help you get started, we’ve selected a few cleo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_init(self):
        """
        InputArgument.__init__() behaves properly
        """
        argument = InputArgument('foo')
        self.assertEqual('foo', argument.get_name(), msg='__init__() takes a name as its first argument')

        # mode argument
        argument = InputArgument('foo')
        self.assertFalse(argument.is_required(), msg='__init__() gives a "InputArgument.OPTIONAL" mode by default')

        argument = InputArgument('foo', None)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.REQUIRED)
        self.assertTrue(argument.is_required(), msg='__init__() can take "InputArgument.REQUIRED" as its mode')

        self.assertRaises(Exception, InputArgument, 'foo', 'ANOTHER_MODE')
        self.assertRaises(Exception, InputArgument, 'foo', -1)

        validator = Integer()
        argument = InputArgument('foo', None, validator=validator)
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_init(self):
        """
        InputArgument.__init__() behaves properly
        """
        argument = InputArgument('foo')
        self.assertEqual('foo', argument.get_name(), msg='__init__() takes a name as its first argument')

        # mode argument
        argument = InputArgument('foo')
        self.assertFalse(argument.is_required(), msg='__init__() gives a "InputArgument.OPTIONAL" mode by default')

        argument = InputArgument('foo', None)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.REQUIRED)
        self.assertTrue(argument.is_required(), msg='__init__() can take "InputArgument.REQUIRED" as its mode')

        self.assertRaises(Exception, InputArgument, 'foo', 'ANOTHER_MODE')
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_init(self):
        """
        InputArgument.__init__() behaves properly
        """
        argument = InputArgument('foo')
        self.assertEqual('foo', argument.get_name(), msg='__init__() takes a name as its first argument')

        # mode argument
        argument = InputArgument('foo')
        self.assertFalse(argument.is_required(), msg='__init__() gives a "InputArgument.OPTIONAL" mode by default')

        argument = InputArgument('foo', None)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.REQUIRED)
        self.assertTrue(argument.is_required(), msg='__init__() can take "InputArgument.REQUIRED" as its mode')

        self.assertRaises(Exception, InputArgument, 'foo', 'ANOTHER_MODE')
        self.assertRaises(Exception, InputArgument, 'foo', -1)

        validator = Integer()
        argument = InputArgument('foo', None, validator=validator)
        self.assertEqual(validator, argument.get_validator())

        # Named validator
        validator = 'integer'
        argument = InputArgument('foo', None, validator=validator)
        self.assertIsInstance(argument.get_validator(), Integer)
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
InputArgument.__init__() behaves properly
        """
        argument = InputArgument('foo')
        self.assertEqual('foo', argument.get_name(), msg='__init__() takes a name as its first argument')

        # mode argument
        argument = InputArgument('foo')
        self.assertFalse(argument.is_required(), msg='__init__() gives a "InputArgument.OPTIONAL" mode by default')

        argument = InputArgument('foo', None)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_required(), msg='__init__() can take "InputArgument.OPTIONAL" as its mode')

        argument = InputArgument('foo', InputArgument.REQUIRED)
        self.assertTrue(argument.is_required(), msg='__init__() can take "InputArgument.REQUIRED" as its mode')

        self.assertRaises(Exception, InputArgument, 'foo', 'ANOTHER_MODE')
        self.assertRaises(Exception, InputArgument, 'foo', -1)

        validator = Integer()
        argument = InputArgument('foo', None, validator=validator)
        self.assertEqual(validator, argument.get_validator())

        # Named validator
        validator = 'integer'
        argument = InputArgument('foo', None, validator=validator)
        self.assertIsInstance(argument.get_validator(), Integer)

        # Native type
        validator = int
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_get_description(self):
        """
        InputArgument.get_description() returns the message description
        """
        argument = InputArgument('foo', None, 'Some description')
        self.assertEqual('Some description', argument.get_description(),
                         msg='.get_description() returns the message description')
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_is_list(self):
        """
        InputArgument.is_list() returns true if the argument can be an array'
        """
        argument = InputArgument('foo', InputArgument.IS_LIST)
        self.assertTrue(argument.is_list())

        argument = InputArgument('foo', InputArgument.OPTIONAL | InputArgument.IS_LIST)
        self.assertTrue(argument.is_list())

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_list())
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
def test_is_list(self):
        """
        InputArgument.is_list() returns true if the argument can be an array'
        """
        argument = InputArgument('foo', InputArgument.IS_LIST)
        self.assertTrue(argument.is_list())

        argument = InputArgument('foo', InputArgument.OPTIONAL | InputArgument.IS_LIST)
        self.assertTrue(argument.is_list())

        argument = InputArgument('foo', InputArgument.OPTIONAL)
        self.assertFalse(argument.is_list())
github sdispater / cleo / tests / inputs / test_input_argument.py View on Github external
self.assertRaises(Exception, InputArgument, 'foo', 'ANOTHER_MODE')
        self.assertRaises(Exception, InputArgument, 'foo', -1)

        validator = Integer()
        argument = InputArgument('foo', None, validator=validator)
        self.assertEqual(validator, argument.get_validator())

        # Named validator
        validator = 'integer'
        argument = InputArgument('foo', None, validator=validator)
        self.assertIsInstance(argument.get_validator(), Integer)

        # Native type
        validator = int
        argument = InputArgument('foo', None, validator=validator)
        self.assertIsInstance(argument.get_validator(), Integer)
github sdispater / cleo / cleo / inputs / api.py View on Github external
:param required: Whether the argument is required or not.
    :type required: bool

    :param default: The default value of the argument.
    :type default: mixed

    :param is_list: Whether the argument should be a list or not.
    :type list: bool

    :param validator: An optional validator.
    :type validator: Validator or str

    :rtype: InputArgument
    """
    mode = InputArgument.OPTIONAL
    if required:
        mode = InputArgument.REQUIRED

    if is_list:
        mode |= InputArgument.IS_LIST

    return InputArgument(name, mode, description, default, validator)
github sdispater / cleo / cleo / inputs / api.py View on Github external
:param is_list: Whether the argument should be a list or not.
    :type list: bool

    :param validator: An optional validator.
    :type validator: Validator or str

    :rtype: InputArgument
    """
    mode = InputArgument.OPTIONAL
    if required:
        mode = InputArgument.REQUIRED

    if is_list:
        mode |= InputArgument.IS_LIST

    return InputArgument(name, mode, description, default, validator)