示例#1
0
文件: cfg.go 项目: skhal/gh
// RunCfg runs authentication command
func RunCfg(args []string) error {
	if *flagCfgCreate {
		return CreateCfg()
	}
	c := cfg.NewConfig()
	if err := cfg.Load(c); err != nil {
		return err
	}
	b, err := json.MarshalIndent(c, "", "  ")
	if err != nil {
		return err
	}
	fmt.Fprintf(os.Stdout, "%s\n", b)
	return nil
}
示例#2
0
文件: issues.go 项目: skhal/gh
// RunIssues runs issues command
func RunIssues(args []string) error {
	c := cfg.NewConfig()
	if err := cfg.Load(c); err != nil {
		return err
	}
	client := issues.NewClient(c)
	issues, err := client.Load()
	if err != nil {
		return err
	}
	tmpl := template.Must(template.New("issues").Parse(tmplIssues))
	err = tmpl.Execute(os.Stdout, issues)
	if err != nil {
		return err
	}
	return nil
}
示例#3
0
文件: cfg.go 项目: skhal/gh
// CreateCfg creates an emtpy config
func CreateCfg() error {
	c := cfg.NewConfig()
	return cfg.Save(c)
}