You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CLAide already allows declaring some of the attributes on the class itself as summary, description and more or less arguments, while the latter is not fully exposed in a DSL. I think this is inconsistent.
Allowing that would make it also a lot easier defining reusable pieces of the CLI and share them across different subcommands.
CocoaPods uses currently modules for that, but as they have to overwrite the initializer that works only good once and gets messy after that.
This could look like below:
classCoffeeMaker < CLAide::Commandself.description='Make delicious coffee from the comfort of your terminal.'self.option'--[no-]milk',:flag,'Don’t add milk',default: true# * parses `--milk` as `true`# * parses `--no-milk` as `false`# * defines an attribute accessor `milk?`self.option['--sweetner','-s'],'sugar|honey','Use one of the available sweetners',multivalued: true# * parses `-s sugar -s honey` as `['sugar', 'milk']`# * parses `--sweetner sugar` as `['sugar']`# * defines an attribute accessor `sweetners`end
A: Don't add them in the first place. The interface would be much more composable. So universal subclasses don't necessarily need to define optional options for subclasses and could put them into separate modules.
B: This could be backwards-compatible with the current API. The declared options could be appended to a class variable declared_options, which could be an input to self.options. The latter would still host only an array of pairs with names and descriptions. If an option is removed from the UI, it won't be parsed in later steps. The implicitly defined accessors would be likely still available in that case, which could lead to programmer errors.
CLAide already allows declaring some of the attributes on the class itself as
summary
,description
and more or lessarguments
, while the latter is not fully exposed in a DSL. I think this is inconsistent.Allowing that would make it also a lot easier defining reusable pieces of the CLI and share them across different subcommands.
CocoaPods uses currently modules for that, but as they have to overwrite the initializer that works only good once and gets messy after that.
This could look like below:
This DSL syntax is inspired by Clamp.
The text was updated successfully, but these errors were encountered: