diff --git a/cmd/gh-slack/main.go b/cmd/gh-slack/main.go
index 37b6572..5487cda 100644
--- a/cmd/gh-slack/main.go
+++ b/cmd/gh-slack/main.go
@@ -103,22 +103,35 @@ func realMain() error {
return err
}
+ var channelName string
if opts.Details {
- output = markdown.WrapInDetails(output)
+ channelInfo, err := client.ChannelInfo(channelID)
+ if err != nil {
+ return err
+ }
+
+ channelName = channelInfo.Name
+ output = markdown.WrapInDetails(channelName, opts.Args.Start, output)
}
if repoUrl != "" {
- channelInfo, err := client.ChannelInfo(channelID)
+ if channelName == "" {
+ channelInfo, err := client.ChannelInfo(channelID)
+ if err != nil {
+ return err
+ }
+ channelName = channelInfo.Name
+ }
+
+ err := gh.NewIssue(repoUrl, channelName, output)
if err != nil {
return err
}
- gh.NewIssue(repoUrl, channelInfo, output)
} else if issueUrl != "" {
- channelInfo, err := client.ChannelInfo(channelID)
+ err := gh.AddComment(issueUrl, output)
if err != nil {
return err
}
- gh.AddComment(issueUrl, channelInfo, output)
} else {
os.Stdout.WriteString(output)
}
diff --git a/internal/gh/gh.go b/internal/gh/gh.go
index bc2fa77..9f45ea8 100644
--- a/internal/gh/gh.go
+++ b/internal/gh/gh.go
@@ -5,30 +5,29 @@ import (
"os"
"github.com/cli/go-gh"
- "github.com/rneatherway/gh-slack/internal/slackclient"
)
-func NewIssue(repoUrl string, channel *slackclient.Channel, content string) error {
+func NewIssue(repoUrl string, channelName, content string) error {
out, _, err := gh.Exec(
"issue",
"-R",
repoUrl,
"create",
"--title",
- fmt.Sprintf("Slack conversation archive of `#%s`", channel.Name),
+ fmt.Sprintf("Slack conversation archive of `#%s`", channelName),
"--body",
content)
os.Stdout.Write(out.Bytes())
return err
}
-func AddComment(issueUrl string, channel *slackclient.Channel, content string) error {
+func AddComment(issueUrl string, content string) error {
out, _, err := gh.Exec(
"issue",
"comment",
issueUrl,
"--body",
- fmt.Sprintf("Slack conversation archive of `#%s`\n%s", channel.Name, content))
+ content)
os.Stdout.Write(out.Bytes())
return err
}
diff --git a/internal/markdown/markdown.go b/internal/markdown/markdown.go
index 5447057..f8d7b16 100644
--- a/internal/markdown/markdown.go
+++ b/internal/markdown/markdown.go
@@ -142,6 +142,7 @@ func FromMessages(client *slackclient.SlackClient, history *slackclient.HistoryR
return b.String(), nil
}
-func WrapInDetails(s string) string {
- return fmt.Sprintf("\n Click to expand
\n\n%s\n ", s)
+func WrapInDetails(channelName, link, s string) string {
+ return fmt.Sprintf("Slack conversation archive of [`#%s`](%s)\n\n\n Click to expand
\n\n%s\n ",
+ channelName, link, s)
}