summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
authorHorus32015-08-01 23:24:02 +0200
committerHorus32015-08-01 23:24:02 +0200
commitf80efe5616ba247a1fff074b0876631a9bfb6f96 (patch)
tree3a92b8b3fbccc32d3016029d0f47b061788656da /cli
parentdb550a0edb5f21220151530f91056c4acbcc87b7 (diff)
downloadmandible-f80efe5616ba247a1fff074b0876631a9bfb6f96.tar.gz
Merges the production setup.
Diffstat (limited to 'cli')
-rw-r--r--cli/imgup/main.go67
1 files changed, 24 insertions, 43 deletions
diff --git a/cli/imgup/main.go b/cli/imgup/main.go
index a1f67e3..30e99b3 100644
--- a/cli/imgup/main.go
+++ b/cli/imgup/main.go
@@ -11,58 +11,33 @@ import (
//var apiHost = "http://127.0.0.1:8080"
var apiHost = "https://images.iamfabulous.de"
var apiUrl = apiHost + "/api/v1/"
-var updateUrl = "https://bin.iamfabulous.de/imgup/linux-x86_64/imgup"
func main() {
if len(os.Args) == 1 {
printHelp()
+
}
for k, v := range os.Args {
+ if v == "-h" || v == "--help" || v == "help" {
+ printHelp()
+ }
if k > 0 {
- if v == "--update" {
- doUpdate(updateUrl)
- continue
- }
- if v == "--help" || v == "-h" {
- printHelp()
- continue
- }
if stat, err := os.Stat(v); err != nil {
- if isUrl(v) {
- fmt.Println("Fetching image from " + v)
- fmt.Print("\n")
- err := urlUpload(apiUrl+"url", v, v)
- if err != nil {
- fmt.Println("There is an error. Are you sure the url is correct?")
- fmt.Printf("\n")
- fmt.Println("Technical information: ")
- fmt.Println(" "+err.Error(), "\n")
- }
- } else {
- fmt.Println("There is an error!")
- fmt.Print("\n")
- fmt.Println(v + " is not an url.")
- fmt.Println("Upload cancelled.\n")
- continue
+ err := urlUpload(apiUrl+"url", v, v)
+ if err != nil {
+ fmt.Println("There is an error. Are you sure the url is correct?")
+ fmt.Printf("\n")
+ fmt.Println("Technical information: ")
+ fmt.Println(" "+err.Error(), "\n")
}
} else {
- if isImage(v) {
- fmt.Println("Starting to upload " + stat.Name() + "...")
- fmt.Print("\n")
- err = fileUpload(apiUrl+"file", v, stat.Name())
- if err != nil {
- fmt.Println("There is an error. Are you sure the url is correct?")
- fmt.Printf("\n")
- fmt.Println("Technical information: ")
- fmt.Println(" "+err.Error(), "\n")
- }
- } else {
- fmt.Println("There is an error!")
- fmt.Print("\n")
- fmt.Println(v + " is not an image file.")
- fmt.Println("Upload cancelled.\n")
- continue
+ err := fileUpload(apiUrl+"file", v, stat.Name())
+ if err != nil {
+ fmt.Println("There is an error. Are you sure the url is correct?")
+ fmt.Printf("\n")
+ fmt.Println("Technical information: ")
+ fmt.Println(" "+err.Error(), "\n")
}
}
}
@@ -91,9 +66,15 @@ func printHelp() {
programName := pstat.Name()
fmt.Println("Usage: " + os.Args[0] + " [FILE] [URL]")
- fmt.Println(" " + os.Args[0] + " --update updates " + programName + " to newest version.")
fmt.Print("\n")
fmt.Println(programName + " uploads an image to " + apiHost + ".")
- //fmt.Println("FILE should be a path to a image file.")
os.Exit(0)
+ /*
+ fmt.Println("Usage: " + os.Args[0] + " [FILE] [URL]")
+ fmt.Println(" " + os.Args[0] + " --update updates " + programName + " to newest version.")
+ fmt.Print("\n")
+ fmt.Println(programName + " uploads an image to " + apiHost + ".")
+ //fmt.Println("FILE should be a path to a image file.")
+ os.Exit(0)
+ */
}