cmd

package
v1.6.1 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Bootstrap = &cobra.Command{
	Use:   "bootstrap",
	Short: "bootstrap the client",
	Long:  "bootstrap the client.",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("not implemented for your os")
		os.Exit(1)
	},
}

Bootstrap represents the bootstrap command

View Source
var Config = &cobra.Command{
	Use:   "config",
	Short: "manage the configuration",
}

Config represents the config command

View Source
var Service = &cobra.Command{
	Use:   "service",
	Short: "administrate windows service",
}

Service represents the service command

View Source
var Update = &cobra.Command{
	Use:      "update",
	Short:    "update the executable from github",
	PreRunE:  preUpdate,
	PostRunE: postUpdate,
	Run: func(cmd *cobra.Command, args []string) {
		logger := log.New(config.ParseLogOptions()...)

		release, err := client.Release()
		if err != nil {
			logger.Error(err)
			os.Exit(1)
		}

		version, err := semver.ParseTolerant(version.Version)
		if release.Version.Equals(version) {
			logger.Errorf("current version is the latest")
			os.Exit(0)
		}

		fmt.Print("Do you want to update to ", release.Version, "? (y/n): ")
		scanner := bufio.NewScanner(os.Stdin)
		if !scanner.Scan() {
			logger.Error("failed to scan rune")
			os.Exit(1)
		}
		input := strings.ToLower(scanner.Text())
		if scanner.Err() != nil {
			logger.Errorf("failed to read input: %v", scanner.Err())
			os.Exit(1)
		}

		switch input {
		case "y":
			break
		case "n":
			os.Exit(0)
		default:
			logger.Errorf("Invalid input: %s", input)
			os.Exit(1)
		}

		if err := client.Update(release); err != nil {
			logger.Errorf("failed to update client: %v", err)
			os.Exit(1)
		}

		logger.Println("Successfully updated to version:", release.Version)

	},
}

Update represents the update command

View Source
var Version = &cobra.Command{
	Use:   "version",
	Short: "show version information",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println("Version:", version.Version)
		fmt.Println("Date:", version.Date)
		fmt.Println("Commit:", version.Commit)
	},
}

Version represents the version 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