KevinMarquette/PSGraph

Make Edge cmdlet case insensitive

Stephanevg opened this issue · 2 comments

Hi Kevin,

I have something that bothers me on the 'edge' cmdlet. I don't know if this is by design, but I noticed that the 'edge' cmdlet is case sensitive. I would rather have it be insensitive, and most of the things in PowerShell are case insensitive.

See the example below:

graph g {

    SubGraph MyTests {

        Record -Name "Parent" {
            Row "Parent First Row" -Name "Parent_Row_First"
            Row "Parent second Row" -Name "Parent_Row_Second"
            
        }

        $Childs = @("Pierre","Paul","Jacques")

        Foreach($c in $Childs){
            Record -Name $c {
                Row "$c First Row" -Name "$($c)_Row_First"
                Row "$c second Row" -Name "$($c)_Row_Second"
                Row "$c thrid Row" -Name "$($c)_Row_third"
                
            }
        }

    }

    #This will not work, and create a new circle instead of the existing elements of the graph.
    #This is due to the fact that the case is different then in the $Childs array.
        edge -From "parent" -To "pierre","paul","jacques"
    

    
} |Show-PSGraph

This is the result we would get (But not the one we would expect / want):

edge_debbuging_nok

graph g {

    SubGraph MyTests {

        Record -Name "Parent" {
            Row "Parent First Row" -Name "Parent_Row_First"
            Row "Parent second Row" -Name "Parent_Row_Second"
            
        }

        $Childs = @("Pierre","Paul","Jacques")

        Foreach($c in $Childs){
            Record -Name $c {
                Row "$c First Row" -Name "$($c)_Row_First"
                Row "$c second Row" -Name "$($c)_Row_Second"
                Row "$c thrid Row" -Name "$($c)_Row_third"
                
            }
        }

    }

    #This works, since it has the EXACT same case sensitivy a the strings located in '$Childs'
        edge -From "Parent" -To "Pierre","Paul","Jacques"


} |Show-PSGraph

And in this case, this is what we would get (and actually expect).

edge_debbuging_ok

Although the fix seems trivial, I needed quite some time to realize where it came from, as I was testing it on various scripts with Write-ClassDiagram on scripts that I didn't write. (See issue on PowershellClassUtils here)

I think it would be great if we could remove the case sensitivity, as I don't really see, as a PowerShell scripter, what it actually brings as added value.

It's actually graphviz that is case sensitive. I do provide a way to set a custom node name format script that can provide case insensitivity.

Set-NodeFormatScript -ScriptBlock {$_.ToLower()}

This will have the side effect of making all node names lowercase. I often counter that by specifying a label on my nodes so they display as expected.

Hi,

I actually provided an -IgnoreCase in my function, which will force the name of the nodes to TitleCase.