Skip to content
Myr

Improved echo and some help texts

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 95c24b3 · Browse files · 4 files+10 added−4 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+10 added−4 removed

  • other:+10 added−4 removed

4 files+10 added−4 removed

modified:click/_compat.py+2 added
16 unmodified lines
17if PY2:18 text_type = unicode19 bytes = str20 raw_input = raw_input21 string_types = (str, unicode)2223 def open_stream(filename, mode='r', encoding=None, errors='strict'):24 if filename != '-':25 if encoding is not None:
13 unmodified lines
39else:40 import io41 text_type = str42 raw_input = input43 string_types = (str,)4445 def _make_binary_stream(f, stream_name):46 buf = getattr(f, 'buffer', None)47 if buf is not None and isinstance(buf, io.BufferedReader):
27 unmodified lines
modified:click/core.py+3 added-2 removed
597 unmodified lines
598599 return value600601 def get_missing_message(self, ctx):602 return 'Missing %s "%s".' % (602 return 'Missing %s %s.' % (603 self.param_type_name,604 ' / '.join(chain(self.opts, self.secondary_opts)),604 ' / '.join('"%s"' % x for x in chain(605 self.opts, self.secondary_opts)),606 )607608 def value_from_envvar(self, ctx):609 if self.envvar is None:
295 unmodified lines
modified:click/helpers.py+3 added-1 removed
1import os2import sys3import struct45from ._compat import raw_input, PY2, text_type5from ._compat import raw_input, PY2, text_type, string_types6from .utils import get_best_encoding7from .exceptions import Abort, UsageError8from .types import convert_type9
151 unmodified lines
161 :param file: the file to write to (defaults to ``stdout``)162 """163 if file is None:164 file = sys.stdout165 if not isinstance(message, string_types):166 message = text_type(message)167 if message:168 if PY2 and isinstance(message, text_type):169 encoding = get_best_encoding(file)170 message = message.encode(encoding, 'replace')
3 unmodified lines
modified:click/types.py+2 added-1 removed
38 unmodified lines
39 """Helper method to fail with an invalid value message."""40 if param is None:41 message = 'Invalid value: %s' % message42 else:43 names = ' / '.join(param.opts) or param.name43 message = 'Invalid value for %s: %s' % (param.name, message)44 message = 'Invalid value for "%s": %s' % (names, message)45 raise UsageError(message, ctx=ctx)464748class FuncParamType(ParamType):
193 unmodified lines