Beispiel #1
0
// iris get static
// iris get -t static
// iris get = iris get basic
// and all are happy
func get(flags cli.Flags) error {
	// error and the end, not so idiomatic but needed here to make things easier

	if len(os.Args) >= 2 { // app name command name [and the package name]

		// set as the default value first
		t := flags.String("type") // this never empty

		// now check if actually user passed a package name without the -t/-type
		if len(os.Args) > 2 {
			v := os.Args[2]
			if !strings.HasPrefix(v, "-") {
				t = v // change the default given with the actual user-defined 'subcommand form'
			}
		}

		for k, p := range projects {
			if k == t {
				p.run()
				return nil
			}
		}
	}

	err := errInvalidManualArgs.Format(strings.Join(os.Args[1:], ","))
	app.Printf(err.Error())
	return err
}
Beispiel #2
0
func create(flags cli.Flags) (err error) {

	targetDir, err := filepath.Abs(flags.String("dir"))
	if err != nil {
		panic(err)
	}

	if !isValidInstallDir(targetDir) {
		printer.Dangerf("\nPlease make sure you are targeting a directory inside $GOPATH, type iris -h for help.")
		return
	}

	if !utils.DirectoryExists(packagesInstallDir) || !flags.Bool("offline") {
		downloadPackages()
	}

	createPackage(flags.String("type"), targetDir)
	return
}
Beispiel #3
0
func create(flags cli.Flags) (err error) {

	if !utils.DirectoryExists(packagesInstallDir) || !flags.Bool("offline") {
		downloadPackages()
	}

	targetDir := flags.String("dir")

	// remove first and last / if any
	if strings.HasPrefix(targetDir, "./") || strings.HasPrefix(targetDir, "."+utils.PathSeparator) {
		targetDir = targetDir[2:]
	}
	if targetDir[len(targetDir)-1] == '/' {
		targetDir = targetDir[0 : len(targetDir)-1]
	}
	//

	createPackage(flags.String("type"), targetDir)
	return
}
Beispiel #4
0
func create(flags cli.Flags) (err error) {

	targetDir, err := filepath.Abs(flags.String("dir"))
	if err != nil {
		panic(err)
	}

	if !isValidInstallDir(targetDir) {
		printer.Dangerf("\nPlease make sure you are targeting a directory inside $GOPATH, type iris -h for help.")
		return
	}

	if !utils.DirectoryExists(packagesInstallDir) || !flags.Bool("offline") {
		// install/update go dependencies at the same time downloading the zip from the github iris-contrib assets
		finish := make(chan bool)
		go func() {
			go func() {
				for _, source := range packagesDependencies {
					gogetCmd := utils.CommandBuilder("go", "get", source)
					if msg, err := gogetCmd.CombinedOutput(); err != nil {
						panic("Unable to go get " + source + " please make sure you're connected to the internet.\nSolution: Remove your $GOPATH/src/github.com/iris-contrib/middleware folder and re-run the iris create\nReason:\n" + string(msg))
					}
				}
				finish <- true

			}()

			downloadPackages()
			<-finish
		}()

		<-finish
		close(finish)
	}
	createPackage(flags.String("type"), targetDir)
	return
}