Powershell GUI fronted (WPF) to run categorized console scripts

⌈⌋ ⎇ branch:  ClickyColoury


Check-in [8e78d588f1]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Simpler Start-Process doesn't work. PS does not escape double quotes in -ArgumentList properly, nor allows escaping with standard CMD ^ caret etc.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 8e78d588f10dee63b32bfa8af22630afa9fe4030
User & Date: mario 2018-05-18 17:57:05
Context
2018-05-18
17:57
Add PSR as default tool. check-in: efdfe648a3 user: mario tags: trunk
17:57
Simpler Start-Process doesn't work. PS does not escape double quotes in -ArgumentList properly, nor allows escaping with standard CMD ^ caret etc. check-in: 8e78d588f1 user: mario tags: trunk
17:54
Add online repo shortcut, disable config option (not going to use plugin scan or add direct download). check-in: 1470549b26 user: mario tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to contrib/RichtextboxCopyPlainText.ps1.

1
2
3
4
5
6
7
8
9
10
11
12
13
# encoding: utf-8
# api: clicky
# type: init-gui
# version: 0.2
# title: Copy plain text
# description: override [Ctl-C] and [Ins] to copy just text/plain from color output
# category: ui
# state: stable
# hidden: 1
# nomenu: 1
#
# That's a workaround, which prevents copying RTF from RichTextBox/FlowDoc.
# Only extracts/converts from the current text selection.





|







1
2
3
4
5
6
7
8
9
10
11
12
13
# encoding: utf-8
# api: clicky
# type: init-gui
# version: 0.2
# title: Copy plain text
# description: override ⌨[Ctl-C] and [Ins] to copy just text/plain from color output
# category: ui
# state: stable
# hidden: 1
# nomenu: 1
#
# That's a workaround, which prevents copying RTF from RichTextBox/FlowDoc.
# Only extracts/converts from the current text selection.

Changes to modules/guimenu.psm1.

1
2
3
4
5
6
7
8
9
10
11
12
13
# api: ps
# title: GUI handling, WPF + WinForms
# description: WinForm and WPF interaction, GUI and thread handling
# depends: menu, clipboard, sys:presentationframework, sys:system.windows.forms, sys:system.drawing
# doc: http://fossil.include-once.org/clickycoloury/wiki/W
# version: 1.2.0
# license: MITL
# type: functions
# category: ui
# config:
#   { name: cfg.threading, type: bool, value: 1, description: Enable threading/runspaces for GUI/WPF version }
#   { name: cfg.autoclear, type: int, value: 300, description: Clear output box after N seconds. }
#   { name: cfg.noheader, type: bool, value: 0, description: Disable script info header in output. }





|







1
2
3
4
5
6
7
8
9
10
11
12
13
# api: ps
# title: GUI handling, WPF + WinForms
# description: WinForm and WPF interaction, GUI and thread handling
# depends: menu, clipboard, sys:presentationframework, sys:system.windows.forms, sys:system.drawing
# doc: http://fossil.include-once.org/clickycoloury/wiki/W
# version: 1.2.1
# license: MITL
# type: functions
# category: ui
# config:
#   { name: cfg.threading, type: bool, value: 1, description: Enable threading/runspaces for GUI/WPF version }
#   { name: cfg.autoclear, type: int, value: 300, description: Clear output box after N seconds. }
#   { name: cfg.noheader, type: bool, value: 0, description: Disable script info header in output. }
931
932
933
934
935
936
937

938
939
940
941
942
943
944
        $meta_params = @( @{name="machine"}, @{name="username"} )
    }
    ForEach ($key in ($meta_params | % { $_.name })) {
        # aliases
        $key = Get-VarsAlias $key
        # quote + append
        $out += ' "'+($vals[$key] -replace '(["^])','^$1')+'"'

    }
    return $out
}

#-- fetch all script input vars - ribbon fields + custom vars:
function Get-ScriptVars($e) {
    #-- machine, user







>







931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
        $meta_params = @( @{name="machine"}, @{name="username"} )
    }
    ForEach ($key in ($meta_params | % { $_.name })) {
        # aliases
        $key = Get-VarsAlias $key
        # quote + append
        $out += ' "'+($vals[$key] -replace '(["^])','^$1')+'"'
        #$out += $vals[$key]
    }
    return $out
}

#-- fetch all script input vars - ribbon fields + custom vars:
function Get-ScriptVars($e) {
    #-- machine, user
1031
1032
1033
1034
1035
1036
1037
1038

1039
1040
1041
1042
1043
1044
1045
        elseif ($e.func) {
            [void]((Invoke-Expression "$e.func $machine $username") | Out-String | Out-Gui -f Yellow)
        }
        #-- Start script
        elseif ($e.fn) {
            if ($e.type -match "window|cli") {  # in separate window
                $cmd_params = Convert-VarsToCmdArgs ($e.vars) ($GUI.vars)
                Start-Process powershell.exe -Argumentlist "-STA -ExecutionPolicy ByPass -File $($e.fn) $cmd_params"

            }
            else {  # dot-source all "inline" type: plugins
                . $e.fn | Out-String -Width 120 | Out-Gui
            }
        }
        #-- No handler
        else {







|
>







1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
        elseif ($e.func) {
            [void]((Invoke-Expression "$e.func $machine $username") | Out-String | Out-Gui -f Yellow)
        }
        #-- Start script
        elseif ($e.fn) {
            if ($e.type -match "window|cli") {  # in separate window
                $cmd_params = Convert-VarsToCmdArgs ($e.vars) ($GUI.vars)
                Start-Process powershell.exe -Argumentlist "-STA -ExecutionPolicy ByPass -File ""$($e.fn)"" $cmd_params"
                #Start-Process powershell.exe -ArgumentList (@("-STA", "-ExecutionPolicy", "ByPass", "-File", $e.fn)+@($cmd_params))
            }
            else {  # dot-source all "inline" type: plugins
                . $e.fn | Out-String -Width 120 | Out-Gui
            }
        }
        #-- No handler
        else {