clint:Python 命令行程序工具

网友投稿 791 2022-10-14

clint:Python 命令行程序工具

clint:Python 命令行程序工具

Clint: Python Command-line Application Tools

Clint is a module filled with a set of awesome tools for developing commandline applications.

C ommand L ine IN terface T ools .

Clint is awesome. Crazy awesome. It supports colors, but detects if the session is a TTY, so doesn't render the colors if you're piping stuff around. Automagically.

Awesome nest-able indentation context manager. Example: (with indent(4): puts('indented text')). It supports custom email-style quotes. Of course, it supports color too, if and when needed.

It has an awesome Column printer with optional auto-expanding columns. It detects how wide your current console is and adjusts accordingly. It wraps your words properly to fit the column size. With or without colors mixed in. All with a single function call.

The world's easiest to use implicit argument system w/ chaining methods for filtering. Seriously.

Run the various executables in examples to get a good feel for what Clint offers.

You'll never want to not use it.

Current Features:

Little Documentation (bear with me for now)CLI Colors and IndentsExtremely Simple + Powerful Column PrinterIterator-based Progress BarImplicit Argument HandlingSimple Support for Incoming Unix PipesApplication Directory management

Future Features:

Documentation!Simple choice system Are you sure? [Yn]Suggestions welcome.

Example

I want to indent my console text.

>>> from clint.textui import puts, indent>>> puts('not indented text')>>> with indent(4):>>> puts('indented text')not indented text indented text

I want to quote my console text (like email).

>>> puts('not indented text')>>> with indent(4, quote=' >'):>>> puts('quoted text')>>> puts('pretty cool, eh?')not indented text > quoted text > pretty cool, eh?

I want to color my console text.

>>> from clint.textui import colored, puts>>> puts(colored.red('red text'))red text# It's red in Windows, OSX, and Linux alike.

I want to get data piped to stdin.

>>> clint.piped_in()# if no data was piped in, piped_in returns None

I want to get the first commandline argument passed in.

>>> from clint import arguments>>> args = arguments.Args()>>> args.get(0)# if no argument was passed, get returns None

I want to store a configuration file.

>>> from clint import resources>>> resources.init('Company', 'AppName')>>> resources.user.write('config.ini', file_contents)# OSX: '/Users/appuser/Library/Application Support/AppName/config.ini'# Windows: 'C:\\Users\\appuser\\AppData\\Local\\Company\\AppName\\config.ini'# Linux: '/home/appuser/.config/appname/config.ini'

I want to force color output even if stdout is not a TTY:

$ export CLINT_FORCE_COLOR=1

I want to ask for input.

>>> from clint.textui import prompt, validators>>> path = prompt.query('Installation Path', default='/usr/local/bin/', validators=[validators.PathValidator()])

Installation

To install clint, simply:

$ pip install clint

Or, if you absolutely must:

$ easy_install clint

But, you really shouldn't do that.

License:

ISC License.

Copyright (c) 2011, Kenneth Reitz Permission to use, copy, modify, and/or distribute this software for anypurpose with or without fee is hereby granted, provided that the abovecopyright notice and this permission notice appear in all copies.THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIESWITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OFMERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FORANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGESWHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ANACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OFOR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

Contribute

If you'd like to contribute, simply fork the repository, commit your changes to the master branch (or branch off of it), and send a pull request. Make sure you add yourself to AUTHORS.

Roadmap

UnittestsSphinx Documentation

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Struts2_访问或添加request等属性
下一篇:Struts2_单文件上传
相关文章

 发表评论

暂时没有评论,来抢沙发吧~