Skip to content

Support "GitLab-specific references" passed via CLI? #822

@claytonrcarter

Description

@claytonrcarter

GL supports many different special "references" in markdown. These are the shortcuts like #number to refer to an issue or !number to refer to an MR. Although it doesn't come up super often, there are semi-regular cases where I want to paste something into the cli like lab mr b <paste> but my clipboard includes the !. As we've already documented, I'm lazy and I think it would be really great of lab was able to deal w/ something like lab mr show !123.

Although there are many different shorthand references, I suspect that supporting issues and MRs would cover most of the use-cases.

This could be as simple as an update to

lab/cmd/util.go

Lines 290 to 306 in 73bada2

func parseArgsStringAndID(args []string) (string, int64, error) {
if len(args) == 2 {
n, err := strconv.ParseInt(args[1], 0, 64)
if err != nil {
return args[0], 0, err
}
return args[0], n, nil
}
if len(args) == 1 {
n, err := strconv.ParseInt(args[0], 0, 64)
if err != nil {
return args[0], 0, nil
}
return "", n, nil
}
return "", 0, nil
}
that strips the first char of an arg if it happens to be [#!], or it could be more robust where an error is thrown if, eg, we try call lab mr b #123 (ie I try to browse to an MR but give an issue ref).

If there's interest in this, I can take a whack at it. If the add'l "you're trying to browse to a mr but you passed an issue" is desired, that might extend beyond the scope of my abilities, though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions