unified output (#14) (#40)

This commit is contained in:
root360-AndreasUlm
2019-09-15 08:38:18 +00:00
committed by Gitea
parent 1d233402fd
commit 7c024bcd69
24 changed files with 2866 additions and 12 deletions

View File

@ -5,7 +5,6 @@
package cmd
import (
"fmt"
"log"
"os"
"path/filepath"
@ -33,6 +32,11 @@ var CmdReleases = cli.Command{
Name: "repo, r",
Usage: "Indicate one repository, optional when inside a gitea repository",
},
cli.StringFlag{
Name: "output, o",
Usage: outputUsage,
Destination: &output,
},
},
}
@ -44,17 +48,32 @@ func runReleases(ctx *cli.Context) error {
log.Fatal(err)
}
headers := []string{
"Tag-Name",
"Title",
"Published At",
"Tar URL",
}
var values [][]string
if len(releases) == 0 {
fmt.Println("No Releases")
Output(output, headers, values)
return nil
}
for _, release := range releases {
fmt.Printf("#%s\t%s\t%s\t%s\n", release.TagName,
release.Title,
release.PublishedAt.Format("2006-01-02 15:04:05"),
release.TarURL)
values = append(
values,
[]string{
release.TagName,
release.Title,
release.PublishedAt.Format("2006-01-02 15:04:05"),
release.TarURL,
},
)
}
Output(output, headers, values)
return nil
}