PSArm icon indicating copy to clipboard operation
PSArm copied to clipboard

PSArm affecting help

Open SteveL-MSFT opened this issue 3 years ago • 7 comments

PS> help about_operators
Exception: Not enough parameters provided

PS> gerr

Exception             :
    Type                        : System.Management.Automation.RuntimeException
    ErrorRecord                 :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Not enough parameters provided
            HResult : -2146233087
        CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : RuntimeException
    WasThrownFromThrowStatement : True
    Message                     : Not enough parameters provided
    HResult                     : -2146233087
TargetObject          : Not enough parameters provided
CategoryInfo          : OperationStopped: (Not enough parameters provided:String) [], RuntimeException
FullyQualifiedErrorId : Not enough parameters provided
InvocationInfo        :
    ScriptLineNumber : 257
    OffsetInLine     : 28
    HistoryId        : -1
    ScriptName       : /Users/steve/.local/share/powershell/Modules/PSArm/0.1.0/ArmBuiltins.psm1
    Line             : if ($args.Count -lt 2){ throw 'Not enough parameters provided' }

    PositionMessage  : At /Users/steve/.local/share/powershell/Modules/PSArm/0.1.0/ArmBuiltins.psm1:257 char:28
                       +    if ($args.Count -lt 2){ throw 'Not enough parameters provided' }
                       +                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    PSScriptRoot     : /Users/steve/.local/share/powershell/Modules/PSArm/0.1.0
    PSCommandPath    : /Users/steve/.local/share/powershell/Modules/PSArm/0.1.0/ArmBuiltins.psm1
    CommandOrigin    : Internal
ScriptStackTrace      : at less, /Users/steve/.local/share/powershell/Modules/PSArm/0.1.0/ArmBuiltins.psm1: line 257
                        at <ScriptBlock>, <No file>: line 144
                        at <ScriptBlock>, <No file>: line 1

Get-Help does work, but for some reason the help function calls into PSArm

SteveL-MSFT avatar Apr 19 '21 19:04 SteveL-MSFT

What does gcm help tell you?

rjmholt avatar Apr 19 '21 20:04 rjmholt

Oh it's an ARM expression function

rjmholt avatar Apr 19 '21 20:04 rjmholt

This is currently by design then -- those functions take the same names as ARM expression functions.

We could theoretically only define those functions within Arm blocks, but I'm not sure if we should

rjmholt avatar Apr 19 '21 20:04 rjmholt

Since arm expression functions could overlap with any existing command, it seems preferable for those to only exist within Arm blocks, if possible. What would be the downside to that approach?

SteveL-MSFT avatar Apr 24 '21 13:04 SteveL-MSFT

The only drawback I see is if you wanted to evaluate resources outside an ARM block.

Even with this change though you could still write those definitions in a separate script. You just wouldn't be able to evaluate them properly outside an ARM block.

It would be a pretty subtle behaviour, but perhaps only as subtle as anything else in the DSL.

rjmholt avatar Apr 24 '21 16:04 rjmholt

The other option, which I don't like, is to prefix any conflicting functions. So in this specific case it would be armhelp I guess which is pretty ugly. Or maybe better to have a suffix to not re-order the intellisense help-arm which is pretty bad, too.

SteveL-MSFT avatar Apr 25 '21 18:04 SteveL-MSFT

Yeah I definitely prefer the scoping option too

rjmholt avatar Apr 27 '21 16:04 rjmholt