Skip to content

Commit

Permalink
Reordering
Browse files Browse the repository at this point in the history
  • Loading branch information
mgumz committed Jan 27, 2018
1 parent 16cd651 commit 7f37cc5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 22 deletions.
18 changes: 18 additions & 0 deletions job_ui.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package main

import "time"

// ui-ideas
//
// * https://godoc.org/github.com/jroimartin/gocui
Expand Down Expand Up @@ -33,3 +35,19 @@ type JobUI interface {
JobDone(jobID string)
Wait() // wait for all jobs to be .Done()
}

func newUI(ui string) JobUI {
switch ui {
case "oneline":
return &UIOneLine{
pt: newProgressTicker(0),
prefix: "vopher",
duration: 25 * time.Millisecond,
}
case "simple":
return &UISimple{jobs: make(map[string]Runtime)}
case "quiet":
return &UIQuiet{}
}
return nil
}
27 changes: 5 additions & 22 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (
"log"
"os"
"strings"
"time"
)

var allowedActions = []string{
Expand Down Expand Up @@ -131,17 +130,17 @@ func main() {

if cli.action == "search" && len(flag.Args()) < 2 {
log.Fatal("error: missing arguments for 'search'")
} else if cli.action == "fetch" && len(flag.Args()) < 2 {
}
if cli.action == "fetch" && len(flag.Args()) < 2 {
log.Fatal("error: missing arguments for 'fetch'")
}

cli.ui = defaultUI(cli.ui, cli.action)
var ui JobUI = generateUI(cli.ui)

if cli.dir == "" {
log.Fatal("error: empty -dir")
}

cli.ui = defaultUI(cli.ui, cli.action)
ui := newUI(cli.ui)

path, err := expandPath(cli.dir)
if err != nil {
log.Fatalf("error: expanding %q failed while obtaining current user?? %s", cli.dir, err)
Expand Down Expand Up @@ -195,22 +194,6 @@ func defaultUI(ui, action string) string {
}
}

func generateUI(ui string) JobUI {
switch ui {
case "oneline":
return &UIOneLine{
pt: newProgressTicker(0),
prefix: "vopher",
duration: 25 * time.Millisecond,
}
case "simple":
return &UISimple{jobs: make(map[string]Runtime)}
case "quiet":
return &UIQuiet{}
}
return nil
}

func mayReadPlugins(path string, parse PluginParser, filter stringList) PluginList {
plugins := make(PluginList)
parse(plugins, path)
Expand Down

0 comments on commit 7f37cc5

Please sign in to comment.