本文整理汇总了Golang中github.com/codegangsta/cli.Context.Output方法的典型用法代码示例。如果您正苦于以下问题:Golang Context.Output方法的具体用法?Golang Context.Output怎么用?Golang Context.Output使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/codegangsta/cli.Context
的用法示例。
在下文中一共展示了Context.Output方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: addFileToLibrary
func addFileToLibrary(c *cli.Context, r library.Registrar, file string, name string) error {
var entry *library.Entry
if strings.HasSuffix(file, ".fbp") {
// adding a compsite component (subgraph) in .fbp format
data, err := ioutil.ReadFile(file)
if err != nil {
return err
}
g, err := graph.ParseFBP(data)
if err != nil {
return err
}
if entry, err = graphToEntry(g, file, r); err != nil {
return err
}
entry.Elementary = false
} else if strings.HasSuffix(file, ".json") {
// adding a compsite component (subgraph) in .json format
data, err := ioutil.ReadFile(file)
if err != nil {
return err
}
g, err := graph.ParseJSON(data)
if err != nil {
return err
}
if entry, err = graphToEntry(g, file, r); err != nil {
return err
}
entry.Elementary = false
} else {
// adding an elementary component
c := exec.Command(file, "--json")
out, err := c.Output()
if err != nil {
return fmt.Errorf("Cannot register component %s: %s\n", name, err.Error())
}
if err = json.Unmarshal(out, &entry); err != nil {
return err
}
entry.Elementary = true
}
if len(entry.Inports) == 0 && len(entry.Outports) == 0 {
return fmt.Errorf("Cannot register component %s: inports and outports are empty", name)
}
entry.Name = name
entry.Executable = file
if r.Exists(name) && !c.Bool("force") {
fmt.Printf("WARNING \"%s\" already exists and --force is not provided. Ignoring this entry", name)
fmt.Println("")
} else {
r.Add(*entry)
fmt.Printf("Added \"%s\"", name)
fmt.Println("")
}
return nil
}