コード例 #1
0
ファイル: index.go プロジェクト: kadel/grasshopper
func printIndexInfo(args []string) error {
	if len(args) < 1 {
		// FIXME		cmd.Usage()
		jww.FATAL.Println("APPNAME is required")
		return fmt.Errorf("APPNAME is required")
	}

	nuleculeLibraryIndexZip, err := getNuleculeLibraryIndexfromGithubAsZIP()
	if err != nil {
		jww.FATAL.Println(err)
		return err
	}

	// set up a new tabwriter
	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 26, 8, 2, '\t', 0)

	// and print some output to the tabwriter
	fmt.Fprintln(w, "This is the Nulecule Library Index")
	fmt.Fprintln(w, "Application Name\tAppID\tVersion")

	// iterate through the files in the archive
	for _, item := range nuleculeLibraryIndexZip.File {
		if item.FileInfo().IsDir() {
			continue
		}

		// if the file is a Nulecule, get it!
		if item.FileInfo().Name() == "Nulecule" {
			jww.DEBUG.Printf("Found a Nulecule, size of it's description is %d\n", item.FileInfo().Size())

			rc, err := item.Open()
			if err != nil {
				jww.FATAL.Println(err)
				return err
			}
			defer rc.Close()

			// get the Nulecules content
			nuci, parseError := nulecule.Parse(rc)

			if parseError != nil { // TODO this is a multierror thingy
				jww.INFO.Println(parseError, " This may be due to unsupported (by Grasshopper) artifact inheritance.")
				continue
			}

			// FIXME this needs to ignore case etc.
			if (nuci.Metadata.Name == args[0]) || (nuci.AppID == args[0]) {
				fmt.Fprintf(w, "%s\t%s\t%s\n", nuci.Metadata.Name, nuci.AppID, nuci.Metadata.AppVersion)

			}
		}

		w.Flush()
	}

	return nil
}
コード例 #2
0
ファイル: index.go プロジェクト: navidshaikh/grasshopper
func printIndexList(cmd *cobra.Command, args []string) {
	InitializeConfig()

	if Verbose {
		jww.SetLogThreshold(jww.LevelTrace)
		jww.SetStdoutThreshold(jww.LevelInfo)
	}

	nuleculeLibraryIndexZip, err := getNuleculeLibraryIndexfromGithubAsZIP()
	if err != nil {
		jww.FATAL.Println(err)
		return
	}

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 26, 8, 2, '\t', 0)

	fmt.Fprintln(w, "This is the Nulecule Library Index")
	fmt.Fprintln(w, "Application Name\tAppID\tVersion")

	// Iterate through the files in the archive
	for _, item := range nuleculeLibraryIndexZip.File {
		if item.FileInfo().IsDir() {
			continue
		}

		// if the file is a Nulecule, getit!
		if item.FileInfo().Name() == "Nulecule" {
			jww.DEBUG.Printf("Found a Nulecule, size of it's description is %d\n", item.FileInfo().Size())

			rc, err := item.Open()
			if err != nil {
				jww.FATAL.Println(err)
				return
			}
			defer rc.Close()

			// get the Nulecules content
			nuci, parseError := nulecule.Parse(rc)

			if parseError != nil {
				jww.INFO.Println(parseError, " This may be due to unsupported (by Grasshopper) artifact inheritance.")
				continue
			}

			fmt.Fprintf(w, "%s\t%s\t%s\n", nuci.Metadata.Name, nuci.AppID, nuci.Metadata.AppVersion)
		}

		w.Flush()
	}
}
コード例 #3
0
ファイル: index.go プロジェクト: navidshaikh/grasshopper
				continue
			}

			// if the file is a Nulecule, getit!
			if item.FileInfo().Name() == "Nulecule" {
				jww.DEBUG.Printf("Found a Nulecule, size of it's description is %d\n", item.FileInfo().Size())

				rc, err := item.Open()
				if err != nil {
					jww.FATAL.Println(err)
					return
				}
				defer rc.Close()

				// get the Nulecules content
				nuci, parseError := nulecule.Parse(rc)

				if parseError != nil {
					jww.INFO.Println(parseError, " This may be due to unsupported (by Grasshopper) artifact inheritance.")
					continue
				}

				// FIXME this needs to ignore case etc.
				if (nuci.Metadata.Name == args[0]) || (nuci.AppID == args[0]) {
					fmt.Fprintf(w, "%s\t%s\t%s\n", nuci.Metadata.Name, nuci.AppID, nuci.Metadata.AppVersion)

				}
			}

			w.Flush()
		}