Compare commits
3 commits
27a1025eba
...
e310c168f4
Author | SHA1 | Date | |
---|---|---|---|
e310c168f4 | |||
16bf5ace2a | |||
4de4a4aee2 |
2 changed files with 25 additions and 6 deletions
14
Makefile
14
Makefile
|
@ -1,5 +1,5 @@
|
||||||
VERS_MAJOR := 0
|
VERS_MAJOR := 0
|
||||||
VERS_MINOR := 3
|
VERS_MINOR := 4
|
||||||
VERSION := $(VERS_MAJOR).$(VERS_MINOR)
|
VERSION := $(VERS_MAJOR).$(VERS_MINOR)
|
||||||
NEW_MINOR := $$(( $(VERS_MINOR) + 1 ))
|
NEW_MINOR := $$(( $(VERS_MINOR) + 1 ))
|
||||||
NEW_MAJOR := $$(( $(VERS_MAJOR) + 1 ))
|
NEW_MAJOR := $$(( $(VERS_MAJOR) + 1 ))
|
||||||
|
@ -9,7 +9,15 @@ output:
|
||||||
output/sendmail: output
|
output/sendmail: output
|
||||||
go build -o output/sendmail -ldflags "-X main.version=$(VERSION)" ./...
|
go build -o output/sendmail -ldflags "-X main.version=$(VERSION)" ./...
|
||||||
|
|
||||||
build: output/sendmail
|
output/sendmail-dev: output
|
||||||
|
go build -o output/sendmail-dev ./...
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm output/*
|
||||||
|
|
||||||
|
build: clean output/sendmail
|
||||||
|
|
||||||
|
dev-build: clean output/sendmail-dev
|
||||||
|
|
||||||
bumpvers-minor:
|
bumpvers-minor:
|
||||||
sed -i"" "s/VERS_MINOR := $(VERS_MINOR)/VERS_MINOR := $(NEW_MINOR)/" Makefile
|
sed -i"" "s/VERS_MINOR := $(VERS_MINOR)/VERS_MINOR := $(NEW_MINOR)/" Makefile
|
||||||
|
@ -31,4 +39,4 @@ release-maj:
|
||||||
make bumpvers-major
|
make bumpvers-major
|
||||||
make build
|
make build
|
||||||
|
|
||||||
PHONY: bumpvers-minor bumpvers-major release-min release-maj
|
PHONY: bumpvers-minor bumpvers-major release-min release-maj clean
|
||||||
|
|
17
main.go
17
main.go
|
@ -6,12 +6,13 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var noVersion = "dev"
|
var noVersion = "dev"
|
||||||
var version string
|
var version string
|
||||||
|
|
||||||
func readFromConsole() string {
|
func readFromConsole(result chan string) {
|
||||||
var text, line string
|
var text, line string
|
||||||
var err error
|
var err error
|
||||||
counter := 0
|
counter := 0
|
||||||
|
@ -29,7 +30,8 @@ func readFromConsole() string {
|
||||||
Error.F("Error in reading text from console\n%s", err)
|
Error.F("Error in reading text from console\n%s", err)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
return strings.TrimRight(text, "\n")
|
result <- strings.TrimRight(text, "\n")
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func toList(input string) []string {
|
func toList(input string) []string {
|
||||||
|
@ -100,7 +102,16 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if flag.NArg() == 0 {
|
if flag.NArg() == 0 {
|
||||||
text = readFromConsole()
|
result := make(chan string, 1)
|
||||||
|
go readFromConsole(result)
|
||||||
|
select {
|
||||||
|
case text = <-result:
|
||||||
|
Info.Ln("text read from console")
|
||||||
|
case <-time.After(5 * time.Minute):
|
||||||
|
Error.Ln("timeout reading from console")
|
||||||
|
os.Exit(3)
|
||||||
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for _, arg := range flag.Args() {
|
for _, arg := range flag.Args() {
|
||||||
text += fmt.Sprintf("%s\n", arg)
|
text += fmt.Sprintf("%s\n", arg)
|
||||||
|
|
Loading…
Reference in a new issue