mirror of
https://github.com/sourcegraph/sourcegraph.git
synced 2026-02-06 17:31:43 +00:00
sg: print teammate details to terminal (#62031)
while looking into why certain github handles were not picked up I
noticed this was missing and it seems pretty useful
This commit is contained in:
parent
9bf06b664c
commit
1f09814d6f
@ -56,6 +56,7 @@ sg teammate handbook asdine
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
teammate, err := resolver.ResolveByName(ctx.Context, strings.Join(args, " "))
|
||||
if err != nil {
|
||||
return err
|
||||
@ -84,7 +85,44 @@ sg teammate handbook asdine
|
||||
std.Out.Writef("Opening handbook link for %s: %s", teammate.Name, teammate.HandbookLink)
|
||||
return open.URL(teammate.HandbookLink)
|
||||
},
|
||||
}},
|
||||
},
|
||||
{
|
||||
Name: "details",
|
||||
ArgsUsage: "<nickname>",
|
||||
Usage: "print the details of a Sourcegraph",
|
||||
Action: func(ctx *cli.Context) error {
|
||||
args := ctx.Args().Slice()
|
||||
if len(args) == 0 {
|
||||
return errors.New("no nickname provided")
|
||||
}
|
||||
handle := strings.Join(args, "")
|
||||
resolver, err := getTeamResolver(ctx.Context)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
teammate, err := resolver.ResolveByGitHubHandle(ctx.Context, handle)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
markdownFmt := `**Name** : %s
|
||||
**Slack** : %s
|
||||
**Email** : %s
|
||||
**GitHub** : %s
|
||||
**Location** : %s
|
||||
**Role** : %s
|
||||
**Description**: %s`
|
||||
markdown := fmt.Sprintf(markdownFmt,
|
||||
teammate.Name,
|
||||
teammate.SlackName,
|
||||
teammate.Email,
|
||||
fmt.Sprintf("[%s](https://github.com/%s)", teammate.GitHub, teammate.GitHub),
|
||||
teammate.Description,
|
||||
teammate.Location,
|
||||
teammate.Role)
|
||||
return std.Out.WriteMarkdown(markdown)
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@ -290,6 +290,7 @@ func (o *Output) WriteMarkdown(str string, opts ...MarkdownStyleOpts) error {
|
||||
// wrap output at slightly less than terminal width
|
||||
glamour.WithWordWrap(o.caps.Width*4/5),
|
||||
glamour.WithEmoji(),
|
||||
glamour.WithPreservedNewLines(),
|
||||
)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "renderer")
|
||||
|
||||
Loading…
Reference in New Issue
Block a user