Generating a cube based on a line

Hi, I’m trying to practice my coding skills but getting stuck. I want to be able to draw a line in the usual way, but for the line to create a component (simple cube) with the line length being one side of the cube. So I draw the line and it creates a cube. The other 2 dimensions for the cube would need to be set in advance somehow, I guess from a pop up option box. Does anyone know any code to get me started? Thanks

There is both an example cube and an example line tool in the Tutorials repository at GitHub.