3
3
import textwrap
4
4
from argparse import FileType
5
5
6
+ from argcomplete .completers import ChoicesCompleter , FilesCompleter
7
+
6
8
from httpie import __doc__ , __version__
7
9
from httpie .cli .argtypes import (KeyValueArgType , SessionNameValidator ,
8
10
SSLCredentials , readable_file_arg ,
64
66
$ http example.org hello=world # => POST
65
67
66
68
""" ,
67
- )
69
+ ).completer = ChoicesCompleter (
70
+ ('GET' , 'HEAD' , 'POST' , 'PUT' , 'PATCH' , 'DELETE' , 'OPTIONS' ))
68
71
positional_arguments .add_argument (
69
72
dest = 'url' ,
70
73
metavar = 'URL' ,
79
82
$ http :/foo # => http://localhost/foo
80
83
81
84
""" ,
82
- )
85
+ ). completer = ChoicesCompleter (())
83
86
positional_arguments .add_argument (
84
87
dest = 'request_items' ,
85
88
metavar = 'REQUEST_ITEM' ,
136
139
field-name-with\:colon=value
137
140
138
141
""" ,
139
- )
142
+ ). completer = ChoicesCompleter (())
140
143
141
144
#######################################################################
142
145
# Content type.
190
193
'Specify a custom boundary string for multipart/form-data requests. '
191
194
'Only has effect only together with --form.'
192
195
)
193
- )
196
+ ). completer = ChoicesCompleter (())
194
197
content_types .add_argument (
195
198
'--raw' ,
196
199
short_help = 'Pass raw request data without extra processing.' ,
@@ -351,7 +354,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
351
354
--response-charset=big5
352
355
353
356
""" ,
354
- )
357
+ ). completer = ChoicesCompleter (())
355
358
output_processing .add_argument (
356
359
'--response-mime' ,
357
360
metavar = 'MIME_TYPE' ,
@@ -364,7 +367,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
364
367
--response-mime=text/xml
365
368
366
369
""" ,
367
- )
370
+ ). completer = ChoicesCompleter (())
368
371
output_processing .add_argument (
369
372
'--format-options' ,
370
373
action = 'append' ,
@@ -389,7 +392,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
389
392
f' { option } ' for option in DEFAULT_FORMAT_OPTIONS
390
393
).strip ()
391
394
),
392
- )
395
+ ). completer = ChoicesCompleter (())
393
396
394
397
#######################################################################
395
398
# Output options
@@ -418,7 +421,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
418
421
response body is printed by default.
419
422
420
423
""" ,
421
- )
424
+ ). completer = ChoicesCompleter (())
422
425
output_options .add_argument (
423
426
'--headers' ,
424
427
'-h' ,
@@ -492,7 +495,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
492
495
dest = 'output_options_history' ,
493
496
metavar = 'WHAT' ,
494
497
help = Qualifiers .SUPPRESS ,
495
- )
498
+ ). completer = ChoicesCompleter (())
496
499
output_options .add_argument (
497
500
'--stream' ,
498
501
'-S' ,
@@ -526,7 +529,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
526
529
printed to stderr.
527
530
528
531
""" ,
529
- )
532
+ ). completer = FilesCompleter ()
530
533
531
534
output_options .add_argument (
532
535
'--download' ,
@@ -597,7 +600,7 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
597
600
598
601
https://httpie.io/docs/cli/config-file-directory
599
602
""" ,
600
- )
603
+ ). completer = FilesCompleter (( 'json' ,))
601
604
sessions .add_argument (
602
605
'--session-read-only' ,
603
606
metavar = 'SESSION_NAME_OR_PATH' ,
@@ -608,13 +611,12 @@ def format_style_help(available_styles, *, isolation_mode: bool = False):
608
611
exchange.
609
612
610
613
""" ,
611
- )
614
+ ). completer = FilesCompleter (( 'json' ,))
612
615
613
616
#######################################################################
614
617
# Authentication
615
618
#######################################################################
616
619
617
-
618
620
def format_auth_help (auth_plugins_mapping , * , isolation_mode : bool = False ):
619
621
text = """
620
622
The authentication mechanism to be used. Defaults to "{default}".
@@ -672,7 +674,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
672
674
(-a username), HTTPie will prompt for the password.
673
675
674
676
""" ,
675
- )
677
+ ). completer = ChoicesCompleter (())
676
678
authentication .add_argument (
677
679
'--auth-type' ,
678
680
'-A' ,
@@ -683,7 +685,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
683
685
cache = False ,
684
686
short_help = 'The authentication mechanism to be used.' ,
685
687
help_formatter = format_auth_help ,
686
- )
688
+ ). completer = ChoicesCompleter (())
687
689
authentication .add_argument (
688
690
'--ignore-netrc' ,
689
691
default = False ,
@@ -717,7 +719,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
717
719
and $HTTPS_proxy are supported as well.
718
720
719
721
""" ,
720
- )
722
+ ). completer = ChoicesCompleter (())
721
723
network .add_argument (
722
724
'--follow' ,
723
725
'-F' ,
@@ -735,7 +737,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
735
737
By default, requests have a limit of 30 redirects (works with --follow).
736
738
737
739
""" ,
738
- )
740
+ ). completer = ChoicesCompleter (())
739
741
network .add_argument (
740
742
'--max-headers' ,
741
743
type = int ,
@@ -744,7 +746,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
744
746
'The maximum number of response headers to be read before '
745
747
'giving up (default 0, i.e., no limit).'
746
748
)
747
- )
749
+ ). completer = ChoicesCompleter (())
748
750
749
751
network .add_argument (
750
752
'--timeout' ,
@@ -761,7 +763,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
761
763
the underlying socket for timeout seconds).
762
764
763
765
""" ,
764
- )
766
+ ). completer = ChoicesCompleter (())
765
767
network .add_argument (
766
768
'--check-status' ,
767
769
default = False ,
@@ -811,7 +813,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
811
813
for private certs. (Or you can set the REQUESTS_CA_BUNDLE environment
812
814
variable instead.)
813
815
""" ,
814
- )
816
+ ). completer = ChoicesCompleter (( 'yes' , 'no' ))
815
817
ssl .add_argument (
816
818
'--ssl' ,
817
819
dest = 'ssl_version' ,
@@ -825,7 +827,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
825
827
are shown here).
826
828
827
829
""" ,
828
- )
830
+ ). completer = ChoicesCompleter (())
829
831
ssl .add_argument (
830
832
'--ciphers' ,
831
833
short_help = 'A string in the OpenSSL cipher list format.' ,
@@ -837,7 +839,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
837
839
{ DEFAULT_SSL_CIPHERS }
838
840
839
841
""" ,
840
- )
842
+ ). completer = ChoicesCompleter (())
841
843
ssl .add_argument (
842
844
'--cert' ,
843
845
default = None ,
@@ -849,7 +851,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
849
851
specify --cert-key separately.
850
852
851
853
""" ,
852
- )
854
+ ). completer = FilesCompleter (( 'crt' , 'cert' , 'pem' ))
853
855
ssl .add_argument (
854
856
'--cert-key' ,
855
857
default = None ,
@@ -860,7 +862,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
860
862
certificate file does not contain the private key.
861
863
862
864
""" ,
863
- )
865
+ ). completer = FilesCompleter (( 'key' , 'pem' ))
864
866
865
867
ssl .add_argument (
866
868
'--cert-key-pass' ,
@@ -872,7 +874,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
872
874
is given and the key file requires a passphrase.
873
875
If not provided, you’ll be prompted interactively.
874
876
"""
875
- )
877
+ ). completer = ChoicesCompleter (())
876
878
877
879
#######################################################################
878
880
# Troubleshooting
@@ -914,7 +916,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
914
916
'--default-scheme' ,
915
917
default = 'http' ,
916
918
short_help = 'The default scheme to use if not specified in the URL.'
917
- )
919
+ ). completer = ChoicesCompleter (( 'http' , 'https' ))
918
920
troubleshooting .add_argument (
919
921
'--debug' ,
920
922
action = 'store_true' ,
0 commit comments