Merge pull request #114 from iKevinY/doc-fixes
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Documentation Fixes
authored by Armin Ronacher · committed by Armin Ronacher · parents e0ea94a, 24c01d5 · Browse files · 2 files·+22 added−22 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
2 files+22 added−22 removed
- other:+22 added−22 removed
Provenance
- Commit
a6136b4- Tree
6d36dda- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
e0ea94a- Parent 2
24c01d5
2 files changed+22 added−22 removed
modified:docs/utils.rst+17 added-17 removed
10 unmodified lines11 Printing to Stdout12 ------------------13 14 The most obvious helper is the :func:`echo` function, which in many ways15-works like the Python print statement or function. The main difference is15+works like the Python ``print`` statement or function. The main difference is16 that it works the same in Python 2 and 3, it intelligently detects17-misconfigured output streams, and will never fail (except in Python 3; for17+misconfigured output streams, and it will never fail (except in Python 3; for18 more information see :ref:`python3-limitations`).19 20 Example::21 1 unmodified line23 24 click.echo('Hello World!')25 26 Most importantly, it can print both Unicode and binary data, unlike the27-builtin ``print`` function in Python 3, which cannot output any bytes. It28-will, however, emit a trailing newline by default which needs to be29-supressed by passing ``nl=False``::27+built-in ``print`` function in Python 3, which cannot output any bytes. It28+will, however, emit a trailing newline by default, which needs to be29+suppressed by passing ``nl=False``::30 31 click.echo(b'\xe2\x98\x83', nl=False)32 33 10 unmodified lines44 is installed, then ANSI codes are intelligently handled.45 46 Primarily this means that:47 48-- click's echo function will automatically strip ANSI color codes if the49- stream is not connected to a terminal.50-- the echo function will transparently connect to the terminal on48+- click's :func:`echo` function will automatically strip ANSI color codes49+ if the stream is not connected to a terminal.50+- the :func:`echo` function will transparently connect to the terminal on51 Windows and translate ANSI codes to terminal API calls. This means52 that colors will work on Windows the same way they do on other53 operating systems.54 3 unmodified lines58 To install `colorama`, run this command::59 60 $ pip install colorama61 62-For styling a string the :func:`style` function can be used::62+For styling a string, the :func:`style` function can be used::63 64 import click65 66 click.echo(click.style('Hello World!', fg='green'))67 click.echo(click.style('Some more text', bg='blue', fg='white'))68- click.echo(click.style('ATTENTION', blink=True))68+ click.echo(click.style('ATTENTION', blink=True, bold=True))69 70 The combination of :func:`echo` and :func:`style` is also available in71 a single function called :func:`secho`::72 73 click.secho('Hello World!', fg='green')74 click.secho('Some more text', bg='blue', fg='white')75- click.secho('ATTENTION', blink=True)75+ click.secho('ATTENTION', blink=True, bold=True)76 77 78 .. _colorama: https://pypi.python.org/pypi/colorama79 39 unmodified lines119 standard input. However, this is buffered input and will not show up until120 the line has been terminated. In certain circumstances, you might not want121 to do that and instead read individual characters as they are being written.122 123-For thi,s click provides the :func:`getchar` function which reads a single123+For this, click provides the :func:`getchar` function which reads a single124 character from the terminal buffer and returns it as a Unicode character.125 126 Note that this function will always read from the terminal, even if stdin127 is instead a pipe.14 unmodified lines142 143 Note that this reads raw input, which means that things like arrow keys144 will show up in the platform's native escape format. The only characters145 translated are ``^C`` and ``^D`` which are converted into keyboard146-interrupt and end of file exceptions. This is done because otherwise it's147-too easy to forget about that and to create scripts that cannot be148-properly exited.146+interrupts and end of file exceptions respectively. This is done because147+otherwise, it's too easy to forget about that and to create scripts that148+cannot be properly exited.149 150 151 Waiting for Key Press152 ---------------------68 unmodified lines221 ------------------222 223 Because filenames might not be Unicode, formatting them can be a bit224 tricky. Generally, this is easier in Python 2 than on 3, as you can just225-write the bytes to stdout with the print function, but in Python 3, you will226-always need to operate in Unicode.225+write the bytes to stdout with the ``print`` function, but in Python 3, you226+will always need to operate in Unicode.227 228 The way this works with click is through the :func:`format_filename`229 function. It does a best-effort conversion of the filename to Unicode and230 will never fail. This makes it possible to use these filenames in the106 unmodified linesmodified:README+5 added-5 removed
1 $ click_2 3- click is a Python package for creating beautiful command line interfaces3+ Click is a Python package for creating beautiful command line interfaces4 in a composable way with as little amount of code as necessary. It's the5 "Command Line Interface Creation Kit". It's highly configurable but comes6 with good defaults out of the box.7 8- It aims at making writing command line tools fun and quick without causing9- user frustration at not being able to implement an intended CLI API.8+ It aims to make writing command line tools quick and fun without causing9+ user frustration from the inability to implement a desired CLI API.10 11 Click in three points:12- 12+13 - arbitrary nesting of commands14 - automatic help page generation15- - supports lazy loading of subcommands at runtime 15+ - supports lazy loading of subcommands at runtime16 17 Read the docs at http://click.pocoo.org/18 19 This library is work in progress. Please give feedback!