Skip to content

Commit

Permalink
http: fix multiparts completion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Dec 4, 2022
1 parent 16bb512 commit 1349b97
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 40 deletions.
2 changes: 1 addition & 1 deletion completers/carapace_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func flagCmd(args []string) *cobra.Command {
}),
"scrape": carapace.ActionFiles(".yaml"),
"spec": carapace.ActionFiles(".yaml"),
"style": carapace.ActionStyleConfig(),
"style": carapace.ActionStyleConfig().NoSpace(),
})

carapace.Gen(cmd).PositionalAnyCompletion(
Expand Down
2 changes: 1 addition & 1 deletion completers/faas-cli_completer/cmd/invoke.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func init() {
rootCmd.AddCommand(invokeCmd)

carapace.Gen(invokeCmd).FlagCompletion(carapace.ActionMap{
"content-type": http.ActionMediaTypes(),
"content-type": http.ActionMediaTypes().MultiParts("/"),
"method": http.ActionRequestMethods(),
"namespace": action.ActionNamespaces(),
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/actions/net/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func ActionRequestHeaderValues(header string) carapace.Action {
switch header {
// TODO complete more headers
case "Accept":
return ActionMediaTypes().UniqueList(",")
return ActionMediaTypes().MultiParts("/").UniqueList(",")
case "Accept-Encoding":
return ActionContentEncodingTokens().UniqueList(",")
case "Accept-Language":
Expand All @@ -93,7 +93,7 @@ func ActionRequestHeaderValues(header string) carapace.Action {
case "Content-Encoding":
return ActionContentEncodingTokens().UniqueList(",")
case "Content-Type":
return ActionMediaTypes().UniqueList(",")
return ActionMediaTypes().MultiParts("/").UniqueList(",")
case "Transfer-Encoding":
return ActionTransferEncodingTokens()
case "User-Agent":
Expand Down
70 changes: 34 additions & 36 deletions pkg/actions/tools/mitmproxy/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,42 +188,40 @@ func ActionOptionValues(option string) carapace.Action {
}
}),
).ToA(),
"dns_server": actionBool,
"export_preserve_original_ip": actionBool,
"http2": actionBool,
"http2_ping_keepalive": carapace.ActionValues(),
"ignore_hosts": carapace.ActionValues(),
"intercept": carapace.ActionValues(), // TODO completion?
"intercept_active": actionBool,
"keep_host_header": actionBool,
"key_size": carapace.ActionValues(),
"listen_host": carapace.ActionValues(),
"listen_port": net.ActionPorts(),
"map_local": carapace.ActionValues(), // TODO completion
"map_remote": carapace.ActionValues(),
"mode": ActionModes(),
"modify_body": ActionModifyBodyPattern(),
"modify_headers": ActionModifyHeaderPattern(),
"normalize_outbound_headers": actionBool,
"onboarding": actionBool,
"onboarding_host": carapace.ActionValues(),
"onboarding_port": net.ActionPorts(),
"proxy_debug": actionBool,
"proxyauth": carapace.ActionValues(),
"rawtcp": actionBool,
"readfile_filter": actionOptionFlowFilters(),
"rfile": carapace.ActionFiles(),
"save_stream_file": ActionAppendableFiles(),
"save_stream_filter": actionOptionFlowFilters(),
"scripts": carapace.ActionFiles(),
"server": actionBool,
"server_replay": carapace.ActionFiles(),
"server_replay_ignore_content": actionBool,
"server_replay_ignore_host": actionBool,
"server_replay_ignore_params": carapace.ActionValues(),
"server_replay_ignore_payload_params": carapace.ActionCallback(func(c carapace.Context) carapace.Action {
return http.ActionMediaTypes().Invoke(c).ToMultiPartsA("/")
}),
"dns_server": actionBool,
"export_preserve_original_ip": actionBool,
"http2": actionBool,
"http2_ping_keepalive": carapace.ActionValues(),
"ignore_hosts": carapace.ActionValues(),
"intercept": carapace.ActionValues(), // TODO completion?
"intercept_active": actionBool,
"keep_host_header": actionBool,
"key_size": carapace.ActionValues(),
"listen_host": carapace.ActionValues(),
"listen_port": net.ActionPorts(),
"map_local": carapace.ActionValues(), // TODO completion
"map_remote": carapace.ActionValues(),
"mode": ActionModes(),
"modify_body": ActionModifyBodyPattern(),
"modify_headers": ActionModifyHeaderPattern(),
"normalize_outbound_headers": actionBool,
"onboarding": actionBool,
"onboarding_host": carapace.ActionValues(),
"onboarding_port": net.ActionPorts(),
"proxy_debug": actionBool,
"proxyauth": carapace.ActionValues(),
"rawtcp": actionBool,
"readfile_filter": actionOptionFlowFilters(),
"rfile": carapace.ActionFiles(),
"save_stream_file": ActionAppendableFiles(),
"save_stream_filter": actionOptionFlowFilters(),
"scripts": carapace.ActionFiles(),
"server": actionBool,
"server_replay": carapace.ActionFiles(),
"server_replay_ignore_content": actionBool,
"server_replay_ignore_host": actionBool,
"server_replay_ignore_params": carapace.ActionValues(),
"server_replay_ignore_payload_params": http.ActionMediaTypes().MultiParts("/"),
"server_replay_ignore_port": actionBool,
"server_replay_kill_extra": actionBool,
"server_replay_nopop": actionBool,
Expand Down

0 comments on commit 1349b97

Please sign in to comment.