Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleo2.x break backward compatible with optional value #295

Closed
zlogz101 opened this issue Nov 28, 2022 · 5 comments
Closed

Cleo2.x break backward compatible with optional value #295

zlogz101 opened this issue Nov 28, 2022 · 5 comments

Comments

@zlogz101
Copy link

Before Cleo 1.0, there was a nice feature for an optional value to a option.

It was implemented by clikit as below:
clikit.OPTION_OPTIONAL_VALUE
--option=?
This option may or may not have a value (e.g. --yell or --yell=loud)

However, from Cleo 1.0, optional value has been removed, which cause existing application hard to upgrade to the latest Cleo version.

Is there any suggestion to this issue? Many thanks.

@neersighted
Copy link
Member

neersighted commented Nov 28, 2022

I think what you are trying to achieve is easily done with Option(name, flag=False, requires_value=False).

@zlogz101
Copy link
Author

@neersighted Many think for you kind response :)

Option(name, flag=False, requires_value=False) is our first choice, however, it can't identify below two scenarios:

  1. -y without value: return None
  2. Not specify -y: return None

Clikit return string "null" for the first scenario. We also need two different values to meet our requirements.

@Secrus
Copy link
Member

Secrus commented Nov 28, 2022

Returning "null" string is definitely not something that is going to come back. However, if you need 2 different values, wouldn't setting default solve your issue? I would expect that Cleo returns None when there is no argument and default when an option has no given value.

@zlogz101
Copy link
Author

Cool! Many thanks to @Secrus , that's what I want, it works for me :)

@zlogz101
Copy link
Author

The problem has been solved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants