remove

package
v0.0.20 Latest Latest
Warning

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

Go to latest
Published: May 10, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RemoveCmd = &cobra.Command{
	Use:   "remove",
	Short: "A brief description of your command",
	Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:

Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
	PreRunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return utils.ErrNoArgs
		}

		return nil
	},
	RunE: func(cmd *cobra.Command, args []string) error {
		logger := cmd.Context().Value(constants.LoggerKey{}).(zerolog.Logger)
		socketPath := cmd.Context().Value(constants.SocketPathKey{}).(string)

		logger.Info().
			Str("operation", cmd.Name()).
			Any("args", args).
			Msg(constants.ProcessCommand)

		for _, arg := range args {
			req := fmt.Sprintf("%s %s", cmd.Name(), arg)
			res, err := utils.SendCommandToDaemon(socketPath, req)
			if err != nil {
				logger.Error().
					Str("command", req).
					Err(err).
					Msg(constants.FailedToProcessCommand)

				continue
			}

			logger.Info().
				Str("command", req).
				Str("response", res).
				Msg(constants.SuccessfullyProcessed)
		}

		return nil
	},
}

RemoveCmd represents the remove command

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