Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

sg: print teammate details to terminal #62031

Merged
merged 1 commit into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 39 additions & 1 deletion dev/sg/sg_teammate.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
},
},
},
}
)

Expand Down
1 change: 1 addition & 0 deletions lib/output/output.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down