readHubCLIConfig finds and deserialized the config file for Github's "hub" CLI (https://hub.github.com/).
()
| 36 | // readHubCLIConfig finds and deserialized the config file for |
| 37 | // Github's "hub" CLI (https://hub.github.com/). |
| 38 | func readHubCLIConfig() (hubCLIConfig, error) { |
| 39 | homeDir, err := os.UserHomeDir() |
| 40 | if err != nil { |
| 41 | return nil, fmt.Errorf("failed to get user home directory: %w", err) |
| 42 | } |
| 43 | |
| 44 | f, err := os.Open(path.Join(homeDir, ".config", "hub")) |
| 45 | if err != nil { |
| 46 | return nil, fmt.Errorf("failed to open hub config file: %w", err) |
| 47 | } |
| 48 | |
| 49 | var cfg hubCLIConfig |
| 50 | if err := yaml.NewDecoder(f).Decode(&cfg); err != nil { |
| 51 | return nil, fmt.Errorf("failed to parse hub config file: %w", err) |
| 52 | } |
| 53 | |
| 54 | return cfg, nil |
| 55 | } |
| 56 | |
| 57 | // gh cli config (https://cli.github.com) |
| 58 | type ghCLIConfig map[string]struct { |