-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Deprecate AppSettings / ArgSettings in favor of binary methods #2717
Comments
As we resolve this, we'll need to create issues for
|
@pksunkara I think this should be tagged for the 3.0 release as it will lower the barrier for transition from clap2->3. Note that this is only for deprecating and not removing settings. Removing the settings would definitely for a 4.0 thing EDIT: And will resolve documentation regressions |
To confirm, the settings approach was picked instead of the methods approach first. But then, we started adding convenience helper methods (Ex: Basically, the methods we added are builder methods, but they are not 1:1 with the settings. They are helper methods which manipulate one or more settings.
We had to revert the removing of methods because of the above reason. They are helpers which change one or more settings and I don't think kbknapp realised that.
Color settings should never have been there in the first place. I agree that it should be a separate enum and should be used by a method which takes that enum. Let's fix this for 3.0 by creating an issue "Migrate color control to an enum, from distinct binary flags"
I am not sure what exactly you mean by this, but I assume it's an issue with the color related settings only. Thus, this would be fixed by removing them as proposed above.
I would argue that the transition is harder compared to the reverse.
What I would propose instead is to remove (Deprecation discussion in #2617) the binary methods we currently have for |
I'm a bit surprised, your response feels like a 180 but maybe I misinterpreted us moving this from discussion to Issue. I had thought that we were past the high level discussion and good with the general direction. Whatever the motivation was, if we still have this much to discuss, this would have best left to discussions because of threading so we can more easily keep the topics focused. I'm also confused by parts of your response.
Clap started only with the methods, for example required in clap v1 Not digging through it all and taking what kbnapp said, the Settings were then added in an attempt to comply with the API guidelines.
So maybe there were multiple reasons or different angles on the same but 82ffb82 explicitly says the reason was to smooth the upgrade process. Regardless of any of the above, I don't see how this impacts my proposal. Is there something that the user can do today through Settings that they can't do through methods that is a motivating use case to focus on Settings?
Let me re-phrase. We have parallel APIs for building Args and Apps, settings and methods.
My proposal was to start with deprecating settings, not obsoleting / removing them. Also, from my other investigations, there are generally 0-3 App Settings while there are a lot of arg methods.
I'm not sure what you mean by "helper" vs "binary" method and what I'm supposed to notice is different in the linked functions.
So if I'm understanding, it sounds like you are in favor of resuming kbnapp's efforts to remove the methods, in favor of settings? Under what pretense? I did not see any justification given for them and yet there are many flaws with the settings API, as has been previously enumerated. |
I am sorry, it was my mistake in misunderstanding. When you asked the below question in that discussion:
I thought you wanted to discuss this more in this issue to finalize the design. I was under the assumption that we were using the discussions threads as a maybe idea and issues as todo idea. Which is why I answered yes to create an issue as an agreement that we need to resolve this. Am I correct in assuming that you want to move the whole design finalization to discussions? |
I'll break this down into
With each being broken down into high level and detailed. We discussed the Problem and Solution and I thought we were agreed and ready to move on to Implementation. However, if we are still working out Settings vs Methods, then we have not agreed on a Solution. Where it lives relative to where we are at in the process doesn't matter too much except for how much discussion it generates. Issues being single threaded make it hard to break down and discuss individual points. |
Yeah, we haven't agreed on a solution. As I said, it was a miscommunication that gave the impression that we did. |
Proposing to punt this to v4 to get 3.0.0-rc.0 out this week. |
These exist pretty much just for YAML (clap-rs#3087). If anyone else is building on these, it has a limited shelf-life anyways because of clap-rs#2717. BREAKING CHANGE: `FromStr` for settings requires the `yaml` feature.
In switching to functions, we use global vs non-global. Overall I think this can help because its easy to overlook this and do the wrong thing. Granted, there are cases where things might go either way. My long term thought for addressing replacing this system is hard coding whether an attribute is "inheritable" or not. We then layer One challenge will be in documenting this. Now to break down which should be inheritable. Inheritable (global)
Non-inheritable (non-global)
Removing in 4.0
|
This is prep for clap-rs#2717
This is prep for clap-rs#2717
- ArgSettings are part of clap-rs#2717 - Errors are part of clap-rs#2628 - `help_heading` is part of clap-rs#1807 and clap-rs#1553 - Some misc parts are for API consistency
- ArgSettings are part of clap-rs#2717 - Errors are part of clap-rs#2628 - `help_heading` is part of clap-rs#1807 and clap-rs#1553 - Some misc parts are for API consistency
This is a part of clap-rs#2717 Some settings didn't get getters because - They are transient parse settings (e.g. ignore errors) - They get propagated to args and should be checked there `is_allow_hyphen_values_set` is a curious case. In some cases, we only check the app and not an arg. This seems suspicious.
This is a part of clap-rs#2717 Some settings didn't get getters because - They are transient parse settings (e.g. ignore errors) - They get propagated to args and should be checked there `is_allow_hyphen_values_set` is a curious case. In some cases, we only check the app and not an arg. This seems suspicious.
This is a part of clap-rs#2717 Some settings didn't get getters because - They are transient parse settings (e.g. ignore errors) - They get propagated to args and should be checked there `is_allow_hyphen_values_set` is a curious case. In some cases, we only check the app and not an arg. This seems suspicious.
Remaining work, exclusive for 4.0, is the layering of the global settings. |
Since no one has reported a problem where layering is needed, I'm going to close this issue out. Layering can be added in a later breaking release and tracked in its own issue. |
Since I was already in a conversation with kbknapp, I figured I might as well ask him for the reason for the transitio to ArgSettings early in clap3.
The guideline in question: Arguments convey meaning through types, not bool or Option (C-CUSTOM-TYPE)
The motivations given are:
This motivation doesn't quite line up with clap because the arguments are being used in a builder position which automatically names things. Its fairly common in builders to still use bools. Its also hard to predict what the expansion should be for what to name enum variants. Plus, they would balloon the API.
Proposal
We emphasize the methods, restoring any inferring, and work to deprecate the
ArgSettings
/AppSettings
. Besides the improvements below, this will make the clap2->clap3 transition easierThis is only affecting the API and is independent of how we store these settings.
Problems with
Settings
User convenience of inferring settings
Unnecessary verbosity:
#[clap(multiple_occurrences = true)]
vs#[clap(setting(clap::ArgSettings::MultipleOccurrences)]
Interferes with actually following the API guidelines (see the individual
Color
settings vs having an enumDisjoint API leaking implementation details: Related to the above, we have to distinct ways of doing things, based on the conceptual data type. This makes the API more confusing and increases the barrier to change, including to follow the guidelines this was done for (again, see above with Color)
Keeping both means we are maintaining two distinct APIs for modifying the builders
For global settings, we can "layered" the Apps: for opted-in settings, we track whether they have been explicitly set and for anything not explicitly set, we automatically propagate the parent Apps settings. See #1184 for more details.
kbknapp's thoughts
While kbknapp's word isn't the only consideration here, I thought I'd add his thoughts
Regarding
Settings
As for which direction to go, he originally stated:
and later
Originally posted by @epage in #2607 (reply in thread)
The text was updated successfully, but these errors were encountered: