Browse Source

Debora has a pretty list.

pull/61/head
Jae Kwon 9 years ago
parent
commit
e294b1f954
2 changed files with 21 additions and 13 deletions
  1. +19
    -13
      cmd/debora/main.go
  2. +2
    -0
      process/process.go

+ 19
- 13
cmd/debora/main.go View File

@ -32,6 +32,11 @@ func main() {
Value: "default",
Usage: "uses ~/.debora/<group>.cfg",
}
labelFlag = cli.StringFlag{
Name: "label",
Value: "_",
Usage: "label of the process, or _ by default",
}
bgFlag = cli.BoolFlag{
Name: "bg",
Usage: "if set, runs as a background daemon",
@ -68,6 +73,7 @@ func main() {
Usage: "run process",
Action: cliRunProcess,
Flags: []cli.Flag{
labelFlag,
bgFlag,
inputFlag,
},
@ -125,15 +131,14 @@ func cliGetStatus(c *cli.Context) {
func cliRunProcess(c *cli.Context) {
args := c.Args()
if len(args) < 2 {
Exit("Must specify <label> <execPath> <args...>")
if len(args) < 1 {
Exit("Must specify <execPath> <args...>")
}
label := args[0]
execPath := args[1]
args = args[2:]
execPath := args[0]
args = args[1:]
command := btypes.CommandRunProcess{
Wait: !c.Bool("bg"),
Label: label,
Label: c.String("label"),
ExecPath: execPath,
Args: args,
Input: c.String("input"),
@ -207,14 +212,15 @@ func cliListProcesses(c *cli.Context) {
} else {
fmt.Printf("%v processes:\n", Blue(remote))
for _, proc := range response.Processes {
startTimeStr := Green(proc.StartTime.String())
endTimeStr := proc.EndTime.String()
if !proc.EndTime.IsZero() {
endTimeStr = Red(endTimeStr)
fmt.Printf(" \"%v\" => `%v %v` (%v)\n", Yellow(proc.Label), proc.ExecPath, proc.Args, proc.Pid)
fmt.Printf(" started at %v", proc.StartTime.String())
if proc.EndTime.IsZero() {
fmt.Printf(", running still\n")
} else {
endTimeStr := proc.EndTime.String()
fmt.Printf(", stopped at %v\n", Yellow(endTimeStr))
}
fmt.Printf(" %v start:%v end:%v output:%v\n",
RightPadString(Fmt("\"%v\" => `%v` (%v)", Yellow(proc.Label), proc.ExecPath, proc.Pid), 40),
startTimeStr, endTimeStr, proc.OutputPath)
fmt.Printf(" stdout/stderr goes to %v\n", proc.OutputPath)
}
}
}(remote)


+ 2
- 0
process/process.go View File

@ -13,6 +13,7 @@ import (
type Process struct {
Label string
ExecPath string
Args []string
Pid int
StartTime time.Time
EndTime time.Time
@ -55,6 +56,7 @@ func Create(mode int, label string, execPath string, args []string, input string
proc := &Process{
Label: label,
ExecPath: execPath,
Args: args,
Pid: cmd.Process.Pid,
StartTime: time.Now(),
OutputPath: outPath,


Loading…
Cancel
Save