Best way to make Powershell CmdLets to Blocks

90 views
Skip to first unread message

Florian Tschimben

unread,
Jun 3, 2024, 11:40:32 AMJun 3
to Blockly
Hi,
We wanted to make a Blockly to Powershell translator and we finished the base functions for Powershell. Now we have to decide how we make the Powershell CmdLets into Blocks. The Problem here are the parameters. There are way to many parameters to keep Blockly clear. So we wanted to ask you, what is the best way to make this?

Beka Westberg

unread,
Jun 6, 2024, 12:45:05 PMJun 6
to Blockly
Hello!

It might be helpful to post some more pictures of your blocks to let folks know exactly what you want to fix. But from your message it seems like you probably have a lot of optional inputs you're not sure how to deal with.

I recommend creating a block that changes shape, and uses a mutator to save what shape it's in. So, for example, you could have a "+" button that adds more inputs to your block. Or you could have a block that has no inputs when it's in the flyout, but lots of inputs when it's in the workspace. TinkerCAD does something like that.

I hope that gives you some places to start! If you have any further questions please reply!
--Beka

Florian Tschimben

unread,
Jun 11, 2024, 4:54:53 AMJun 11
to Blockly
Hi,

We decided to make mutators with checkboxes out of it. But now we encountered a new Problem: The Powershell CmdLets sometimes gives back objects with some properties. Now we need a way to access these Properties, but Blockly does not know what Properties each object has. So now we need a new advise...

Alan Vescoli

unread,
Jun 11, 2024, 11:20:09 AMJun 11
to Blockly
Hello here is a picture of how the blocks look
Screenshot 2024-06-11 114844.png

Aaron Dodson

unread,
Jun 11, 2024, 6:24:47 PMJun 11
to Blockly
To make sure I'm understanding, does the Add-AppxVolume block in your screenshot return one of these objects with various properties, along with other blocks that return different kinds of objects? If so, are the properties fixed for each block type (e.g. the object returned from Add-AppxVolume always has `foo` and `bar` properties, while the object returned from another block has a `baz` property), or do the properties vary for the same block? In the former case, you may want to look into typing the output values of the block, and then adding other blocks like `get foo of ()` that accept blocks with compatible output types as input. If the object properties aren't known until runtime you may need to do something a bit less ergonomic like a `get property ____ of ____` block that accepts a string for the property name and a block that returns the object in question as inputs.

Florian Tschimben

unread,
Jun 12, 2024, 2:02:57 AMJun 12
to Blockly
Hello,

The problem is, that Powershell can return different Object based on the used parameters and the values of them. So we dont know until runtime, what object will be returned. Like you said, you probably need to use the  `get property ____ of ____` block. Thank you for your response!

Aaron Dodson

unread,
Jun 12, 2024, 6:09:55 PMJun 12
to Blockly
Got it, then yes, investigating a custom block like that might be a reasonable approach. Feel free to let us know if you have any further questions!
Reply all
Reply to author
Forward
0 new messages