commands

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2021 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DeleteCmd = &cobra.Command{
	Use:   "delete <delete hash>",
	Short: "Delete image from Imgur by Delete Hash",
	Args:  cobra.MinimumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client := utils.CreateClient()

		_, _, err := client.DeleteImageUnAuthed(args[0])
		if err != nil {
			log.Fatal("Error delete image: " + err.Error())
		}

		return nil
	},
}
View Source
var UploadCmd = &cobra.Command{
	Use:   "upload <path to file or url>",
	Short: "Upload image to Imgur",
	Args:  cobra.MinimumNArgs(1),
	RunE: func(cmd *cobra.Command, args []string) error {
		client := utils.CreateClient()

		f, err := os.Stat(args[0])

		if err == nil {
			if f.IsDir() {
				log.Fatalf("%s is dir", args[0])
			}

			data, _, err := client.UploadImageFromFile(args[0], "")
			if err != nil {
				log.Fatal(err)
			}

			printLink(data)
		} else {
			data, _, err := client.UploadImageFromURL(args[0], "")
			if err != nil {
				log.Fatal(err)
			}

			printLink(data)
		}

		return nil
	},
}

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL