Debora has a pretty list.
This commit is contained in:
parent
b02f088cc7
commit
e294b1f954
|
@ -32,6 +32,11 @@ func main() {
|
||||||
Value: "default",
|
Value: "default",
|
||||||
Usage: "uses ~/.debora/<group>.cfg",
|
Usage: "uses ~/.debora/<group>.cfg",
|
||||||
}
|
}
|
||||||
|
labelFlag = cli.StringFlag{
|
||||||
|
Name: "label",
|
||||||
|
Value: "_",
|
||||||
|
Usage: "label of the process, or _ by default",
|
||||||
|
}
|
||||||
bgFlag = cli.BoolFlag{
|
bgFlag = cli.BoolFlag{
|
||||||
Name: "bg",
|
Name: "bg",
|
||||||
Usage: "if set, runs as a background daemon",
|
Usage: "if set, runs as a background daemon",
|
||||||
|
@ -68,6 +73,7 @@ func main() {
|
||||||
Usage: "run process",
|
Usage: "run process",
|
||||||
Action: cliRunProcess,
|
Action: cliRunProcess,
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
|
labelFlag,
|
||||||
bgFlag,
|
bgFlag,
|
||||||
inputFlag,
|
inputFlag,
|
||||||
},
|
},
|
||||||
|
@ -125,15 +131,14 @@ func cliGetStatus(c *cli.Context) {
|
||||||
|
|
||||||
func cliRunProcess(c *cli.Context) {
|
func cliRunProcess(c *cli.Context) {
|
||||||
args := c.Args()
|
args := c.Args()
|
||||||
if len(args) < 2 {
|
if len(args) < 1 {
|
||||||
Exit("Must specify <label> <execPath> <args...>")
|
Exit("Must specify <execPath> <args...>")
|
||||||
}
|
}
|
||||||
label := args[0]
|
execPath := args[0]
|
||||||
execPath := args[1]
|
args = args[1:]
|
||||||
args = args[2:]
|
|
||||||
command := btypes.CommandRunProcess{
|
command := btypes.CommandRunProcess{
|
||||||
Wait: !c.Bool("bg"),
|
Wait: !c.Bool("bg"),
|
||||||
Label: label,
|
Label: c.String("label"),
|
||||||
ExecPath: execPath,
|
ExecPath: execPath,
|
||||||
Args: args,
|
Args: args,
|
||||||
Input: c.String("input"),
|
Input: c.String("input"),
|
||||||
|
@ -207,14 +212,15 @@ func cliListProcesses(c *cli.Context) {
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("%v processes:\n", Blue(remote))
|
fmt.Printf("%v processes:\n", Blue(remote))
|
||||||
for _, proc := range response.Processes {
|
for _, proc := range response.Processes {
|
||||||
startTimeStr := Green(proc.StartTime.String())
|
fmt.Printf(" \"%v\" => `%v %v` (%v)\n", Yellow(proc.Label), proc.ExecPath, proc.Args, proc.Pid)
|
||||||
endTimeStr := proc.EndTime.String()
|
fmt.Printf(" started at %v", proc.StartTime.String())
|
||||||
if !proc.EndTime.IsZero() {
|
if proc.EndTime.IsZero() {
|
||||||
endTimeStr = Red(endTimeStr)
|
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",
|
fmt.Printf(" stdout/stderr goes to %v\n", proc.OutputPath)
|
||||||
RightPadString(Fmt("\"%v\" => `%v` (%v)", Yellow(proc.Label), proc.ExecPath, proc.Pid), 40),
|
|
||||||
startTimeStr, endTimeStr, proc.OutputPath)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}(remote)
|
}(remote)
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
type Process struct {
|
type Process struct {
|
||||||
Label string
|
Label string
|
||||||
ExecPath string
|
ExecPath string
|
||||||
|
Args []string
|
||||||
Pid int
|
Pid int
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
EndTime time.Time
|
EndTime time.Time
|
||||||
|
@ -55,6 +56,7 @@ func Create(mode int, label string, execPath string, args []string, input string
|
||||||
proc := &Process{
|
proc := &Process{
|
||||||
Label: label,
|
Label: label,
|
||||||
ExecPath: execPath,
|
ExecPath: execPath,
|
||||||
|
Args: args,
|
||||||
Pid: cmd.Process.Pid,
|
Pid: cmd.Process.Pid,
|
||||||
StartTime: time.Now(),
|
StartTime: time.Now(),
|
||||||
OutputPath: outPath,
|
OutputPath: outPath,
|
||||||
|
|
Loading…
Reference in New Issue