mirror of
https://github.com/httpie/cli.git
synced 2025-06-21 01:57:42 +02:00
check --ssl-cert and --ssl-key to be files
This commit is contained in:
parent
14583a2efa
commit
b9d7220b10
@ -19,6 +19,7 @@ from .input import (Parser, AuthCredentialsArgType, KeyValueArgType,
|
|||||||
OUT_REQ_HEAD, OUT_REQ_BODY, OUT_RESP_HEAD,
|
OUT_REQ_HEAD, OUT_REQ_BODY, OUT_RESP_HEAD,
|
||||||
OUT_RESP_BODY, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT,
|
OUT_RESP_BODY, OUTPUT_OPTIONS, OUTPUT_OPTIONS_DEFAULT,
|
||||||
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, SessionNameValidator)
|
PRETTY_MAP, PRETTY_STDOUT_TTY_ONLY, SessionNameValidator)
|
||||||
|
from .utils import existing_file
|
||||||
|
|
||||||
|
|
||||||
class HTTPieHelpFormatter(RawDescriptionHelpFormatter):
|
class HTTPieHelpFormatter(RawDescriptionHelpFormatter):
|
||||||
@ -468,6 +469,7 @@ network.add_argument(
|
|||||||
network.add_argument(
|
network.add_argument(
|
||||||
'--ssl-cert',
|
'--ssl-cert',
|
||||||
default=None,
|
default=None,
|
||||||
|
type=existing_file,
|
||||||
help="""
|
help="""
|
||||||
You can specify a local cert to use as client side SSL certificate.
|
You can specify a local cert to use as client side SSL certificate.
|
||||||
This file may either contain both private key and certificate or you may
|
This file may either contain both private key and certificate or you may
|
||||||
@ -479,6 +481,7 @@ network.add_argument(
|
|||||||
network.add_argument(
|
network.add_argument(
|
||||||
'--ssl-key',
|
'--ssl-key',
|
||||||
default=None,
|
default=None,
|
||||||
|
type=existing_file,
|
||||||
help="""
|
help="""
|
||||||
The private key to use with SSL. Only needed if --ssl-cert is given and the
|
The private key to use with SSL. Only needed if --ssl-cert is given and the
|
||||||
certificate file does not contain the private key.
|
certificate file does not contain the private key.
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
import argparse
|
||||||
|
|
||||||
|
|
||||||
def humanize_bytes(n, precision=2):
|
def humanize_bytes(n, precision=2):
|
||||||
@ -44,3 +45,12 @@ def humanize_bytes(n, precision=2):
|
|||||||
break
|
break
|
||||||
|
|
||||||
return '%.*f %s' % (precision, n / factor, suffix)
|
return '%.*f %s' % (precision, n / factor, suffix)
|
||||||
|
|
||||||
|
|
||||||
|
def existing_file(filename):
|
||||||
|
try:
|
||||||
|
open(filename, 'rb')
|
||||||
|
except IOError as ex:
|
||||||
|
raise argparse.ArgumentTypeError(
|
||||||
|
'%s: %s' % (filename, ex.args[1]))
|
||||||
|
return filename
|
||||||
|
Loading…
x
Reference in New Issue
Block a user