func listFiles(cmd *cobra.Command, args []string) { url := core.UrlHandler(ToadHost, ToadPort, "/listfiles", "") resp, err := http.Get(url) if err != nil { common.IfExit(err) } defer resp.Body.Close() b, err := ioutil.ReadAll(resp.Body) if err != nil { common.IfExit(err) } log.Warn(string(b)) }
func putFiles(cmd *cobra.Command, args []string) { fileName := args[0] file, err := os.Open(fileName) defer file.Close() if err != nil { common.IfExit(err) } url := core.UrlHandler(ToadHost, ToadPort, "/postfile?fileName=", fileName) _, err = http.Post(url, "", file) if err != nil { common.IfExit(err) } log.Warn("success. file added to toadserver") }
func getFiles(cmd *cobra.Command, args []string) { fileName := args[0] url := core.UrlHandler(ToadHost, ToadPort, "/getfile?fileName=", fileName) resp, err := http.Get(url) if err != nil { common.IfExit(err) } defer resp.Body.Close() body, err := ioutil.ReadAll(resp.Body) if err != nil { common.IfExit(err) } if err := ioutil.WriteFile(fileName, body, 0777); err != nil { common.IfExit(err) } }
//---------------------------------------------------- func RunPackage(cmd *cobra.Command, args []string) { common.IfExit(packages.RunPackage(do)) }
} else if do.Debug { log.SetLevel(log.DebugLevel) } // clears epm.log file util.ClearJobResults() // Welcomer.... log.Info("Hello! I'm EPM.") // Fixes path issues and controls for mint-client / eris-keys assumptions // util.BundleHttpPathCorrect(do) util.PrintPathPackage(do) // Populates chainID from the chain (if its not passed) common.IfExit(util.GetChainID(do)) }, Run: RunPackage, PersistentPostRun: func(cmd *cobra.Command, args []string) { // Ensure that errors get written to screen and generally flush the log // log.Flush() }, } func Execute() { InitEPM() AddGlobalFlags() EPMCmd.Execute() }