Skip to content

param -ConfirmOnce for Mint.Invoke-App tests only once per pipeline #147

@ninmonkey

Description

@ninmonkey

Basic implementation currently prompts for every iteration

Mint.Invoke-AppWithConfirm -Name 'git' -CommandLineArgs @( 'add', $_ )

# like
$files | Get-Item -ea 'stop' | % {
    Mint.Invoke-AppWithConfirm -Name 'git' -CommandLineArgs @(
        'add'
        $_
    )
}

Note

You can add multiple files to git in a single invocation. That's just an example. other commands could include a
block of invokes that can't be simplified
So ignore that the example is git, replace it with anything.

Simple implementation

add an ForEachInput [object[]] parameter.

Mint.Invoke-AppConfirmOnce -Name 'git' -CommandLineArgs @( 'add', $args[0] ) -ForeachInput @( $files )

Which Internally calls

function Mint.Invoke-AppConfirmOnce  {
    # ...
    if ( -not ( PromptUserForCommand ) ) { return }  
    foreach ($Item in $ForEachInput ) { 
        Mint.Invoke-App git -CommandLineArgs @( 'add', $item )
    }
}

Or fake AST?

Should allow something like

# confirms once at the top
# invoked n-number of times. 
$files | Mint.Invoke-AppConfirmOnce -Name 'git' -CommandLineArgs @( 'add', $args[0] )

# Can I use args? Or do I need to parse the ast, replacing it with the next $INPUT 
$files | Mint.Invoke-AppConfirmOnce -Name 'git' -CommandLineArgs @( 'add', $fakeAstItem )

Metadata

Metadata

Assignees

Labels

CommandCmdlets, Functions, AliasesCommandLinecli, native commands, etc. comparison with "Command" which means Cmdlet-ishenhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions