Example #1
0
File: cfg.go Project: 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
}
Example #2
0
File: issues.go Project: 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
}
Example #3
0
File: cfg.go Project: skhal/gh
// CreateCfg creates an emtpy config
func CreateCfg() error {
	c := cfg.NewConfig()
	return cfg.Save(c)
}