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,7 +611,7 @@ 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
@@ -672,7 +675,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
672
675
(-a username), HTTPie will prompt for the password.
673
676
674
677
""" ,
675
- )
678
+ ). completer = ChoicesCompleter (())
676
679
authentication .add_argument (
677
680
'--auth-type' ,
678
681
'-A' ,
@@ -683,7 +686,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
683
686
cache = False ,
684
687
short_help = 'The authentication mechanism to be used.' ,
685
688
help_formatter = format_auth_help ,
686
- )
689
+ ). completer = ChoicesCompleter (())
687
690
authentication .add_argument (
688
691
'--ignore-netrc' ,
689
692
default = False ,
@@ -717,7 +720,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
717
720
and $HTTPS_proxy are supported as well.
718
721
719
722
""" ,
720
- )
723
+ ). completer = ChoicesCompleter (())
721
724
network .add_argument (
722
725
'--follow' ,
723
726
'-F' ,
@@ -735,7 +738,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
735
738
By default, requests have a limit of 30 redirects (works with --follow).
736
739
737
740
""" ,
738
- )
741
+ ). completer = ChoicesCompleter (())
739
742
network .add_argument (
740
743
'--max-headers' ,
741
744
type = int ,
@@ -744,7 +747,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
744
747
'The maximum number of response headers to be read before '
745
748
'giving up (default 0, i.e., no limit).'
746
749
)
747
- )
750
+ ). completer = ChoicesCompleter (())
748
751
749
752
network .add_argument (
750
753
'--timeout' ,
@@ -761,7 +764,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
761
764
the underlying socket for timeout seconds).
762
765
763
766
""" ,
764
- )
767
+ ). completer = ChoicesCompleter (())
765
768
network .add_argument (
766
769
'--check-status' ,
767
770
default = False ,
@@ -811,7 +814,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
811
814
for private certs. (Or you can set the REQUESTS_CA_BUNDLE environment
812
815
variable instead.)
813
816
""" ,
814
- )
817
+ ). completer = ChoicesCompleter (( 'yes' , 'no' ))
815
818
ssl .add_argument (
816
819
'--ssl' ,
817
820
dest = 'ssl_version' ,
@@ -825,7 +828,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
825
828
are shown here).
826
829
827
830
""" ,
828
- )
831
+ ). completer = ChoicesCompleter (())
829
832
ssl .add_argument (
830
833
'--ciphers' ,
831
834
short_help = 'A string in the OpenSSL cipher list format.' ,
@@ -837,7 +840,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
837
840
{ DEFAULT_SSL_CIPHERS }
838
841
839
842
""" ,
840
- )
843
+ ). completer = ChoicesCompleter (())
841
844
ssl .add_argument (
842
845
'--cert' ,
843
846
default = None ,
@@ -849,7 +852,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
849
852
specify --cert-key separately.
850
853
851
854
""" ,
852
- )
855
+ ). completer = FilesCompleter (( 'crt' , 'cert' , 'pem' ))
853
856
ssl .add_argument (
854
857
'--cert-key' ,
855
858
default = None ,
@@ -860,7 +863,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
860
863
certificate file does not contain the private key.
861
864
862
865
""" ,
863
- )
866
+ ). completer = FilesCompleter (( 'key' , 'pem' ))
864
867
865
868
ssl .add_argument (
866
869
'--cert-key-pass' ,
@@ -872,7 +875,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
872
875
is given and the key file requires a passphrase.
873
876
If not provided, you’ll be prompted interactively.
874
877
"""
875
- )
878
+ ). completer = ChoicesCompleter (())
876
879
877
880
#######################################################################
878
881
# Troubleshooting
@@ -914,7 +917,7 @@ def format_auth_help(auth_plugins_mapping, *, isolation_mode: bool = False):
914
917
'--default-scheme' ,
915
918
default = 'http' ,
916
919
short_help = 'The default scheme to use if not specified in the URL.'
917
- )
920
+ ). completer = ChoicesCompleter (( 'http' , 'https' ))
918
921
troubleshooting .add_argument (
919
922
'--debug' ,
920
923
action = 'store_true' ,
0 commit comments