mirror of
https://github.com/httpie/cli.git
synced 2024-11-29 03:03:44 +01:00
Add a --default-scheme argument.
This commit is contained in:
parent
1ded5c2a97
commit
6259b5dd3b
@ -88,6 +88,7 @@ positional.add_argument(
|
|||||||
metavar='URL',
|
metavar='URL',
|
||||||
help="""
|
help="""
|
||||||
The scheme defaults to 'http://' if the URL does not include one.
|
The scheme defaults to 'http://' if the URL does not include one.
|
||||||
|
(You can override this with: --default-scheme https)
|
||||||
|
|
||||||
You can also use a shorthand for localhost
|
You can also use a shorthand for localhost
|
||||||
|
|
||||||
@ -558,6 +559,15 @@ troubleshooting.add_argument(
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
)
|
)
|
||||||
|
troubleshooting.add_argument(
|
||||||
|
'--default-scheme',
|
||||||
|
choices=["http", "https"],
|
||||||
|
default="http",
|
||||||
|
help="""
|
||||||
|
Default scheme to use if not specified in the URL.
|
||||||
|
|
||||||
|
"""
|
||||||
|
)
|
||||||
troubleshooting.add_argument(
|
troubleshooting.add_argument(
|
||||||
'--debug',
|
'--debug',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
@ -137,7 +137,7 @@ class Parser(ArgumentParser):
|
|||||||
if not self.args.ignore_stdin and not env.stdin_isatty:
|
if not self.args.ignore_stdin and not env.stdin_isatty:
|
||||||
self._body_from_file(self.env.stdin)
|
self._body_from_file(self.env.stdin)
|
||||||
if not URL_SCHEME_RE.match(self.args.url):
|
if not URL_SCHEME_RE.match(self.args.url):
|
||||||
scheme = HTTP
|
scheme = self.args.default_scheme + "://"
|
||||||
|
|
||||||
# See if we're using curl style shorthand for localhost (:3000/foo)
|
# See if we're using curl style shorthand for localhost (:3000/foo)
|
||||||
shorthand = re.match(r'^:(?!:)(\d*)(/?.*)$', self.args.url)
|
shorthand = re.match(r'^:(?!:)(\d*)(/?.*)$', self.args.url)
|
||||||
|
Loading…
Reference in New Issue
Block a user