cleo icon indicating copy to clipboard operation
cleo copied to clipboard

single space as an argument default value

Open pmav99 opened this issue 7 years ago • 0 comments

How can I define an empty space as the default value of an argument/option?

Using ' ' is interpreted as 3 chars (i.e. a quoted space). Obviously, I can apply the default value in the handle() code, but I was wondering if I am missing the "cleo" way of doing this.

Minimal Working Example

from cleo import Application
from cleo import Command

class MyCommand(Command):
    """
    Command description

    cmd
        {--s|separator=' ' : The separator.}
    """
    def handle(self):
        separator = self.option("separator")
        print(separator)
        print(repr(separator))
        print(len(separator))
        print(type(separator))
        if separator == " ":
            print("Yay!")

def main():
    application = Application()
    application.add(MyCommand())
    application.run()

if __name__ == "__main__":
    main()

pmav99 avatar Jan 09 '19 19:01 pmav99