Adds describe output... but Im not sold on it. Siloing in a branch for now.
This commit is contained in:
parent
77de8e95af
commit
6051ef6c01
66
main.go
66
main.go
|
@ -28,6 +28,7 @@ import (
|
|||
"os/signal"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"syscall"
|
||||
"tildegit.org/sloum/swim/termios"
|
||||
|
@ -254,6 +255,59 @@ func SetColorFromFlag(f string) int {
|
|||
}
|
||||
}
|
||||
|
||||
func DescribeFile() {
|
||||
fmt.Printf("\033[1m%s\033[0m\n\n", fp)
|
||||
fmt.Printf("\t\033[1m%s\033[0m (%d lanes)\n", board.Title, len(board.Lanes))
|
||||
users := map[string]bool{}
|
||||
comments := 0
|
||||
if len(board.Lanes) > 0 {
|
||||
for l := range board.Lanes {
|
||||
storyWord := "stories"
|
||||
if len(board.Lanes[l].Stories) == 1 {
|
||||
storyWord = "story"
|
||||
}
|
||||
var b strings.Builder
|
||||
points := 0
|
||||
for s := range board.Lanes[l].Stories {
|
||||
pts := "-"
|
||||
if board.Lanes[l].Stories[s].Points > 0 {
|
||||
pts = strconv.Itoa(board.Lanes[l].Stories[s].Points)
|
||||
}
|
||||
pointWord := "points"
|
||||
if pts == "1" {
|
||||
pointWord = "point"
|
||||
}
|
||||
b.WriteString(fmt.Sprintf("\t\t\t\033[1m%s\033[0m (%s %s)\n",board.Lanes[l].Stories[s].Title, pts, pointWord))
|
||||
points += board.Lanes[l].Stories[s].Points
|
||||
for u := range board.Lanes[l].Stories[s].Users {
|
||||
users[board.Lanes[l].Stories[s].Users[u]] = true
|
||||
}
|
||||
comments += len(board.Lanes[l].Stories[s].Comments)
|
||||
}
|
||||
pointWord := "points"
|
||||
if points == 1 {
|
||||
pointWord = "point"
|
||||
}
|
||||
fmt.Printf("\n\t\t\033[1m%s\033[0m (%d %s - %d %s)\n", board.Lanes[l].Title, len(board.Lanes[l].Stories), storyWord, points, pointWord)
|
||||
fmt.Print(b.String())
|
||||
}
|
||||
userWord := "users"
|
||||
if len(users) == 1 {
|
||||
userWord = "user"
|
||||
}
|
||||
fmt.Printf("\n\t\033[1m%d %s\033[0m assigned to stories\n", len(users), userWord)
|
||||
for k := range users {
|
||||
fmt.Printf("\t\t%s\n", k)
|
||||
}
|
||||
commentWord := "comments"
|
||||
if comments == 1 {
|
||||
commentWord = "comment"
|
||||
}
|
||||
fmt.Printf("\t\033[1m%d %s\033[0m\n", comments, commentWord)
|
||||
}
|
||||
Quit()
|
||||
}
|
||||
|
||||
func printHelp() {
|
||||
header := `swim - project board
|
||||
|
||||
|
@ -280,21 +334,31 @@ Flags:
|
|||
func main() {
|
||||
flag.Usage = printHelp
|
||||
colors := flag.String("color", "", "Color mode: Simple, 256, True, None" )
|
||||
describe := flag.Bool("describe", false, "Output data to stdout about the file being passed in, then exit")
|
||||
flag.Parse()
|
||||
args := flag.Args()
|
||||
style.Init(SetColorFromFlag(*colors))
|
||||
cols, rows := termios.GetWindowSize()
|
||||
arg0 := strings.ToLower(args[0])
|
||||
if len(args) > 0 {
|
||||
if strings.ToLower(args[0]) == "init" {
|
||||
if arg0 == "init" {
|
||||
InitNewBoard()
|
||||
} else {
|
||||
LoadFile(args[0], cols, rows)
|
||||
}
|
||||
} else {
|
||||
if *describe {
|
||||
fmt.Fprintf(os.Stderr, "Describe what? No path was passed.")
|
||||
os.Exit(1)
|
||||
}
|
||||
fp = ""
|
||||
board = DefaultBoard(cols, rows)
|
||||
}
|
||||
|
||||
if *describe {
|
||||
DescribeFile()
|
||||
}
|
||||
|
||||
// watch for signals, send them to be handled
|
||||
c := make(chan os.Signal, 1)
|
||||
signal.Notify(c, syscall.SIGTSTP, syscall.SIGCONT, syscall.SIGINT)
|
||||
|
|
Loading…
Reference in New Issue