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

Commit 1f09814

Browse files
authored
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
1 parent 9bf06b6 commit 1f09814

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

dev/sg/sg_teammate.go

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ sg teammate handbook asdine
5656
if err != nil {
5757
return err
5858
}
59+
5960
teammate, err := resolver.ResolveByName(ctx.Context, strings.Join(args, " "))
6061
if err != nil {
6162
return err
@@ -84,7 +85,44 @@ sg teammate handbook asdine
8485
std.Out.Writef("Opening handbook link for %s: %s", teammate.Name, teammate.HandbookLink)
8586
return open.URL(teammate.HandbookLink)
8687
},
87-
}},
88+
},
89+
{
90+
Name: "details",
91+
ArgsUsage: "<nickname>",
92+
Usage: "print the details of a Sourcegraph",
93+
Action: func(ctx *cli.Context) error {
94+
args := ctx.Args().Slice()
95+
if len(args) == 0 {
96+
return errors.New("no nickname provided")
97+
}
98+
handle := strings.Join(args, "")
99+
resolver, err := getTeamResolver(ctx.Context)
100+
if err != nil {
101+
return err
102+
}
103+
teammate, err := resolver.ResolveByGitHubHandle(ctx.Context, handle)
104+
if err != nil {
105+
return err
106+
}
107+
markdownFmt := `**Name** : %s
108+
**Slack** : %s
109+
**Email** : %s
110+
**GitHub** : %s
111+
**Location** : %s
112+
**Role** : %s
113+
**Description**: %s`
114+
markdown := fmt.Sprintf(markdownFmt,
115+
teammate.Name,
116+
teammate.SlackName,
117+
teammate.Email,
118+
fmt.Sprintf("[%s](https://github.com/%s)", teammate.GitHub, teammate.GitHub),
119+
teammate.Description,
120+
teammate.Location,
121+
teammate.Role)
122+
return std.Out.WriteMarkdown(markdown)
123+
},
124+
},
125+
},
88126
}
89127
)
90128

lib/output/output.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ func (o *Output) WriteMarkdown(str string, opts ...MarkdownStyleOpts) error {
290290
// wrap output at slightly less than terminal width
291291
glamour.WithWordWrap(o.caps.Width*4/5),
292292
glamour.WithEmoji(),
293+
glamour.WithPreservedNewLines(),
293294
)
294295
if err != nil {
295296
return errors.Wrap(err, "renderer")

0 commit comments

Comments
 (0)