MCPcopy
hub / github.com/cli/cli / interactiveLicense

Function interactiveLicense

pkg/cmd/repo/create/create.go:872–893  ·  view source on GitHub ↗
(client *http.Client, hostname string, prompter iprompter)

Source from the content-addressed store, hash-verified

870}
871
872func interactiveLicense(client *http.Client, hostname string, prompter iprompter) (string, error) {
873 confirmed, err := prompter.Confirm("Would you like to add a license?", false)
874 if err != nil {
875 return "", err
876 } else if !confirmed {
877 return "", nil
878 }
879
880 licenses, err := api.RepoLicenses(client, hostname)
881 if err != nil {
882 return "", err
883 }
884 licenseNames := make([]string, 0, len(licenses))
885 for _, license := range licenses {
886 licenseNames = append(licenseNames, license.Name)
887 }
888 selected, err := prompter.Select("Choose a license", "", licenseNames)
889 if err != nil {
890 return "", err
891 }
892 return licenses[selected].Key, nil
893}
894
895// name, description, and visibility
896func interactiveRepoInfo(client *http.Client, hostname string, prompter iprompter, defaultName string) (string, string, string, error) {

Callers 1

createFromScratchFunction · 0.85

Calls 3

RepoLicensesFunction · 0.92
ConfirmMethod · 0.65
SelectMethod · 0.65

Tested by

no test coverage detected