boolean or string boolean, that's the question #3715
-
Hi people, Just the other day I was using an spo commandlet (from PowerShell) to set some field on a content type and I tried to use the hidden option with the PowerShell value for true: m365 spo contenttype field set --webUrl '<some-url>' --contentTypeId '<some-contenttype-id>' --fieldId '<some-field-id>' --hidden $true Now that does not work, I needed to use the string value 'true' or 'false'. What's happening here in the code base is that the option It turns out that quite a few commands have this situation, they even have autocomplete values. I think using strings for booleans is unfortunate, because I'm always just using booleans in my script, for example from variables that have been assigned from the output of other functions. I'm now having to write extra scripting to take care of feeding the right string into the option. And also, it's inconsistent... I think we need to pick sides here. We either do things with booleans OR with strings. Updating this would be a rather big refactoring and a huge breaking change. I'm also thinking it's too late for v6. What are your ideas on this. I'd really like to hear it! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 25 replies
-
Just to check if I understand correctly: do you mean the use of |
Beta Was this translation helpful? Give feedback.
-
I personally think that using options, e.g. My preference would be to use flags for booleans, e.g. One downside to using flags though is that it makes scripting a little more difficult as you have to construct the command options dynamically rather than just changing the option value, I expect this is the reason behind this inconsistency that you have discovered. |
Beta Was this translation helpful? Give feedback.
-
Moved this to issues here: #3853 |
Beta Was this translation helpful? Give feedback.
Moved this to issues here: #3853