Skip to content

Commit b8773c1

Browse files
Merge pull request #82 from danielgtaylor/completion
Completion
2 parents 0350c7e + b9d6da4 commit b8773c1

File tree

6 files changed

+277
-59
lines changed

6 files changed

+277
-59
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Features include:
1717
- Supported formats
1818
- [OpenAPI 3](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md) and [JSON Schema](https://json-schema.org/)
1919
- Automatic configuration of API auth if advertised by the API
20+
- Shell command completion for Bash, Fish, Zsh, Powershell
2021
- Automatic pagination of resource collections via [RFC 5988](https://tools.ietf.org/html/rfc5988) `prev` and `next` hypermedia links
2122
- API endpoint-based auth built-in with support for profiles:
2223
- HTTP Basic

cli/apiconfig.go

+15-13
Original file line numberDiff line numberDiff line change
@@ -99,19 +99,21 @@ func initAPIConfig() {
9999
}
100100

101101
for apiName, config := range configs {
102-
config.name = apiName
103-
configs[apiName] = config
104-
105-
n := apiName
106-
c := config
107-
cmd := &cobra.Command{
108-
Use: n,
109-
Short: c.Base,
110-
Run: func(cmd *cobra.Command, args []string) {
111-
cmd.Help()
112-
},
113-
}
114-
Root.AddCommand(cmd)
102+
func(config *APIConfig) {
103+
config.name = apiName
104+
configs[apiName] = config
105+
106+
n := apiName
107+
c := config
108+
cmd := &cobra.Command{
109+
Use: n,
110+
Short: c.Base,
111+
Run: func(cmd *cobra.Command, args []string) {
112+
cmd.Help()
113+
},
114+
}
115+
Root.AddCommand(cmd)
116+
}(config)
115117
}
116118
}
117119

0 commit comments

Comments
 (0)