-
Notifications
You must be signed in to change notification settings - Fork 46
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
"valid": false
is a bad choice for the default for wf.NewItem
#4
Comments
This is the main reason. It's first and foremost a Go library, where booleans are generally expected to be I did consider defaulting to But currently, I am unconvinced that they are intuitive enough to justify the "magic".
The library has never tried to follow Alfred's default behaviour. It imposes its own logic because Alfred's default behaviour never made a whole lot of sense (turns out a long-standing bug was at fault for much of it).
In what way? This also seems to stem from your incorrect assumption that items are valid by default.
That's a non-starter. If you set In any case, there's no reason to not emit a value for |
Maybe I have asked this wrong. It’s less that the default should be true than that the ability to omit it all together is more consistent with how Alfred works in other contexts. By more intuitive, I mean that if you have made Alfred workflows before without the library, not specififying a parameter in the Items structure (ie: calling
Not so if you make the My main argument for this change is to consider the user experience for a new user to this library. A new user experiments with a call to If you are still unconvinced that making it BTW - quick side note: Thank you so much for making this library! I wasn't certain I needed a library vs hand-coding the JSON responses was the way to go, but the way you wrap panics, and handle environment variables and caching saved me a ton of development time. Thanks! |
What's the point? Omitting
Okay. You're the first new user to mention having this issue. Perhaps any other reading users can chime in if they were caught out by the behaviour, too?
There's nothing "magic" about the property, and if you understand Alfred's JSON format already, you can see exactly what's going on by looking at the generated JSON in Alfred's debugger (which is why the library pretty-prints the JSON).
I think that would be potentially misleading, seeing as that example wants an invalid item. Explicitly setting It is correctly and explicitly used in all the real examples, which are mentioned immediately after the example code in the README.
Yeah, you don't really need a library for Alfred 3. The library is Alfred 2 vintage, and its old XML format was much trickier to generate.
So, its main utility is to eliminate boilerplate and provide some APIs that make it easy to very quickly plug some data source or useful library into Alfred. |
When calling
wf.NewItem(title)
, the Item struct omits theValid
property in the Alfred JSON feedback with a value offalse
, which is really unfortunate because:wf.NewItem(title).Valid(false)
would be the way to accomplish thisvalid: false
in Alfred's item JSON, it assumes you wantedtrue
when omitted. The behavior of this library results in the opposite of the Alfred default behavior.I understand that the go struct is likely just defaulting the boolean value to false, but for the reasons I outlined, I recommend that the correct default behavior of this property is use the
omitempty
JSON marshaling option. I'm happy to submit a fix/PR if you agree that this default is both incorrect and unintuitive.The text was updated successfully, but these errors were encountered: