示例#1
0
func main() {
	nflag.Parse() // Parse nflag

	OriginalLanguage = frala.Config.DefaultLanguage                     // Set OriginalLanguage before doing any parsing or conversion
	frala.Config.DefaultLanguage, _ = nflag.GetAsString("lang")         // Change DefaultLanguage to whatever may be set as lang. This may not change if no value is passed to lang
	frala.Config.Direction = frala.GetDirection(frala.Config.Direction) // Ensure we have an accurate Direction

	parseFiles, parseFilesErr := nflag.GetAsString("parse")
	poFile, poFileErr := nflag.GetAsString("po")

	TargetDirectory, _ = nflag.GetAsString("target-dir")
	TargetDirectory += "/" // Ensure / is appending to end of path

	if (parseFilesErr == nil) && (parseFiles != "") { // If we are parsing files
		ParseFiles(parseFiles) // Call ParseFiles
	} else if (poFileErr == nil) && (poFile != "") { // If we are doing Po conversion
		convertTermsVal, convertTermsGetErr := nflag.GetAsBool("convert-terms") // Get the boolean value of convert-terms

		if convertTermsGetErr != nil { // If there was an error getting convertTermsVal
			convertTermsVal = false // Don't convert from Terms to Po
		}

		PoConversion(convertTermsVal, poFile) // Do Po conversion
	} else { // If we are neither parsing nor doing Po conversion
		nflag.PrintFlags() // Print the nflag flags
	}
}
示例#2
0
func main() {
	nflag.Parse()                                                        // Parse nflag
	projectBootstrap, _ := nflag.GetAsString("bootstrap")                // Get any bootstrap string passed
	getDependencies, _ := nflag.GetAsBool("get-dependencies")            // Should we get dependencies of an existing project
	getTypeDependencies, _ := nflag.GetAsString("get-type-dependencies") // Get dependencies of a particular type
	installDependencies, _ := nflag.GetAsBool("install-dependencies")    // Should we install dependencies of an existing project

	if projectBootstrap != "" { // If we are bootstrapping a new project
		BootstrapProject(projectBootstrap) // Call BootstrapProject with the project name
	} else if getDependencies || installDependencies { // If we are getting or installing the dependencies of an existing project
		projectConfigContent, projectConfigReadError := ioutil.ReadFile("build/config.json") // Read the build/config.json file if it exists

		if projectConfigReadError == nil { // If there was no read error
			var projectConfig codeutilsShared.ProjectConfig                     // Define projectConfig as a ProjectConfig
			decodeError := json.Unmarshal(projectConfigContent, &projectConfig) // Decode / unmarshal projectConfigContent as &ProjectConfig

			if decodeError == nil { // If there was no decode error
				if getDependencies { // If we are getting the dependencies of a project
					PrintDependencies(projectConfig) // Print the dependencies of the project
				} else { // If we are installing the dependencies of a project
					InstallProjectDependencies(projectConfig) // Attempt installation of the project's dependencies
				}
			} else { // If there was a decode error
				fmt.Println("There was an error decoding the config.json file.")
			}
		} else { // If there is no config.json file
			fmt.Println("No config.json file exists in the build folder.")
		}
	} else if getTypeDependencies != "" { // If we are getting dependencies from a specific type
		dependencyMap, dependencyExists := DependenciesMap[getTypeDependencies] // Get the dependencyMap of the getTypeDependencies if it exists in DependenciesMap

		if dependencyExists { // If the dependencyExists
			fmt.Println("Dependencies: ", strings.Join(dependencyMap.Dependencies, ", "))
			fmt.Println("Packager: " + dependencyMap.Packager)
		} else { // If this type does not exist
			fmt.Println("Type \"" + getTypeDependencies + "\" is not a valid dependency type.")
		}
	} else {
		nflag.PrintFlags() // Print nflag flags
	}
}