diff --git a/main.go b/main.go index eb0568e..907bab0 100644 --- a/main.go +++ b/main.go @@ -159,6 +159,22 @@ func main() { fileType := c.String("filetype") fileComment := c.String("comment") + if c.Bool("list") { + for teamName, token := range config.Teams { + InitAPI(token) + for _, n := range listChannels() { + fmt.Printf("[%s] [channel] %s\n", teamName, n) + } + for _, n := range listGroups() { + fmt.Printf("[%s] [group] %s\n", teamName, n) + } + for _, n := range listIms() { + fmt.Printf("[%s] [im] %s\n", teamName, n) + } + } + os.Exit(0) + } + token := config.Teams[team] if token == "" { exitErr(fmt.Errorf("no such team: %s", team)) @@ -167,22 +183,6 @@ func main() { InitAPI(token) slackcat := newSlackcat(username, iconEmoji, channel) - if c.Bool("list") { - fmt.Println("channels:") - for _, n := range listChannels() { - fmt.Printf(" %s\n", n) - } - fmt.Println("groups:") - for _, n := range listGroups() { - fmt.Printf(" %s\n", n) - } - fmt.Println("ims:") - for _, n := range listIms() { - fmt.Printf(" %s\n", n) - } - os.Exit(0) - } - if len(c.Args()) > 0 { if c.Bool("stream") { output("filepath provided, ignoring stream option") diff --git a/slackcat.go b/slackcat.go index b169bde..46312b4 100644 --- a/slackcat.go +++ b/slackcat.go @@ -122,7 +122,7 @@ func (sc *Slackcat) postFile(filePath, fileName, fileType, fileComment string) { } start := time.Now() - _, err := api.FilesUpload(&slack.FilesUploadOpt{ + err := api.FilesUpload(&slack.FilesUploadOpt{ Filepath: filePath, Filename: fileName, Filetype: fileType,