root

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const App = "dingmark"

Variables

View Source
var SendCmd = &cobra.Command{
	Use: "send",
	Args: func(cmd *cobra.Command, args []string) error {
		if len(args) != 2 {
			return errors.New("requires 2 argument, title and text")
		}
		token := viper.GetString("token")
		if token == "" {
			return fmt.Errorf("%s is blank", "token")
		}
		secret := viper.GetString("secret")
		if secret == "" {
			return fmt.Errorf("%s is blank", "secret")
		}
		if args[0] == "" || args[1] == "" {
			return fmt.Errorf("invalid args input")
		}
		return nil
	},
	Run: func(cmd *cobra.Command, args []string) {
		token := viper.GetString("token")
		secret := viper.GetString("secret")
		title := args[0]
		text := args[1]

		resp, err := services.SendMarkdown(token, secret, title, text)
		if err != nil {
			fmt.Println(err)
			return
		}
		fmt.Println("result:", resp.IsSuccess(), "code:", resp.GetCode(), "message:", resp.GetMessage())
	},
}

Functions

func NewRootCmd

func NewRootCmd(cfgFile *string) *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

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