Ejemplo n.º 1
0
// showConfig outputs the current running configuration
func (s *Show) showConfig() {
	fmt.Print("\naion config:\n")
	w := utils.NewTabWriter()

	v := reflect.ValueOf(*s.config)

	fmt.Fprint(w, "\n")

	// iterate through the values of the struct and write to the tabwriter
	for i := 0; i < v.NumField(); i++ {
		fmt.Fprintf(w, "%s\t%v\n", v.Type().Field(i).Name, v.Field(i).Interface())
	}

	fmt.Fprintf(w, "\n")
	w.Flush()
}
Ejemplo n.º 2
0
// AllJobs gets all job entries
func (s *Show) AllJobs() {
	response, err := http.Get("http://" + s.config.Endpoint + "/api/v1/job")
	if err != nil {
		fmt.Println(err)
	}
	defer response.Body.Close()

	var r JobsResponse
	if err := json.NewDecoder(response.Body).Decode(&r); err != nil {
		fmt.Println(err)
	}

	w := utils.NewTabWriter()

	fmt.Fprintf(w, "\nName\tDescription\tTasks")
	fmt.Fprintf(w, "\n----------\t----------\t----------\n")

	for _, i := range r.Jobs {
		fmt.Fprintf(w, "%s\t%s\t%s\n", i.Name, i.Desc, i.Tasks)
	}

	fmt.Fprintf(w, "\n")
	w.Flush()
}