Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "Add file or folder to server", Long: `Add file or folder to server`, Run: func(cmd *cobra.Command, args []string) { absFileNamePath, _ := filepath.Abs(fileNameParam) resp, _ := http.PostForm("http://localhost:7890/add", url.Values{"path": {absFileNamePath}}) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) res := api.AddResponse{} json.Unmarshal([]byte(body), &res) if res.Status { if len(res.ListIps) == 1 { copyClipboard(res.ListIps[0]) return } fmt.Println("Choose option to copy:") for i := 0; i < len(res.ListIps); i++ { fmt.Printf("%v) %s\n", i, res.ListIps[i]) } var option int fmt.Scanf("%d", &option) copyClipboard(res.ListIps[option]) } else { fmt.Printf("Error: %s\n", res.ErrorMessage) } }, }
View Source
var PsCmd = &cobra.Command{ Use: "ps", Short: "List files or folders from server", Long: `List files or folders from server`, Run: func(cmd *cobra.Command, args []string) { resp, _ := http.Get("http://localhost:7890/ps") defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) res := []lib.Server{} json.Unmarshal([]byte(body), &res) lines := []string{ "ID | Folder | List Ips", } for i := 0; i < len(res); i++ { line := fmt.Sprintf("%v|%s|%v", res[i].ID, res[i].Path, res[i].ListIps) lines = append(lines, line) } result := columnize.SimpleFormat(lines) fmt.Println(result) }, }
View Source
var RmCmd = &cobra.Command{ Use: "rm", Short: "Remove file or folder from server", Long: `Remove file or folder from server`, Run: func(cmd *cobra.Command, args []string) { if removeServerID > 0 { url := fmt.Sprintf("http://localhost:7890/rm/%v", removeServerID) resp, _ := http.Get(url) defer resp.Body.Close() body, _ := ioutil.ReadAll(resp.Body) res := api.RmResponse{} json.Unmarshal([]byte(body), &res) if res.Status { fmt.Printf("Ok removed server with id = %v\n", removeServerID) } else { fmt.Printf("Error: %s\n", res.ErrorMessage) } } }, }
View Source
var RootCmd = &cobra.Command{ Use: "share", Short: "Share is a cli to share quickly a file with http protocol", Long: `Share is a cli to share quickly a file with http protocol with go. Complete documentation is available at https://github.com/devcows/share`, Run: func(cmd *cobra.Command, args []string) { fmt.Println("TODO use add, ps or rm") }, }
View Source
var ServerCmd = &cobra.Command{ Use: "server", Short: "Server APIREST", Long: `Server APIREST`, Run: func(cmd *cobra.Command, args []string) { var err error if err = lib.InitSettings(lib.ConfigFile(), &settings); err != nil { fmt.Println(err) os.Exit(-1) } if err = lib.InitDB(settings); err != nil { fmt.Println(err) os.Exit(-1) } overwriteSettings() mainServer() }, }
Functions ¶
This section is empty.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.