Skip to content

Refactor: FormatTaskName#322

Merged
HeyItsGilbert merged 1 commit intopsake:masterfrom
Splaxi:refactor-formattaskname
Sep 21, 2024
Merged

Refactor: FormatTaskName#322
HeyItsGilbert merged 1 commit intopsake:masterfrom
Splaxi:refactor-formattaskname

Conversation

@Splaxi
Copy link
Copy Markdown
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 FormatTaskName -Full

NAME
    FormatTaskName

SYNOPSIS
    This function allows you to change how psake renders the task name during a build.


SYNTAX
    FormatTaskName [-Format] <Object> [<CommonParameters>]


DESCRIPTION
    This function takes either a string which represents a format string (formats using
    the -f format operator see "help about_operators") or it can accept a script block
    that has a single parameter that is the name of the task that will be executed.


PARAMETERS
    -Format <Object>
        A format string or a scriptblock to execute

        Required?                    true
        Position?                    1
        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:\>A sample build script that uses a format string is shown below:

    Task default -depends TaskA, TaskB, TaskC

    FormatTaskName "-------- {0} --------"

    Task TaskA {
    "TaskA is executing"
    }

    Task TaskB {
    "TaskB is executing"
    }

    Task TaskC {
    "TaskC is executing"

    -----------
    The script above produces the following output:

    -------- TaskA --------
    TaskA is executing
    -------- TaskB --------
    TaskB is executing
    -------- TaskC --------
    TaskC is executing

    Build Succeeded!




    -------------------------- EXAMPLE 2 --------------------------

    PS C:\>A sample build script that uses a ScriptBlock is shown below:

    Task default -depends TaskA, TaskB, TaskC

    FormatTaskName {
        param($taskName)
        write-host "Executing Task: $taskName" -foregroundcolor blue
    }

    Task TaskA {
    "TaskA is executing"
    }

    Task TaskB {
    "TaskB is executing"
    }

    Task TaskC {
    "TaskC is executing"
    }

    -----------
    The above example uses the scriptblock parameter to the FormatTaskName function to
    render each task name in the color blue.

    Note: the $taskName parameter is arbitrary, it could be named anything.





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

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.

@HeyItsGilbert HeyItsGilbert merged commit 8858075 into psake:master Sep 21, 2024
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.

2 participants