Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor: Exec #321

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Refactor: Exec #321

wants to merge 5 commits into from

Conversation

Splaxi
Copy link
Contributor

@Splaxi Splaxi commented Apr 14, 2022

Convert parameter names into pascal

Description

Convert parameter names into pascal

Related Issue

#308

Motivation and Context

How Has This Been Tested?

ps>Get-Help Exec -Full

NAME
    Exec

SYNOPSIS
    Helper function for executing command-line programs.


SYNTAX
    Exec [-Cmd] <ScriptBlock> [[-ErrorMessage] <String>] [[-MaxRetries] <Int32>]
    [[-RetryTriggerErrorPattern] <String>] [[-WorkingDirectory] <String>]
    [<CommonParameters>]


DESCRIPTION
    This is a helper function that runs a scriptblock and checks the PS variable
    $lastexitcode to see if an error occcured.
    If an error is detected then an exception is thrown.
    This function allows you to run command-line programs without having to explicitly
    check fthe $lastexitcode variable.


PARAMETERS
    -Cmd <ScriptBlock>
        The scriptblock to execute. This scriptblock will typically contain the
        command-line invocation.

        Required?                    true
        Position?                    1
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -ErrorMessage <String>
        The error message to display if the external command returned a non-zero exit
        code.

        Required?                    false
        Position?                    2
        Default value                ($msgs.error_bad_command -f $Cmd)
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -MaxRetries <Int32>
        The maximum number of times to retry the command before failing.

        Required?                    false
        Position?                    3
        Default value                0
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -RetryTriggerErrorPattern <String>
        If the external command raises an exception, match the exception against this
        regex to determine if the command can be retried.
        If a match is found, the command will be retried provided [MaxRetries] has not
        been reached.

        Required?                    false
        Position?                    4
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    -WorkingDirectory <String>
        The working directory to set before running the external command.

        Required?                    false
        Position?                    5
        Default value
        Accept pipeline input?       false
        Accept wildcard characters?  false

    <CommonParameters>
        This cmdlet supports the common parameters: Verbose, Debug,
        ErrorAction, ErrorVariable, WarningAction, WarningVariable,
        OutBuffer, PipelineVariable, and OutVariable. For more information, see
        about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).

INPUTS

OUTPUTS

    -------------------------- EXAMPLE 1 --------------------------

    PS C:\>exec { svn info $repository_trunk } "Error executing SVN. Please verify SVN
    command-line client is installed"

    This example calls the svn command-line client.





RELATED LINKS
    Assert
    FormatTaskName
    Framework
    Get-PSakeScriptTasks
    Include
    Invoke-psake
    Properties
    Task
    TaskSetup
    TaskTearDown
    Properties

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Splaxi Splaxi changed the title Refactor exec Refactor: Exec Apr 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant