profile

package
v0.7.1-beta Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2026 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AddProfileCmd = &cobra.Command{
	Use:   "add filepath",
	Short: "Add profile(s) from YAML or JSON file",
	Args:  cobra.ExactArgs(1),
	Run: func(cmd *cobra.Command, args []string) {
		code := runAddProfile(args[0])
		if code != 0 {
			osExit(code)
		}
	},
}
View Source
var Command = &cobra.Command{
	Use:     "profile",
	Aliases: []string{"p"},
	Short:   "Manage raid profiles",
	Args:    cobra.RangeArgs(0, 1),
	Run: func(cmd *cobra.Command, args []string) {
		if len(args) == 0 {
			profile := pro.Get()
			if !profile.IsZero() {
				fmt.Println(profile.Name)
			} else {
				fmt.Println("No active profile found. Use 'raid profile use <profile>' to set one.")
			}
		} else if len(args) == 1 {
			name := args[0]
			err := raid.WithMutationLock(func() error {
				return pro.Set(name)
			})
			if err != nil {
				fmt.Printf("Profile '%s' not found. Use 'raid profile list' to see available profiles.\n", name)
				os.Exit(1)
			}
			fmt.Printf("Profile '%s' is now active.\n", name)
		} else {
			cmd.PrintErrln("Invalid number of arguments.")
		}
	},
}
View Source
var CreateProfileCmd = &cobra.Command{
	Use:   "create",
	Short: "Interactively create a new profile",
	Args:  cobra.NoArgs,
	Run:   runCreateWizard,
}

CreateProfileCmd is the interactive wizard for creating a new profile.

View Source
var ListProfileCmd = &cobra.Command{
	Use:   "list",
	Short: "List profiles",
	Run: func(cmd *cobra.Command, args []string) {
		profiles := pro.ListAll()
		activeProfile := pro.Get()

		if len(profiles) == 0 {
			fmt.Println("No profiles found.")
			return
		}

		fmt.Println("Available profiles:")
		for _, profile := range profiles {
			activeIndicator := ""
			if profile.Name == activeProfile.Name {
				activeIndicator = " (active)"
			}
			fmt.Printf("\t%s%s\t%s\n", profile.Name, activeIndicator, profile.Path)
		}
	},
}
View Source
var RemoveProfileCmd = &cobra.Command{
	Use:        "remove profile",
	Short:      "Remove profile(s)",
	SuggestFor: []string{"delete"},
	Args:       cobra.MinimumNArgs(1),

	RunE: func(cmd *cobra.Command, args []string) error {
		return raid.WithMutationLock(func() error {
			for _, name := range args {
				if err := pro.Remove(name); err != nil {
					fmt.Printf("Profile '%s' not found. Use 'raid profile list' to see available profiles.\n", name)
				} else {
					fmt.Printf("Profile '%s' has been removed.\n", name)
				}
			}
			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