本文整理汇总了Golang中github.com/juju/cmd.Command.Run方法的典型用法代码示例。如果您正苦于以下问题:Golang Command.Run方法的具体用法?Golang Command.Run怎么用?Golang Command.Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/cmd.Command
的用法示例。
在下文中一共展示了Command.Run方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: RunCommandInDir
// RunCommandInDir works like RunCommand, but runs with a context that uses dir.
func RunCommandInDir(c *gc.C, com cmd.Command, args []string, dir string) (*cmd.Context, error) {
if err := InitCommand(com, args); err != nil {
return nil, err
}
var context = ContextForDir(c, dir)
return context, com.Run(context)
}
示例2: RunCommand
// RunCommand runs a command with the specified args. The returned error
// may come from either the parsing of the args, the command initialisation, or
// the actual running of the command. Access to the resulting output streams
// is provided through the returned context instance.
func RunCommand(c *gc.C, com cmd.Command, args ...string) (*cmd.Context, error) {
if err := InitCommand(com, args); err != nil {
return nil, err
}
var context = Context(c)
return context, com.Run(context)
}
示例3: RunCommand
// RunCommand runs the command and returns channels holding the
// command's operations and errors.
func RunCommand(ctx *cmd.Context, com cmd.Command, args ...string) (opc chan dummy.Operation, errc chan error) {
if ctx == nil {
panic("ctx == nil")
}
errc = make(chan error, 1)
opc = make(chan dummy.Operation, 200)
dummy.Listen(opc)
go func() {
defer func() {
// signal that we're done with this ops channel.
dummy.Listen(nil)
// now that dummy is no longer going to send ops on
// this channel, close it to signal to test cases
// that we are done.
close(opc)
}()
if err := coretesting.InitCommand(com, args); err != nil {
errc <- err
return
}
errc <- com.Run(ctx)
}()
return
}
示例4: RunCommand
// RunCommand runs a command with the specified args. The returned error
// may come from either the parsing of the args, the command initialisation, or
// the actual running of the command. Access to the resulting output streams
// is provided through the returned context instance.
func RunCommand(c *gc.C, com cmd.Command, args ...string) (*cmd.Context, error) {
var context = Context(c)
if err := InitCommand(com, args); err != nil {
if err != nil {
fmt.Fprintf(context.Stderr, "error: %v\n", err)
}
return context, err
}
return context, com.Run(context)
}
示例5: runCommand
func runCommand(ctx *cmd.Context, com cmd.Command, args ...string) (opc chan dummy.Operation, errc chan error) {
if ctx == nil {
panic("ctx == nil")
}
errc = make(chan error, 1)
opc = make(chan dummy.Operation, 200)
dummy.Listen(opc)
go func() {
// signal that we're done with this ops channel.
defer dummy.Listen(nil)
err := coretesting.InitCommand(com, args)
if err != nil {
errc <- err
return
}
err = com.Run(ctx)
errc <- err
}()
return
}