Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var AddCmd = &cobra.Command{ Use: "add", Short: "add a package repository", Long: ` The "config add" subcommand allows you to add a package repository. `, RunE: func(cmd *cobra.Command, args []string) error { cfg, err := config.Load() if err != nil { return err } var repo PkgRepo qs := []*survey.Question{ { Name: "name", Prompt: &survey.Input{ Message: "Repository name", }, Validate: survey.Required, }, { Name: "type", Prompt: &survey.Select{ Message: "Repository type", Options: []string{"gitea", "github"}, }, Validate: survey.Required, }, { Name: "user", Prompt: &survey.Input{ Message: "Git user name", }, Validate: survey.Required, }, { Name: "repo", Prompt: &survey.Input{ Message: "Git repository name", }, Validate: survey.Required, }, { Name: "branch", Prompt: &survey.Input{ Message: "Git branch name", Default: "main", }, }, } if err := survey.Ask(qs, &repo); err != nil { return err } if repo.Type == config.PkgRepoTypeGitea { q := &survey.Input{ Message: "Gitea URL", } if err := survey.AskOne(q, &repo.GiteaURL, survey.WithValidator(survey.Required)); err != nil { return err } } p := config.PkgRepo(repo) ok, err := p.Validate() if err != nil { return err } if !ok { return fmt.Errorf("%q is an invalid package repository; no `pkgs` sub-directory", p.Name) } if err := p.RefreshRecipes(); err != nil { return err } cfg.PkgRepos = append(cfg.PkgRepos, &p) if err := cfg.Save(); err != nil { return err } color.HiGreen("Repository %q successfully added", repo.Name) return nil }, }
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.