Documentation
¶
Overview ¶
Copyright © 2024 Kirill Chernetsky <foxsoft2005@gmail.com>
Copyright © 2024 Kirill Chernetsky <foxsoft2005@gmail.com>
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var InitCmd = &cobra.Command{ Use: "init", Short: "initialize the application", Long: `Use this command to create / check the app configuration. The config file will be automatically created if not found.`, Run: func(cmd *cobra.Command, args []string) { log.Printf("Config file is %s", viper.ConfigFileUsed()) log.Printf("Token: %s", viper.GetString("token")) log.Printf("Organization id: %d", viper.GetInt("orgId")) }, }
View Source
var UpdateCmd = &cobra.Command{ Use: "update", Short: "updates y360c app", Long: `Use this command to update y360c application to the actual version.`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("checking the latest version...") wd, _ := os.Getwd() filename := fmt.Sprintf("y360c-%s-x64.zip", strings.ToLower(runtime.GOOS)) url := fmt.Sprintf("https://github.com/foxsoft2005/y360c/releases/latest/download/%s", filename) req, _ := http.NewRequest("GET", url, nil) resp, err := http.DefaultClient.Do(req) if err != nil { log.Fatalln("unable to get update:", err) } defer resp.Body.Close() f, _ := os.OpenFile(filepath.Join(wd, filename), os.O_CREATE|os.O_WRONLY, 0644) defer f.Close() bar := progressbar.DefaultBytes( resp.ContentLength, "downloading", ) io.Copy(io.MultiWriter(f, bar), resp.Body) fmt.Printf("update downloaded to %v, extract it manually", filepath.Join(wd, filename)) }, }
updateCmd represents the update command
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.