本文整理汇总了Golang中github.com/cortesi/termlog.TermLog.Stream方法的典型用法代码示例。如果您正苦于以下问题:Golang TermLog.Stream方法的具体用法?Golang TermLog.Stream怎么用?Golang TermLog.Stream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cortesi/termlog.TermLog
的用法示例。
在下文中一共展示了TermLog.Stream方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: NewDaemonPen
// NewDaemonPen creates a new DaemonPen
func NewDaemonPen(block conf.Block, vars map[string]string, log termlog.TermLog) (*DaemonPen, error) {
d := make([]*daemon, len(block.Daemons))
for i, dmn := range block.Daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
return nil, err
}
dmn.Command = finalcmd
var indir string
if block.InDir != "" {
indir = block.InDir
} else {
indir, err = os.Getwd()
if err != nil {
return nil, err
}
}
d[i] = &daemon{
conf: dmn,
log: log.Stream(niceHeader("daemon: ", dmn.Command)),
shell: vars[shellVarName],
indir: indir,
}
}
return &DaemonPen{daemons: d}, nil
}
示例2: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *watch.Mod, log termlog.TermLog) error {
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if err != nil {
return err
}
err = RunProc(cmd, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
return err
}
}
return nil
}
示例3: NewDaemonPen
// NewDaemonPen creates a new DaemonPen
func NewDaemonPen(block conf.Block, vars map[string]string, log termlog.TermLog) (*DaemonPen, error) {
d := make([]*daemon, len(block.Daemons))
for i, dmn := range block.Daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
return nil, err
}
dmn.Command = finalcmd
d[i] = &daemon{
conf: dmn,
log: log.Stream(niceHeader("daemon: ", dmn.Command)),
}
}
return &DaemonPen{daemons: d}, nil
}
示例4: Start
// Start starts set of daemons, each specified by a command
func (dp *DaemonPen) Start(daemons []conf.Daemon, vars map[string]string, log termlog.TermLog) {
dp.Lock()
defer dp.Unlock()
d := make([]daemon, len(daemons))
for i, dmn := range daemons {
d[i] = daemon{
conf: dmn,
vars: vars,
log: log.Stream(
niceHeader("daemon: ", dmn.Command),
),
}
go d[i].Run()
}
dp.daemons = &d
}
示例5: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *watch.Mod, log termlog.TermLog, notifiers []notify.Notifier) error {
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if err != nil {
return err
}
err = RunProc(cmd, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
if pe, ok := err.(ProcError); ok {
for _, n := range notifiers {
n.Push("modd error", pe.Output, "")
}
}
return err
}
}
return nil
}
示例6: Start
// Start starts set of daemons, each specified by a command
func (dp *DaemonPen) Start(daemons []conf.Daemon, vars map[string]string, log termlog.TermLog) {
dp.Lock()
defer dp.Unlock()
d := make([]daemon, len(daemons))
for i, dmn := range daemons {
vcmd := varcmd.VarCmd{Block: nil, Mod: nil, Vars: vars}
finalcmd, err := vcmd.Render(dmn.Command)
if err != nil {
log.Shout("%s", err)
continue
}
dmn.Command = finalcmd
d[i] = daemon{
conf: dmn,
log: log.Stream(
niceHeader("daemon: ", dmn.Command),
),
}
go d[i].Run()
}
dp.daemons = &d
}
示例7: RunPreps
// RunPreps runs all commands in sequence. Stops if any command returns an error.
func RunPreps(b conf.Block, vars map[string]string, mod *moddwatch.Mod, log termlog.TermLog, notifiers []notify.Notifier, initial bool) error {
shell := vars[shellVarName]
vcmd := varcmd.VarCmd{Block: &b, Mod: mod, Vars: vars}
for _, p := range b.Preps {
cmd, err := vcmd.Render(p.Command)
if initial && p.Onchange {
log.Say(niceHeader("skipping prep: ", cmd))
continue
}
if err != nil {
return err
}
err = RunProc(cmd, shell, log.Stream(niceHeader("prep: ", cmd)))
if err != nil {
if pe, ok := err.(ProcError); ok {
for _, n := range notifiers {
n.Push("modd error", pe.Output, "")
}
}
return err
}
}
return nil
}