I went through the code base and determined the following to reorder so that this tool is platform independent.
Users must perform the following combination, as you mentioned
mzr convert toJSON path/to/yaml/
path / to / yaml must be OS independent and must be an absolute / relative path to the file. For this you can do the following function conversion. And remove the dependency github.com/mitchellh/go-homedir from convert.go
func convert(args []string) { //read file // TODO: handle number of arguments and output proper messages. yamlFile, err := ioutil.ReadFile(args[0]) if err != nil { log.Printf("yamlFile.Get err #%v ", err) } //Format the yaml to json fmt.Println("Start converting: " + strings.Join(args, " ")) jsonOut, err := YAML.YAMLToJSON(yamlFile) // TODO: handle error fmt.Println(string(jsonOut)) err = ioutil.WriteFile("jsonFile.json", jsonOut, 0644) // TODO: handle error }
There are two ways to use this tool.
Modify the main.go file (in git diff format).
package main -import "mzr/cmd/commands" +import "github.com/NinaWatcher/mzr/cmd/commands"
After that, users can install this tool with the following smilar command, how godep works
go get github.com/NinaWatcher/mzr
Users who do not have golang are installed.
Create custom OS distributions that you make with the make.sh file
Hope this solves the problem of distributing your tool. However, on the side of the note, there are many that can be improved in the code base, especially when handling errors, package hierarchies, etc. Delete them before distributing them to users.
Anuruddha
source share