Skip to content

Commit 82622df

Browse files
author
yoshibase
committed
Install fish and bash completions via pip data_files
Install extras/fish/http.fish and extras/bash-completion/http so pip install places completions where fish and bash expect them. Fixes #912
1 parent 5b604c3 commit 82622df

5 files changed

Lines changed: 163 additions & 6 deletions

File tree

MANIFEST.in

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ include docs/README.md
66

77
# <https://github.com/httpie/cli/issues/182>
88
recursive-include tests/ *
9+
include extras/httpie-completion.fish
10+
include extras/httpie-completion.bash
11+
include extras/fish/http.fish
12+
include extras/bash-completion/http

extras/bash-completion/http

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
_http_complete() {
2+
local cur_word=${COMP_WORDS[COMP_CWORD]}
3+
local prev_word=${COMP_WORDS[COMP_CWORD - 1]}
4+
5+
if [[ "$cur_word" == -* ]]; then
6+
_http_complete_options "$cur_word"
7+
fi
8+
}
9+
10+
complete -o default -F _http_complete http httpie.http httpie.https https
11+
12+
_http_complete_options() {
13+
local cur_word=$1
14+
local options="-j --json -f --form --pretty -s --style -p --print
15+
-v --verbose -h --headers -b --body -S --stream -o --output -d --download
16+
-c --continue --session --session-read-only -a --auth --auth-type --proxy
17+
--follow --verify --cert --cert-key --timeout --check-status --ignore-stdin
18+
--help --version --traceback --debug --raw"
19+
COMPREPLY=( $( compgen -W "$options" -- "$cur_word" ) )
20+
}

