Giter Site home page Giter Site logo

Comments (11)

jdhitsolutions avatar jdhitsolutions commented on July 20, 2024 3

You should make this as easy for the user as possible. Don't force them to know the technical details. Give them an easy to use parameter that accepts pipeline input by property name. They can then pass parameters values directly, splat, or pipe into the command.

from winget-cli.

jdhitsolutions avatar jdhitsolutions commented on July 20, 2024 1

You don't need a parameter that accepts a hashtable. That's what splatting is for.

from winget-cli.

denelon avatar denelon commented on July 20, 2024 1

This is something I use for DSC Resource testing:

$SplatParam = @{
    Name       = 'WindowsOptionalFeature'
    ModuleName = 'PSDesiredStateConfiguration'
    Method     = 'Test'
    Property   = @{
        Name      = 'Containers-DisposableClientVM'
        Ensure    = 'Enable'
    }
}

Invoke-DscResource @SplatParam
$SplatParam = @{
    Name       = 'WindowsOptionalFeature'
    ModuleName = 'PSDscResources'
    Method     = 'Test'
    Property   = @{
        Name      = 'Containers-DisposableClientVM'
        Ensure    = 'Present'
    }
}

Invoke-DscResource @SplatParam

I think what is being suggested is to be able to do something like this for the WinGet settings.

from winget-cli.

jdhitsolutions avatar jdhitsolutions commented on July 20, 2024 1

Don't commingle the design considerations of a DSC resource with a PowerShell commands. They are very distinct in their requirements.

from winget-cli.

jdhitsolutions avatar jdhitsolutions commented on July 20, 2024 1

I'd approach this in a more granular approach. First, how likely is the user going to need to change the Schema value? I also thing the default behavior is always to merge. Only set what the user specifies. I think all you need is a command with syntax like this:

PS D:\> Get-Command Set-WinGetUserSetting -syntax 

Set-WinGetUserSetting [[-AutoUpdateInterval] <int>] [[-ProgressBar] <string>] [<CommonParameters>]

I'd create a separate command called Set-WingetUserExperimentalFeature that right now would look like :

PS D:\> Get-Command Set-WinGetUserExperimentalSetting -syntax

Set-WinGetUserExperimentalSetting [-List] [-Upgrade] [<CommonParameters>]

As you add experimental features you would need to update this command. Also note that I changed to a singular noun to meet the accepted paradigm. From a DSC perspective, I can see where I want to configure a group of settings, but as an end-user I am likely to only need to change a single setting, like the progress bar. Does this make sense?

from winget-cli.

denelon avatar denelon commented on July 20, 2024

We went back and forth on the design choice with that. I can see the value in both approaches. We're also going to be doing some work with DSC v3 to enable WinGet to act as its own DSC resource.

Given the distinction that some settings are user based and some require elevation, would you include that in the name, or just as a part of the output when the cmdlet is called? Naming things is hard...

What names and arguments would you suggest?

from winget-cli.

stephengillie avatar stephengillie commented on July 20, 2024

Requiring a properly-formatted hashtable of data is an advanced user input method. PowerShell functions and cmdlets should be open to all users, not just advanced users who have researched a particular area.

The way to do this is to construct the PowerShell function in such a way that the upper parameters define the details - and the last parameter accept the hashtable, with its default value being a hashtable of all of the parameters above it. This is essentially a "sideways wrapper" with an advanced input method.

Example:

Function Get-MonthAndDay {
	param(
		$Month = 7,
		$Day = 4,
		$hash = @{ month = $month; day = $day }
	)
	Get-Date -Month $hash.month -Day $hash.day
}

from winget-cli.

denelon avatar denelon commented on July 20, 2024

@jdhitsolutions, what kind of proposed example do you have here? I value your expertise over mine very highly here 😊

I was just showing an example of what I have seen in terms of splatting. I could be way off base. I'm just being transparent about my ignorance.

from winget-cli.

denelon avatar denelon commented on July 20, 2024

I do see the distinction between the interface we're proposing for WinGet as a DSC v3 resource and the PowerShell cmdlets a user would want to use to manage settings.

from winget-cli.

jdhitsolutions avatar jdhitsolutions commented on July 20, 2024

Actually, I'd have to think a bit further on the experimental features cmdlet because I would need a way to turn something off and I don't like parameters that take Boolean values. But hopefully, you still get the idea.

from winget-cli.

denelon avatar denelon commented on July 20, 2024

Makes sense. Thanks for the examples!

from winget-cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.