Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddProfileCmd = &cobra.Command{ Use: "add <path|url>", Short: "Add profile(s) from a local file or URL", Long: `Add one or more profiles from a local file, a git repository URL, or a raw file URL. Local path: the file is validated and registered directly. A repo config (raid.yaml) is also accepted and registered as a single-repo profile named after the raid.yaml's ` + "`name`" + ` field — handy for projects that ship only a raid.yaml without a wrapping profile. Git URL (git@ prefix, .git suffix, or any HTTP URL that responds to git ls-remote): raid shallow-clones the repo and imports *.raid.yaml, *.raid.yml, and profile.json files found at the root. Raw file URL (HTTP/HTTPS URL ending in .yaml, .yml, or .json): the file is downloaded, validated, and registered. Profiles from URLs are saved to ~/<name>.raid.yaml before registration.`, 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", RunE: func(cmd *cobra.Command, args []string) error { profiles := pro.ListAll() activeProfile := pro.Get() if listJSON { out := make([]profileEntry, 0, len(profiles)) for _, p := range profiles { out = append(out, profileEntry{ Name: p.Name, Path: p.Path, Active: p.Name == activeProfile.Name, }) } enc := json.NewEncoder(cmd.OutOrStdout()) enc.SetIndent("", " ") return enc.Encode(out) } if len(profiles) == 0 { fmt.Fprintln(cmd.OutOrStdout(), "No profiles found.") return nil } fmt.Fprintln(cmd.OutOrStdout(), "Available profiles:") for _, profile := range profiles { activeIndicator := "" if profile.Name == activeProfile.Name { activeIndicator = " (active)" } fmt.Fprintf(cmd.OutOrStdout(), "\t%s%s\t%s\n", profile.Name, activeIndicator, profile.Path) } return nil }, }
View Source
var RemoveProfileCmd = &cobra.Command{ Use: "remove <name>", 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.
Click to show internal directories.
Click to hide internal directories.