Ejemplo n.º 1
0
// ListTemplates lists all the Gauge templates available in GaugeTemplatesURL
func ListTemplates() {
	templatesURL := config.GaugeTemplatesUrl()
	_, err := common.UrlExists(templatesURL)
	if err != nil {
		fmt.Printf("Gauge templates URL is not reachable: %s\n", err.Error())
		os.Exit(1)
	}
	tempDir := common.GetTempDir()
	defer util.Remove(tempDir)
	templatesPage, err := common.Download(templatesURL, tempDir)
	if err != nil {
		fmt.Printf("Error occurred while downloading templates list: %s\n", err.Error())
		os.Exit(1)
	}

	templatePageContents, err := common.ReadFileContents(templatesPage)
	if err != nil {
		fmt.Printf("Failed to read contents of file %s: %s\n", templatesPage, err.Error())
		os.Exit(1)
	}
	templates := getTemplateNames(templatePageContents)
	for _, template := range templates {
		fmt.Println(template)
	}
	fmt.Println("\nRun `gauge --init <template_name>` to create a new Gauge project.")
}
Ejemplo n.º 2
0
// ListTemplates lists all the Gauge templates available in GaugeTemplatesURL
func ListTemplates() {
	templatesURL := config.GaugeTemplatesUrl()
	_, err := common.UrlExists(templatesURL)
	if err != nil {
		logger.Fatalf("Gauge templates URL is not reachable: %s", err.Error())
	}
	tempDir := common.GetTempDir()
	defer util.Remove(tempDir)
	templatesPage, err := util.Download(templatesURL, tempDir, "", true)
	if err != nil {
		util.Remove(tempDir)
		logger.Fatalf("Error occurred while downloading templates list: %s", err.Error())
	}

	templatePageContents, err := common.ReadFileContents(templatesPage)
	if err != nil {
		util.Remove(tempDir)
		logger.Fatalf("Failed to read contents of file %s: %s", templatesPage, err.Error())
	}
	templates := getTemplateNames(templatePageContents)
	for _, template := range templates {
		logger.Info(template)
	}
	logger.Info("\nRun `gauge --init <template_name>` to create a new Gauge project.")
}
Ejemplo n.º 3
0
func getTemplateURL(templateName string) string {
	return config.GaugeTemplatesUrl() + "/" + templateName + ".zip"
}