Loading .gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,4 @@ *.lzh .*.swp dupl.html unit-test-output Makefile +13 −2 Original line number Diff line number Diff line .PHONY: all all: .PHONY: all dupl build test docs all: build test build: go generate ./... go install ./... Loading @@ -10,7 +12,16 @@ dupl: > dupl.html xdg-open dupl.html test: @mkdir -p unit-test-output @go vet ./... @CGO_ENABLED=1 go test -cover -coverpkg=./... -coverprofile=unit-test-output/coverage.out -race ./... @go tool cover -html=unit-test-output/coverage.out @go tool cover -func unit-test-output/coverage.out \ | tail -1 | sed 's/[ \t(:][ \t(:]*/ /g;s/)/:/' docs: go tool golang.org/x/pkgsite/cmd/pkgsite -open # vim:ft=make # batch/batch.go +4 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,10 @@ import ( "text/template" "time" "git.lyda.ie/kevin/bulletin/ask" "git.lyda.ie/kevin/bulletin/key" "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/users" "git.lyda.ie/pp/bulletin/ask" "git.lyda.ie/pp/bulletin/key" "git.lyda.ie/pp/bulletin/storage" "git.lyda.ie/pp/bulletin/users" "github.com/adrg/xdg" ) Loading dclish/dclish.go +11 −20 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ commands. package dclish import ( "errors" "fmt" "strings" "unicode" Loading Loading @@ -187,15 +188,13 @@ func (c Commands) run(words []string) error { } switch len(possibles) { case 0: fmt.Printf("ERROR: Unknown command '%s'\n", words[0]) return nil return fmt.Errorf("Unknown command '%s'", words[0]) case 1: wordup = possibles[0] cmd = c[wordup] default: fmt.Printf("ERROR: Ambiguous command '%s' (matches %s)\n", return fmt.Errorf("Ambiguous command '%s' (matches %s)", words[0], strings.Join(possibles, ", ")) return nil } } Loading @@ -203,8 +202,7 @@ func (c Commands) run(words []string) error { if len(cmd.Commands) > 0 { if len(words) == 1 { if cmd.Action == nil { fmt.Printf("ERROR: missing subcommand for %s.\n", wordup) return nil return fmt.Errorf("missing subcommand for %s", wordup) } return cmd.Action(cmd) } Loading @@ -212,8 +210,7 @@ func (c Commands) run(words []string) error { } if cmd.Action == nil { fmt.Printf("ERROR: Command not implemented:\n%s\n", cmd.Description) return nil return fmt.Errorf("Command not implemented:\n%s", cmd.Description) } for flg := range cmd.Flags { cmd.Flags[flg].Value = cmd.Flags[flg].Default Loading @@ -223,8 +220,7 @@ func (c Commands) run(words []string) error { if len(words) == 1 { if len(cmd.Args) < cmd.MinArgs { fmt.Println("ERROR: Not enough args.") return nil return errors.New("Not enough args") } return cmd.Action(cmd) } Loading @@ -244,18 +240,15 @@ func (c Commands) run(words []string) error { wordup = strings.Replace(wordup, "/NO", "/", 1) flg, ok = cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.\n", args[i]) return nil return fmt.Errorf("Flag '%s' not recognised", args[i]) } toggleValue = "false" } if !flg.OptArg && assigned { fmt.Printf("ERROR: Flag '%s' is a toggle.\n", args[i]) return nil return fmt.Errorf("Flag '%s' is a toggle", args[i]) } if flg.Set { fmt.Printf("ERROR: Flag '%s' is already set.\n", args[i]) return nil return fmt.Errorf("Flag '%s' is already set", args[i]) } flg.Set = true if flg.OptArg { Loading @@ -267,15 +260,13 @@ func (c Commands) run(words []string) error { } } else { if len(cmd.Args) == cmd.MaxArgs { fmt.Printf("ERROR: Too many args at '%s'\n", args[i]) return nil return fmt.Errorf("Too many args at '%s'", args[i]) } cmd.Args = append(cmd.Args, args[i]) } } if len(cmd.Args) < cmd.MinArgs { fmt.Println("ERROR: Not enough args.") return nil return errors.New("Not enough args") } return cmd.Action(cmd) } folders/folders.go +2 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ import ( "errors" "strings" "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/this" "git.lyda.ie/pp/bulletin/storage" "git.lyda.ie/pp/bulletin/this" ) // ValidFolder validates the folder name for this user. Loading Loading
.gitignore +1 −0 Original line number Diff line number Diff line Loading @@ -8,3 +8,4 @@ *.lzh .*.swp dupl.html unit-test-output
Makefile +13 −2 Original line number Diff line number Diff line .PHONY: all all: .PHONY: all dupl build test docs all: build test build: go generate ./... go install ./... Loading @@ -10,7 +12,16 @@ dupl: > dupl.html xdg-open dupl.html test: @mkdir -p unit-test-output @go vet ./... @CGO_ENABLED=1 go test -cover -coverpkg=./... -coverprofile=unit-test-output/coverage.out -race ./... @go tool cover -html=unit-test-output/coverage.out @go tool cover -func unit-test-output/coverage.out \ | tail -1 | sed 's/[ \t(:][ \t(:]*/ /g;s/)/:/' docs: go tool golang.org/x/pkgsite/cmd/pkgsite -open # vim:ft=make #
batch/batch.go +4 −4 Original line number Diff line number Diff line Loading @@ -26,10 +26,10 @@ import ( "text/template" "time" "git.lyda.ie/kevin/bulletin/ask" "git.lyda.ie/kevin/bulletin/key" "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/users" "git.lyda.ie/pp/bulletin/ask" "git.lyda.ie/pp/bulletin/key" "git.lyda.ie/pp/bulletin/storage" "git.lyda.ie/pp/bulletin/users" "github.com/adrg/xdg" ) Loading
dclish/dclish.go +11 −20 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ commands. package dclish import ( "errors" "fmt" "strings" "unicode" Loading Loading @@ -187,15 +188,13 @@ func (c Commands) run(words []string) error { } switch len(possibles) { case 0: fmt.Printf("ERROR: Unknown command '%s'\n", words[0]) return nil return fmt.Errorf("Unknown command '%s'", words[0]) case 1: wordup = possibles[0] cmd = c[wordup] default: fmt.Printf("ERROR: Ambiguous command '%s' (matches %s)\n", return fmt.Errorf("Ambiguous command '%s' (matches %s)", words[0], strings.Join(possibles, ", ")) return nil } } Loading @@ -203,8 +202,7 @@ func (c Commands) run(words []string) error { if len(cmd.Commands) > 0 { if len(words) == 1 { if cmd.Action == nil { fmt.Printf("ERROR: missing subcommand for %s.\n", wordup) return nil return fmt.Errorf("missing subcommand for %s", wordup) } return cmd.Action(cmd) } Loading @@ -212,8 +210,7 @@ func (c Commands) run(words []string) error { } if cmd.Action == nil { fmt.Printf("ERROR: Command not implemented:\n%s\n", cmd.Description) return nil return fmt.Errorf("Command not implemented:\n%s", cmd.Description) } for flg := range cmd.Flags { cmd.Flags[flg].Value = cmd.Flags[flg].Default Loading @@ -223,8 +220,7 @@ func (c Commands) run(words []string) error { if len(words) == 1 { if len(cmd.Args) < cmd.MinArgs { fmt.Println("ERROR: Not enough args.") return nil return errors.New("Not enough args") } return cmd.Action(cmd) } Loading @@ -244,18 +240,15 @@ func (c Commands) run(words []string) error { wordup = strings.Replace(wordup, "/NO", "/", 1) flg, ok = cmd.Flags[wordup] if !ok { fmt.Printf("ERROR: Flag '%s' not recognised.\n", args[i]) return nil return fmt.Errorf("Flag '%s' not recognised", args[i]) } toggleValue = "false" } if !flg.OptArg && assigned { fmt.Printf("ERROR: Flag '%s' is a toggle.\n", args[i]) return nil return fmt.Errorf("Flag '%s' is a toggle", args[i]) } if flg.Set { fmt.Printf("ERROR: Flag '%s' is already set.\n", args[i]) return nil return fmt.Errorf("Flag '%s' is already set", args[i]) } flg.Set = true if flg.OptArg { Loading @@ -267,15 +260,13 @@ func (c Commands) run(words []string) error { } } else { if len(cmd.Args) == cmd.MaxArgs { fmt.Printf("ERROR: Too many args at '%s'\n", args[i]) return nil return fmt.Errorf("Too many args at '%s'", args[i]) } cmd.Args = append(cmd.Args, args[i]) } } if len(cmd.Args) < cmd.MinArgs { fmt.Println("ERROR: Not enough args.") return nil return errors.New("Not enough args") } return cmd.Action(cmd) }
folders/folders.go +2 −2 Original line number Diff line number Diff line Loading @@ -12,8 +12,8 @@ import ( "errors" "strings" "git.lyda.ie/kevin/bulletin/storage" "git.lyda.ie/kevin/bulletin/this" "git.lyda.ie/pp/bulletin/storage" "git.lyda.ie/pp/bulletin/this" ) // ValidFolder validates the folder name for this user. Loading