镜像站点 · 本页由第三方 GitHub 只读镜像提供,非 GitHub 官方站点,不接受任何登录或凭据输入。前往 github.com
Skip to content

Support seamless pipelining of related cmdlets #63

Closed

Description

Many related PowerShell cmdlets are designed to operate off of a common datatype in order to support pipelining, e.g.

Get-ChildItem .. | Remove-Item

So Get-ChildItem outputs a [System.IO.FileInfo] object and Remove-Item is designed to populate it's input either from a [System.IO.FileInfo] object or by explicit named parameter.

The cmdlets in this module should support a similar paradigm, so that related cmdlets can be seamlessly piped to each other, as PowerShell users would expect, e.g.

New-GitHubMilestone ... |
    Update-GitHubIssue -Issue 4 -PassThru |
    Update-GitHubIssue -Issue 10

In this example, the OwnerName, RepositoryName, and Milestone can be inferred based on the presence of the Milestone object in the pipeline.

Activity

  1. added
    enhancementAn issue or pull request introducing new functionality to the project.
    up for grabsAnyone in the community is welcome to do this work
    help wantedAnyone in the community is welcome to do this work
    technical debtWork that was postponed by a previous change.
    on Dec 6, 2018
  2. Thraka commented on Jan 24, 2019

    @Thraka

    I'm really surprised this wasn't designed from the ground up to be built like this. I mean, it's PowerShell, that's the whole point 😄

  3. HowardWolosky commented on Jan 24, 2019

    @HowardWolosky
    Contributor

    It was an oversight at the time when I did a refresh of the module. Luckily, adding-in pipeline support is totally possible (as Daniel described). If you're interested in helping out Andy De George (@Thraka), we'd love any contributions.

  4. Thraka commented on Jan 25, 2019

    @Thraka

    I'm not a powershell design expert at all 😄 I still design my powershell like it's C#/.net code

  5. TylerLeonhardt commented on Jun 2, 2020

    @TylerLeonhardt
    Member

    The reality is, it's hard. This module should try to do the least amount of work as possible over the GitHub API because if that changes, this breaks.

    Additionally, I'm sure that Howard Wolosky (@HowardWolosky) doesn't want to be in the business of writing types/classes for all the GitHub outputs.

    Take a look at how I did pipelining in #193

    [Parameter(Mandatory, ParameterSetName='Uri', ValueFromPipelineByPropertyName)]
    [Alias("repository_url")]
    [string] $Uri,
    
    [Parameter(Mandatory, ParameterSetName='Elements')]
    [Parameter(Mandatory, ParameterSetName='Uri', ValueFromPipelineByPropertyName)]
    [Alias("number")]
    [int64] $Issue,

    The idea is, using the power of parameter aliases and ValueFromPipelineByPropertyName to allow the output of some cmdlets to pipe into others.

  6. HowardWolosky commented on Jun 4, 2020

    @HowardWolosky
    Contributor

    Actually, I started thinking about this some more after having looked at your #193 and Simon Heather (@X-Guardian)'s #205. I think this can be done in a pretty natural way. I started experimenting over here:

    HowardWolosky/PowerShellForGitHub@c1e88b6

    I think we should be explicitly adding consistently named properties to all objects that we're returning. For instance, if it's an object somehow related to a specific repo, then is should have a RepositorUrl NoteProperty on it. Then we can use your ValueFromPipelineByPropertyName trick with the added [Alias('RepositoryName')] on Uri so that just about any object pipelined into another function can auto-extract the relevant OwnerName/RepositoryName from that Uri. Additionally, if the object being returned has its own ID (like an Issue or Release), then we should be adding an explicit IssueId or ReleaseId property to those objects. That way, the [Alias] for those functions can really be explicit to avoid mistaken casting from a bad pipeline (so, for instance, we wouldn't use number like you do above for Issue.

  7. added a commit that references this issue on Jun 18, 2020
    17f6122
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementAn issue or pull request introducing new functionality to the project.help wantedAnyone in the community is welcome to do this worktechnical debtWork that was postponed by a previous change.up for grabsAnyone in the community is welcome to do this work

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions