brew test

pull/15/head 1.0.1
Miguel Mota 6 years ago
parent 4c88b56dd3
commit 362987c1d8

@ -22,6 +22,9 @@ clean:
test: test:
go test ./... go test ./...
cointop/test:
go run main.go -test
snap/clean: snap/clean:
snapcraft clean snapcraft clean

@ -3,21 +3,18 @@ class Cointop < Formula
homepage "https://cointop.sh" homepage "https://cointop.sh"
url "https://github.com/miguelmota/cointop/archive/1.0.0.tar.gz" url "https://github.com/miguelmota/cointop/archive/1.0.0.tar.gz"
sha256 "8ff6988cd18b35dbf85436add19135a587e03702b43744f563f137bb067f6e04" sha256 "8ff6988cd18b35dbf85436add19135a587e03702b43744f563f137bb067f6e04"
revision 1
head "https://github.com/miguelmota/cointop.git"
depends_on "go" => :build depends_on "go" => :build
def install def install
ENV["GOPATH"] = buildpath ENV["GOPATH"] = buildpath
mkdir "#{buildpath}/src/github.com/miguelmota/cointop" (buildpath/"src/github.com/miguelmota/cointop").install buildpath.children
path = buildpath/"src/github.com/miguelmota/cointop" cd "src/github.com/miguelmota/cointop" do
cd path do
system "git", "clone", "https://github.com/miguelmota/cointop.git", "."
system "go", "build", "-o", "#{bin}/cointop" system "go", "build", "-o", "#{bin}/cointop"
prefix.install_metafiles
end end
end end
test do test do
system "true" system "#{bin}/cointop" "-test"
end end
end end

@ -1,8 +1,6 @@
package cointop package cointop
import ( import (
"flag"
"fmt"
"log" "log"
"os" "os"
"sync" "sync"
@ -60,15 +58,11 @@ type Cointop struct {
helpvisible bool helpvisible bool
} }
// Instance running cointop instance
var Instance *Cointop
// Run runs cointop // Run runs cointop
func Run() { func Run() {
var ver bool
flag.BoolVar(&ver, "v", false, "Version")
flag.Parse()
if ver {
fmt.Println("1.0.0")
return
}
var debug bool var debug bool
if os.Getenv("DEBUG") != "" { if os.Getenv("DEBUG") != "" {
debug = true debug = true
@ -95,6 +89,7 @@ func Run() {
searchfieldviewname: "searchfield", searchfieldviewname: "searchfield",
helpviewname: "help", helpviewname: "help",
} }
Instance = &ct
err := ct.setupConfig() err := ct.setupConfig()
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
@ -140,3 +135,10 @@ func (ct *Cointop) quit() error {
func (ct *Cointop) forceQuit() error { func (ct *Cointop) forceQuit() error {
return gocui.ErrQuit return gocui.ErrQuit
} }
// Exit safely exit application
func Exit() {
if Instance != nil {
Instance.g.Close()
}
}

@ -1,9 +1,37 @@
package main package main
import ( import (
"flag"
"fmt"
"time"
"github.com/miguelmota/cointop/cointop" "github.com/miguelmota/cointop/cointop"
) )
var version = "1.0.0"
func main() { func main() {
var ver bool
flag.BoolVar(&ver, "v", false, "Version")
var test bool
flag.BoolVar(&test, "test", false, "Run test")
flag.Parse()
if ver {
fmt.Println(version)
return
}
if test {
runTest()
return
}
cointop.Run() cointop.Run()
} }
func runTest() {
go func() {
cointop.Run()
}()
time.Sleep(1 * time.Second)
cointop.Exit()
}

Loading…
Cancel
Save