PowerShell / Crescendo

a module for wrapping native applications in a PowerShell function and module
MIT License
399 stars 37 forks source link

Discussion: DSL: json => PS with custom attributes #94

Closed fsackur closed 3 years ago

fsackur commented 3 years ago

Hi maintainers,

I love that we have Crescendo and I have many use cases. But it's a hard sell to my team, because the creation of JSON files is different enough to the normal workflow to present a barrier to adoption.

I propose a DSL based on custom attributes that lets these be written as powershell script instead.

As a discussion starter:

[Crescendo.Command(OriginalName = 'bcu.exe', OriginalCommandElements = @('diag'), OutputHandlers = 'Parse-BcuDiagOutput')]
function Get-BcuDiag
{
    param
    (
        [Parameter()]
        [Crescendo.Parameter(OriginalName = "--tempshow")]
        [switch]$ShowTemperature
    )

    # no function body - that's Crescendo's job
}
theJasonHelmick commented 3 years ago

@fsackur - Thank you for opening this discussion. I’m going to transfer this to the Discussions page. Also linking similar discussion "Why JSON instead of psd1?" #96

This is not on our plans for the crescendo GA, but I’m very interested in this discussion as adoption and the ease of creating the configuration files is important. Our focus has been to make the schematized JSON configuration as simple as possible, and we are investigating autogeneration of the configuration for newer native commands that produce structured output like Docker or kubectl. This wouldn’t cover all scenarios, especially older commands. As this investigation progresses, I will share more information here. Depending on community feedback, the autogeneration might be something we could look at doing post Crecendo GA.

This doesn’t address those folks that would prefer to use PowerShell script to create the JSON configuration and I would be interested in further understanding:

Thank you for opening the discussion!