MCPcopy Create free account
hub / github.com/cli/cli / interactiveLicense

Function interactiveLicense

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

Source from the content-addressed store, hash-verified

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