xml/Symlink.Format.ps1xml

<?xml version="1.0" encoding="utf-16"?>
<Configuration>
    <!-- General settings. -->
    <DefaultSettings>
        <!-- Shows a '#ERR' string when an error occurs it retrieving data. -->
        <DisplayError/>
         
    </DefaultSettings>
     
    <!-- Selection Sets to simplify view declerations. -->
    <SelectionSets>
        <!-- Symlink Set -->
        <SelectionSet>
            <Name>Set.Symlink</Name>
            <Types>
                <TypeName>Symlink</TypeName>
                <TypeName>Deserialized.Symlink</TypeName>
            </Types>
        </SelectionSet>
         
    </SelectionSets>
     
    <!-- View definitions. -->
    <ViewDefinitions>
        <!-- symlink LIST -->
        <View>
            <Name>Symlink.List</Name>
            <ViewSelectedBy>
                <SelectionSetName>Set.Symlink</SelectionSetName>
            </ViewSelectedBy>
             
            <ListControl>
                <ListEntries>
                     
                    <!-- BASIC Formatting -->
                    <ListEntry>
                        <ListItems>
                             
                            <!-- The symlink name. -->
                            <ListItem>
                                <Label>Name</Label>
                                <ScriptBlock>
                                    "`e[1;4m$($_.Name)`e[0m"
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink location. -->
                            <ListItem>
                                <Label>Path</Label>
                                <ScriptBlock>
                                    $_.FullPath()
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink location's state. -->
                            <ListItem>
                                <Label>Path State</Label>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return "`e[32mExists`e[0m"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[90mDoesn't exist`e[0m"
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[31;4mNeeds creation`e[0m`e[31m!`e[0m"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[33mNeeds Deletion`e[0m`e[31m!`e[0m"
                                        }
                                        "Error"
                                        {
                                            return "`e[31;4mError`e[0m`e[31m!`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink target. -->
                            <!-- Present the true and expanded path. -->
                            <ListItem>
                                <Label>Target</Label>
                                <ScriptBlock>
                                    $_.FullTarget()
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink targets's state. -->
                            <ListItem>
                                <Label>Target State</Label>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.TargetState())
                                    {
                                        "Valid"
                                        {
                                            return "`e[32mExists`e[0m"
                                        }
                                        "Invalid"
                                        {
                                            return "`e[31;4mInvalid`e[0m`e[31m!`e[0m"
                                        }
                                        "MissingVariable"
                                        {
                                            return "`e[33;4mMissing environement variable`e[0m`e[31m!`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The creation condition, only if there is one. -->
                            <!-- A non-existent condition should not be shown. -->
                            <ListItem>
                                <Label>Condition</Label>
                                <ItemSelectionCondition>
                                    <ScriptBlock>
                                        if ($null -ne $_._Condition)
                                        {
                                            return $true
                                        }
                                        else
                                        {
                                            return $false
                                        }
                                    </ScriptBlock>
                                </ItemSelectionCondition>
                                <ScriptBlock>
                                    $str = $_._Condition.ToString().Split("`n") | Foreach-Object { " $_`n" }
                                    "{`n" + $str + "}"
                                </ScriptBlock>
                            </ListItem>
                             
                        </ListItems>
                    </ListEntry>
                     
                    <!-- FANCY Formatting -->
                    <ListEntry>
                        <EntrySelectedBy>
                            <SelectionCondition>
                                <SelectionSetName>Set.Symlink</SelectionSetName>
                                <ScriptBlock>
                                    if ($null -ne $env:WT_SESSION)
                                    {
                                        return $true
                                    }
                                </ScriptBlock>
                            </SelectionCondition>
                        </EntrySelectedBy>
                         
                        <ListItems>
                             
                            <!-- The symlink name. -->
                            <ListItem>
                                <Label>Name</Label>
                                <ScriptBlock>
                                    "`e[97;4m$($_.Name)`e[0m"
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink location. -->
                            <ListItem>
                                <Label>Path</Label>
                                <ScriptBlock>
                                    $_.FullPath()
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink location's state. -->
                            <ListItem>
                                <Label>Path State</Label>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return "`e[32mExists`e[0m"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[90mDoesn't exist`e[0m"
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[31;21mNeeds creation`e[0m❗"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[33mNeeds Deletion`e[0m❗"
                                        }
                                        "Error"
                                        {
                                            return "`e[31;21mError`e[0m❗"
                                        }
                                    }
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink target. -->
                            <!-- Present the true and expanded path. -->
                            <ListItem>
                                <Label>Target</Label>
                                <ScriptBlock>
                                    $_.FullTarget()
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The symlink targets's state. -->
                            <ListItem>
                                <Label>Target State</Label>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.TargetState())
                                    {
                                        "Valid"
                                        {
                                            return "`e[32mExists`e[0m"
                                        }
                                        "Invalid"
                                        {
                                            return "`e[31;21mInvalid`e[0m❗"
                                        }
                                        "MissingVariable"
                                        {
                                            return "`e[33;21mMissing environement variable`e[0m❗"
                                        }
                                    }
                                </ScriptBlock>
                            </ListItem>
                             
                            <!-- The creation condition, only if there is one. -->
                            <!-- A non-existent condition should not be shown. -->
                            <ListItem>
                                <Label>Condition</Label>
                                <ItemSelectionCondition>
                                    <ScriptBlock>
                                        if ($null -ne $_._Condition)
                                        {
                                            return $true
                                        }
                                        else
                                        {
                                            return $false
                                        }
                                    </ScriptBlock>
                                </ItemSelectionCondition>
                                <ScriptBlock>
                                    $str = $_._Condition.ToString().Split("`n") | Foreach-Object { " $_`n" }
                                    "{`n" + $str + "}"
                                </ScriptBlock>
                            </ListItem>
                             
                        </ListItems>
                    </ListEntry>
                     
                </ListEntries>
            </ListControl>
        </View>
         
        <!-- symlink CUSTOM -->
        <View>
            <Name>Symlink.Custom</Name>
            <ViewSelectedBy>
                <SelectionSetName>Set.Symlink</SelectionSetName>
            </ViewSelectedBy>
             
            <CustomControl>
                <CustomEntries>
                     
                    <!-- BASIC Formatting -->
                    <CustomEntry>
                        <CustomItem>
                            <Frame>
                                <CustomItem>
                                    <NewLine />
                                     
                                    <ExpressionBinding>
                                        <ScriptBlock>
                                            "class Symlink"
                                        </ScriptBlock>
                                    </ExpressionBinding>
                                     
                                    <NewLine />
                                    <Text>{</Text>
                                    <NewLine />
                                     
                                    <Frame>
                                        <LeftIndent>4</LeftIndent>
                                        <CustomItem>
                                             
                                            <!-- The name of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "Name = $($_.Name)"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The path of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "Path = $($_._Path)"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The target of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "Target = $($_._Target)"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The condition of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    if ($null -eq $_._Condition) {
                                                        "Condition = NULL"
                                                    }
                                                    else {
                                                        "Condition = $($_._Condition)"
                                                    }
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The ShortPath() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "ShortPath() = $($_.ShortPath())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The FullPath() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "FullPath() = $($_.FullPath())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The ShortTarget() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "ShortTarget() = $($_.ShortTarget())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The FullTarget() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "FullTarget() = $($_.FullTarget())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The TargetState() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "TargetState() = $($_.TargetState())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The Exists() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "Exists() = $($_.Exists())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The ShouldExist() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "ShouldExist() = $($_.ShouldExist())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                            <!-- The State() of the symlink. -->
                                            <ExpressionBinding>
                                                <ScriptBlock>
                                                    "State() = $($_.GetState())"
                                                </ScriptBlock>
                                            </ExpressionBinding>
                                            <NewLine />
                                             
                                        </CustomItem>
                                    </Frame>
                                     
                                    <Text>}</Text>
                                     
                                </CustomItem>
                            </Frame>
                        </CustomItem>
                    </CustomEntry>
                     
                </CustomEntries>
            </CustomControl>
        </View>
         
        <!-- symlink TABLE -->
        <View>
            <Name>Symlink.Table</Name>
            <ViewSelectedBy>
                <SelectionSetName>Set.Symlink</SelectionSetName>
            </ViewSelectedBy>
             
            <TableControl>
                <!-- The table headers. -->
                <TableHeaders>
                     
                    <TableColumnHeader>
                        <Label>Name</Label>
                        <Width>25</Width>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                     
                    <TableColumnHeader>
                        <Label>Path</Label>
                        <Width>35</Width>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                     
                    <TableColumnHeader>
                        <Label>Target</Label>
                        <Width>35</Width>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                     
                    <TableColumnHeader>
                        <Label>Condition</Label>
                        <Width>10</Width>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                     
                    <TableColumnHeader>
                        <Label>Exists</Label>
                        <Width>7</Width>
                        <Alignment>Left</Alignment>
                    </TableColumnHeader>
                     
                </TableHeaders>
                 
                <!-- The table rows. -->
                <TableRowEntries>
                     
                    <!-- BASIC Formatting -->
                    <TableRowEntry>
                        <TableColumnItems>
                             
                            <!-- The symlink name. -->
                            <TableColumnItem>
                                <PropertyName>Name</PropertyName>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- The symlink location. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return $obj.ShortPath()
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[33m$($obj.ShortPath())`e[0m"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[31m$($obj.ShortPath())`e[0m`e[31m!`e[0m"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[90m$($obj.ShortPath())`e[0m"
                                        }
                                        "Error"
                                        {
                                            return "`e[31m;4mError`e[0m`e[31m!`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- The symlink target. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.TargetState())
                                    {
                                        "Valid"
                                        {
                                            return "$($obj.ShortTarget())"
                                        }
                                        "Invalid"
                                        {
                                            return "`e[31;4mInvalid Target`e[0m`e[31m!`e[0m"
                                        }
                                        "MissingVariable"
                                        {
                                            return "`e[32m$($obj.ShortTarget())`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- Whether the symlink has a condition. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    if ($_._Condition)
                                    {
                                        if (Invoke-Command -Scriptblock $_._Condition)
                                        {
                                            return "`e[32mMet`e[0m"
                                        }
                                        else
                                        {
                                            return "`e[31mUnmet`e[0m"
                                        }
                                    }
                                    else
                                    {
                                        return "`e[33mNone`e[0m"
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                             
                            <!-- Whether the symlink exists or not. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return "`e[32m$true`e[0m"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[33m$false`e[0m"
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[31;4m$false`e[0m`e[31m!`e[0m"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[33;4m$true`e[0m`e[31m!`e[0m"
                                        }
                                        "Error"
                                        {
                                            return "`e[31;4mERROR`e[0m`e[31m!`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                             
                        </TableColumnItems>
                    </TableRowEntry>
                     
                    <!-- FANCY Formatting -->
                    <TableRowEntry>
                        <EntrySelectedBy>
                            <SelectionCondition>
                                <SelectionSetName>Set.Symlink</SelectionSetName>
                                <ScriptBlock>
                                    if ($env:WT_SESSION)
                                    {
                                        return $true
                                    }
                                </ScriptBlock>
                            </SelectionCondition>
                        </EntrySelectedBy>
                         
                        <TableColumnItems>
                            <!-- The symlink name. -->
                            <TableColumnItem>
                                <PropertyName>Name</PropertyName>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- The symlink location. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return $obj.ShortPath()
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[33m$($obj.ShortPath())`e[0m"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[31m$($obj.ShortPath())`e[0m`e[31m!`e[0m"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[90m$($obj.ShortPath())`e[0m"
                                        }
                                        "Error"
                                        {
                                            return "`e[31m;21mError`e[0m`e[31m!`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- The symlink target. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.TargetState())
                                    {
                                        "Valid"
                                        {
                                            return "$($obj.ShortTarget())"
                                        }
                                        "Invalid"
                                        {
                                            return "`e[31;21mInvalid Target`e[0m`e[31m!`e[0m"
                                        }
                                        "MissingVariable"
                                        {
                                            return "`e[32m$($obj.ShortTarget())`e[0m"
                                        }
                                    }
                                </ScriptBlock>
                                <Alignment>Left</Alignment>
                            </TableColumnItem>
                             
                            <!-- Whether the symlink has a condition. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    if ($_._Condition)
                                    {
                                        if (Invoke-Command -Scriptblock $_._Condition)
                                        {
                                            return "✅`e[32m(Met)`e[0m"
                                        }
                                        else
                                        {
                                            return "✅`e[33m(Unmet)`e[0m"
                                        }
                                    }
                                    else
                                    {
                                        return "❌"
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                             
                            <!-- Whether the symlink exists or not. -->
                            <TableColumnItem>
                                <ScriptBlock>
                                    $obj = $_
                                    switch ($obj.GetState())
                                    {
                                        "Exists"
                                        {
                                            return "`e[32m$true`e[0m✅"
                                        }
                                        "NotExists"
                                        {
                                            return "`e[33m$false`e[0m✅"
                                        }
                                        "NeedsCreation"
                                        {
                                            return "`e[31;21m$false`e[0m❗"
                                        }
                                        "NeedsDeletion"
                                        {
                                            return "`e[33;4m$true`e[0m❗"
                                        }
                                        "Error"
                                        {
                                            return "`e[31;21mERROR`e[0m❗"
                                        }
                                    }
                                </ScriptBlock>
                            </TableColumnItem>
                             
                        </TableColumnItems>
                    </TableRowEntry>
                     
                </TableRowEntries>
            </TableControl>
        </View>
         
        <!-- symlink WIDE -->
        <View>
            <Name>Symlink.Wide</Name>
            <ViewSelectedBy>
                <SelectionSetName>Set.Symlink</SelectionSetName>
            </ViewSelectedBy>
             
            <WideControl>
                <WideEntries>
                     
                    <!-- BASIC Formatting -->
                    <WideEntry>
                        <!-- The symlink name. -->
                        <WideItem>
                            <ScriptBlock>
                                $name = $_.Name
                                $obj = $_
                                switch ($obj.GetState())
                                {
                                    "Exists"
                                    {
                                        switch ($obj.TargetState())
                                        {
                                            "Valid"
                                            {
                                                return "`e[32m$name`e[0m"
                                            }
                                            "Invalid"
                                            {
                                                return "`e[33;4m$name`e[0m`e[31m!`e[0m"
                                            }
                                            "MissingVariable"
                                            {
                                                return "`e[33;4m$name`e[0m`e[31m!`e[0m"
                                            }
                                        }
                                         
                                    }
                                    "NotExists"
                                    {
                                        return "`e[33m$name`e[0m"
                                    }
                                    "NeedsCreation"
                                    {
                                        return "`e[31;4m$name`e[0m`e[31m!`e[0m"
                                    }
                                    "NeedsDeletion"
                                    {
                                        return "`e[33;4m$name`e[0m`e[31m!`e[0m"
                                    }
                                    "Error"
                                    {
                                        return "`e[31;4mERROR`e[0m`e[31m!`e[0m"
                                    }
                                }
                            </ScriptBlock>
                        </WideItem>
                    </WideEntry>
                     
                    <!-- FANCY Formatting -->
                    <WideEntry>
                        <EntrySelectedBy>
                            <SelectionCondition>
                                <SelectionSetName>Set.Symlink</SelectionSetName>
                                <ScriptBlock>
                                    if ($env:WT_SESSION) {
                                        return $true
                                    }
                                </ScriptBlock>
                            </SelectionCondition>
                        </EntrySelectedBy>
                         
                        <!-- The symlink name. -->
                        <WideItem>
                            <ScriptBlock>
                                $name = $_.Name
                                $obj = $_
                                switch ($obj.GetState())
                                {
                                    "Exists"
                                    {
                                        switch ($obj.TargetState())
                                        {
                                            "Valid"
                                            {
                                                return "`e[32m$name✅`e[0m"
                                            }
                                            "Invalid"
                                            {
                                                return "`e[33;4m$name`e[0m❗"
                                            }
                                            "MissingVariable"
                                            {
                                                return "`e[33;4m$name`e[0m❗"
                                            }
                                        }
                                         
                                    }
                                    "NotExists"
                                    {
                                        return "`e[33m$name✅`e[0m"
                                    }
                                    "NeedsCreation"
                                    {
                                        return "`e[31;21m$name`e[0m❗"
                                    }
                                    "NeedsDeletion"
                                    {
                                        return "`e[33;21m$name`e[0m❗"
                                    }
                                    "Error"
                                    {
                                        return "`e[31;21mERROR`e[0m❗"
                                    }
                                }
                            </ScriptBlock>
                        </WideItem>
                    </WideEntry>
                     
                </WideEntries>
            </WideControl>
        </View>
         
    </ViewDefinitions>
     
</Configuration>