aseprite / laf

A C++ library to create desktop applications
https://aseprite.github.io/laf/
MIT License
276 stars 60 forks source link

Add support for sorted parsing #42

Closed iamOgunyinka closed 2 years ago

iamOgunyinka commented 2 years ago

The rationale behind this proposal is a bug that resulted from the use of the parse function in Aseprite. It so happened that the position of arguments is sensitive in some instances. For example, in cases where values without any associated options (e.g file names) come before some options, Aseprite opens the file(s), parse and process the opened file(s) before moving on to processing the other arguments. In some of these cases, the options provided via the CLI may be what is supposed to drive how the file is opened, parsed and processed. However, if the file is eagerly processed before the arguments, it results in some hard-to-debug bugs. This PR allows the user have two options:

This second option delays the eagerness to open/process option-less values until all driving forces are properly taken care of. If, from Aseprite, we could have direct mutating access to the underlying values and options parsed, there would not have been a need for this PR but (rightly so) the interface exposed is immutable -- thus why I think this PR may be needed.

PS: I am not so sure the name of this function (sortedParse) is the right name for it, but as at the time of making this amendment, this is the only name I could think of.

ADDENDUM: According to this comment, this PR may not be necessary as the Aseprite opened issue isn't really a bug but a feature.

iamOgunyinka commented 2 years ago

Closing this PR now because it's become obvious that Aseprite was designed exactly to work as-is. It wasn't a bug.