extras/fish/http.fish

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
function __fish_httpie_styles
2+
printf '%s\n' abap algol algol_nu arduino auto autumn borland bw colorful default emacs friendly fruity gruvbox-dark gruvbox-light igor inkpot lovelace manni material monokai murphy native paraiso-dark paraiso-light pastie perldoc pie pie-dark pie-light rainbow_dash rrt sas solarized solarized-dark solarized-light stata stata-dark stata-light tango trac vim vs xcode zenburn
3+
end
4+
5+
function __fish_httpie_mime_types
6+
test -r /usr/share/mime/types && cat /usr/share/mime/types
7+
end
8+
9+
function __fish_httpie_print_args
10+
set -l arg (commandline -t)
11+
string match -qe H "$arg" || echo -e $arg"H\trequest headers"
12+
string match -qe B "$arg" || echo -e $arg"B\trequest body"
13+
string match -qe h "$arg" || echo -e $arg"h\tresponse headers"
14+
string match -qe b "$arg" || echo -e $arg"b\tresponse body"
15+
string match -qe m "$arg" || echo -e $arg"m\tresponse metadata"
16+
end
17+
18+
function __fish_httpie_auth_types
19+
echo -e "basic\tBasic HTTP auth"
20+
echo -e "digest\tDigest HTTP auth"
21+
echo -e "bearer\tBearer HTTP Auth"
22+
end
23+
24+
function __fish_http_verify_options
25+
echo -e "yes\tEnable cert verification"
26+
echo -e "no\tDisable cert verification"
27+
end
28+
29+
30+
# Predefined Content Types
31+
32+
complete -c http -s j -l json -d 'Data items are serialized as a JSON object'
33+
complete -c http -s f -l form -d 'Data items are serialized as form fields'
34+
complete -c http -l multipart -d 'Always sends a multipart/form-data request'
35+
complete -c http -l boundary -x -d 'Custom boundary string for multipart/form-data requests'
36+
complete -c http -l raw -x -d 'Pass raw request data without extra processing'
37+
38+
39+
# Content Processing Options
40+
41+
complete -c http -s x -l compress -d 'Content compressed with Deflate algorithm'
42+
43+
44+
# Output Processing
45+
46+
complete -c http -l pretty -xa "all colors format none" -d 'Controls output processing'
47+
complete -c http -s s -l style -xa "(__fish_httpie_styles)" -d 'Output coloring style'
48+
complete -c http -l unsorted -d 'Disables all sorting while formatting output'
49+
complete -c http -l sorted -d 'Re-enables all sorting options while formatting output'
50+
complete -c http -l response-charset -x -d 'Override the response encoding'
51+
complete -c http -l response-mime -xa "(__fish_httpie_mime_types)" -d 'Override the response mime type for coloring and formatting'
52+
complete -c http -l format-options -x -d 'Controls output formatting'
53+
54+
55+
# Output Options
56+
57+
complete -c http -s p -l print -xa "(__fish_httpie_print_args)" -d 'String specifying what the output should contain'
58+
complete -c http -s h -l headers -d 'Print only the response headers'
59+
complete -c http -s m -l meta -d 'Print only the response metadata'
60+
complete -c http -s b -l body -d 'Print only the response body'
61+
complete -c http -s v -l verbose -d 'Print the whole request as well as the response'
62+
complete -c http -l all -d 'Show any intermediary requests/responses'
63+
complete -c http -s S -l stream -d 'Always stream the response body by line'
64+
complete -c http -s o -l output -F -d 'Save output to FILE'
65+
complete -c http -s d -l download -d 'Download a file'
66+
complete -c http -s c -l continue -d 'Resume an interrupted download'
67+
complete -c http -s q -l quiet -d 'Do not print to stdout or stderr'
68+
69+
70+
# Sessions
71+
72+
complete -c http -l session -F -d 'Create, or reuse and update a session'
73+
complete -c http -l session-read-only -F -d 'Create or read a session without updating it'
74+
75+
76+
# Authentication
77+
78+
complete -c http -s a -l auth -x -d 'Username and password for authentication'
79+
complete -c http -s A -l auth-type -xa "(__fish_httpie_auth_types)" -d 'The authentication mechanism to be used'
80+
complete -c http -l ignore-netrc -d 'Ignore credentials from .netrc'
81+
82+
83+
# Network
84+
85+
complete -c http -l offline -d 'Build the request and print it but don\'t actually send it'
86+
complete -c http -l proxy -x -d 'String mapping protocol to the URL of the proxy'
87+
complete -c http -s F -l follow -d 'Follow 30x Location redirects'
88+
complete -c http -l max-redirects -x -d 'Set maximum number of redirects'
89+
complete -c http -l max-headers -x -d 'Maximum number of response headers to be read before giving up'
90+
complete -c http -l timeout -x -d 'Connection timeout in seconds'
91+
complete -c http -l check-status -d 'Error with non-200 HTTP status code'
92+
complete -c http -l path-as-is -d 'Bypass dot segment URL squashing'
93+
complete -c http -l chunked -d 'Enable streaming via chunked transfer encoding'
94+
95+
96+
# SSL
97+
98+
complete -c http -l verify -xa "(__fish_http_verify_options)" -d 'Enable/disable cert verification'
99+
complete -c http -l ssl -x -d 'Desired protocol version to use'
100+
complete -c http -l ciphers -x -d 'String in the OpenSSL cipher list format'
101+
complete -c http -l cert -F -d 'Client side SSL certificate'
102+
complete -c http -l cert-key -F -d 'Private key to use with SSL'
103+
complete -c http -l cert-key-pass -x -d 'Passphrase for the given private key'
104+
105+
106+
# Troubleshooting
107+
108+
complete -c http -s I -l ignore-stdin -d 'Do not attempt to read stdin'
109+
complete -c http -l help -d 'Show help'
110+
complete -c http -l manual -d 'Show the full manual'
111+
complete -c http -l version -d 'Show version'
112+
complete -c http -l traceback -d 'Prints exception traceback should one occur'
113+
complete -c http -l default-scheme -x -d 'The default scheme to use'
114+
complete -c http -l debug -d 'Show debugging output'
115+
116+
117+
# Alias for https to http
118+
119+
complete -c https -w http

setup.cfg

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,3 @@ test =
103103
pytest-mock
104104
werkzeug<2.1.0
105105

106-
[options.data_files]
107-
share/man/man1 =
108-
extras/man/http.1
109-
extras/man/https.1
110-
extras/man/httpie.1

setup.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
11
from setuptools import setup
22

3-
setup()
3+
setup(
4+
data_files=[
5+
(
6+
"share/man/man1",
7+
[
8+
"extras/man/http.1",
9+
"extras/man/https.1",
10+
"extras/man/httpie.1",
11+
],
12+
),
13+
(
14+
"share/fish/vendor_completions.d",
15+
["extras/fish/http.fish"],
16+
),
17+
(
18+
"share/bash-completion/completions",
19+
["extras/bash-completion/http"],
20+
),
21+
],
22+
)

0 commit comments

Comments
 (0)