dry-rb / dry-cli

General purpose Command Line Interface (CLI) framework for Ruby
https://dry-rb.org/gems/dry-cli
MIT License
327 stars 41 forks source link

Implement option required: true #122

Open capripot opened 2 years ago

capripot commented 2 years ago
option :option_name, desc: "This is an option", required: true

required: true is accepted and implemented by Option, but not used by Parser or Banner. This PR implements the enforcement of it and surface it to the help banner.

Checks:

IvanShamatov commented 1 year ago

I would suggest to remove "required" flag from Parser and Banner, rather then having required option. If option is required, that means, that it is not an option, but argument.

capripot commented 1 year ago

I agree, I was also confused by having to write option :flag, required: false but wouldn't it be a breaking change? πŸ˜•

capripot commented 1 year ago

From @IvanShamatov :

If option is required, that means, that it is not an option, but argument.

Could we imagine options as keyword arguments? Sometimes it makes more sense to name the arguments rather than having nameless positional arguments. And keyword arguments used to be an "options Hash" but now can be required or not.

I would leave the option to the developer to choose the style they like the best. What do you think?

IvanShamatov commented 1 year ago

@capripot Sure, I understand the concept of keyword arguments, I just can't remember any cli utility with that kind of required option in a wild. Do you have any examples?

Anyway, I don't see why we can't have it. I will talk to the team to ask their opinion on that. Thank you for the contribution

capripot commented 7 months ago

@IvanShamatov Do you think we could merge this? ☺️ πŸ™

timriley commented 1 month ago

Hi @capripot, thank you so much for your patience here. I've started looking at this, as you might notice from the few small commits I've pushed. I'll look to get it ready to merge over the coming week, and will let you know if I have any questions for you.