===========
Click Click
===========
.. image:: https://travis-ci.org/hjacobs/python-clickclick.svg?branch=master
:target: https://travis-ci.org/hjacobs/python-clickclick
:alt: Travis CI build status
.. image:: https://coveralls.io/repos/hjacobs/python-clickclick/badge.svg
:target: https://coveralls.io/r/hjacobs/python-clickclick
.. image:: https://img.shields.io/pypi/dw/clickclick.svg
:target: https://pypi.python.org/pypi/clickclick/
:alt: PyPI Downloads
.. image:: https://img.shields.io/pypi/v/clickclick.svg
:target: https://pypi.python.org/pypi/clickclick/
:alt: Latest PyPI version
.. image:: https://img.shields.io/pypi/l/clickclick.svg
:target: https://pypi.python.org/pypi/clickclick/
:alt: License
Utility functions (Python 3 only) for the wonderful `Click library`_.
Click is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary.
Usage
=====
.. code-block:: python
from clickclick import Action, OutputFormat
with Action('Performing remote call..') as act:
do_something()
act.progress()
do_something_else()
output_format = 'json' # default: "text"
with OutputFormat(output_format):
print_table(['col1', 'col2'], rows)
.. _Click library: http://click.pocoo.org/
Working Example
---------------
See this `example script`_ and the `shell script`_.
.. _example script: example.py
.. _shell script: example.sh
.. code-block:: python3
$ ./example.py
Usage: example.py [OPTIONS] COMMAND [ARGS]...
Options:
-V, --version Print the current version number and exit.
-h, --help Show this message and exit.
Commands:
list Example for Listings
localtime Print the localtime
output Example for all possible Echo Formats You see...
work-in-progress Work untile working is done
work_done Work done in ?? %
::
$ ./example.py l
Usage: example.py [OPTIONS] COMMAND [ARGS]...
Error: Too many matches: list, localtime
::
$ ./example.py lo
Localtime: 2015-08-27 15:47:46.688547
::
$ ./example.py li
Identifier|Name |Status |Creation Date|Description |Without Title
0 Column #0 ERROR -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
1 Column #1 FINE -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
2 Column #2 WARNING -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title
::
$ ./example.py li -o tsv
id name state creation_time desc without_title
0 Column #0 ERROR -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title
1 Column #1 FINE -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title
2 Column #2 WARNING -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title
::
$ ./example.py li -o json
[{"creation_time": 1444911300, "desc": "this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description", "id": 0, "name": "Column #0", "state": "ERROR", "without_title": "column without title"}, {"creation_time": 1444911300, "desc": "this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description", "id": 1, "name": "Column #1", "state": "FINE", "without_title": "column without title"}, {"creation_time": 1444911300, "desc": "this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description", "id": 2, "name": "Column #2", "state": "WARNING", "without_title": "column without title"}]
::
$ ./example.py li -o yaml
creation_time: 1444911300
desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description
id: 0
name: 'Column #0'
state: ERROR
without_title: column without title
---
creation_time: 1444911300
desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description
id: 1
name: 'Column #1'
state: FINE
without_title: column without title
---
creation_time: 1444911300
desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description
id: 2
name: 'Column #2'
state: WARNING
without_title: column without title
::
$ ./example.py work-
do anything.. OK
create an excption.. EXCEPTION OCCURRED: No active exception to reraise
Start with working.. . . . . OK
Calc 1 + 1.. 2
Oh, I make an error.. work not complete done
Oh, I make a warning.. work is complicated
Start an exception.. EXCEPTION OCCURRED: name 'function_not_found' is not defined
Make a final error.. this is the end..
::
$ ./example.py work_ 15.4
Please select the state of your work
1) Done
2) In Progress
3) unknown
4) lost
Please select (1-4) [4]: 2
Your work is 15.4% In Progress
::
$ ./example.py work_ 15.4
Please select the state of your work
1) Done
2) In Progress
3) unknown
4) lost
Please select (1-4) [4]: 3
Your work is 15.4% unknown
::
$ ./example.py work_ 15.4
Please select the state of your work
1) Done
2) In Progress
3) unknown
4) lost
Please select (1-4) [4]:
Your work is 15.4% lost
::
$ ./example.py output
This is a ok: OK
This is a ok with message:all is fine
This is a warning: please check this
Start with working.. . . . . OK
Id|Name
1 Test #1
2 Test #2
Only FYI
This is a error: this is wrong, please fix
This is a fatal error: this is a fuckup
::
$ ./example.py output -o tsv
id name
1 Test #1
2 Test #2
::
$ ./example.py output -o json
[{"id": 1, "name": "Test #1"}, {"id": 2, "name": "Test #2"}]
::
$ ./example.py output -o yaml
id: 1
name: 'Test #1'
---
id: 2
name: 'Test #2'
License
=======
Copyright (c) 2015-2019 Zalando SE
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Raw data
{
"_id": null,
"home_page": "https://codeberg.org/hjacobs/python-clickclick",
"name": "clickclick",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "click console terminal cli",
"author": "Henning Jacobs",
"author_email": "henning.jacobs@jacobs1.de",
"download_url": "https://files.pythonhosted.org/packages/c6/19/f91d85941b79964d569a3729bf9f8b7f85ab47240248e77b7c0c8ed6ecc3/clickclick-20.10.2.tar.gz",
"platform": "",
"description": "===========\nClick Click\n===========\n\n.. image:: https://travis-ci.org/hjacobs/python-clickclick.svg?branch=master\n :target: https://travis-ci.org/hjacobs/python-clickclick\n :alt: Travis CI build status\n\n.. image:: https://coveralls.io/repos/hjacobs/python-clickclick/badge.svg\n :target: https://coveralls.io/r/hjacobs/python-clickclick\n\n.. image:: https://img.shields.io/pypi/dw/clickclick.svg\n :target: https://pypi.python.org/pypi/clickclick/\n :alt: PyPI Downloads\n\n.. image:: https://img.shields.io/pypi/v/clickclick.svg\n :target: https://pypi.python.org/pypi/clickclick/\n :alt: Latest PyPI version\n\n.. image:: https://img.shields.io/pypi/l/clickclick.svg\n :target: https://pypi.python.org/pypi/clickclick/\n :alt: License\n\nUtility functions (Python 3 only) for the wonderful `Click library`_.\nClick is a Python package for creating beautiful command line interfaces in a composable way with as little code as necessary.\n\n\nUsage\n=====\n\n.. code-block:: python\n\n from clickclick import Action, OutputFormat\n\n with Action('Performing remote call..') as act:\n do_something()\n act.progress()\n do_something_else()\n\n output_format = 'json' # default: \"text\"\n with OutputFormat(output_format):\n print_table(['col1', 'col2'], rows)\n\n\n.. _Click library: http://click.pocoo.org/\n\nWorking Example\n---------------\n\nSee this `example script`_ and the `shell script`_.\n\n.. _example script: example.py\n\n.. _shell script: example.sh\n\n.. code-block:: python3\n\n $ ./example.py\n Usage: example.py [OPTIONS] COMMAND [ARGS]...\n\n Options:\n -V, --version Print the current version number and exit.\n -h, --help Show this message and exit.\n\n Commands:\n list Example for Listings\n localtime Print the localtime\n output Example for all possible Echo Formats You see...\n work-in-progress Work untile working is done\n work_done Work done in ?? %\n\n::\n\n $ ./example.py l\n Usage: example.py [OPTIONS] COMMAND [ARGS]...\n\n Error: Too many matches: list, localtime\n\n::\n\n $ ./example.py lo\n Localtime: 2015-08-27 15:47:46.688547\n\n::\n\n $ ./example.py li\n Identifier|Name |Status |Creation Date|Description |Without Title\n 0 Column #0 ERROR -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title\n 1 Column #1 FINE -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title\n 2 Column #2 WARNING -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr.. column without title\n\n::\n\n $ ./example.py li -o tsv\n id name state creation_time desc without_title\n 0 Column #0 ERROR -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title\n 1 Column #1 FINE -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title\n 2 Column #2 WARNING -4228033s ago this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description column without title\n\n::\n\n $ ./example.py li -o json\n [{\"creation_time\": 1444911300, \"desc\": \"this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\", \"id\": 0, \"name\": \"Column #0\", \"state\": \"ERROR\", \"without_title\": \"column without title\"}, {\"creation_time\": 1444911300, \"desc\": \"this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\", \"id\": 1, \"name\": \"Column #1\", \"state\": \"FINE\", \"without_title\": \"column without title\"}, {\"creation_time\": 1444911300, \"desc\": \"this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\", \"id\": 2, \"name\": \"Column #2\", \"state\": \"WARNING\", \"without_title\": \"column without title\"}]\n\n::\n\n $ ./example.py li -o yaml\n creation_time: 1444911300\n desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\n id: 0\n name: 'Column #0'\n state: ERROR\n without_title: column without title\n ---\n creation_time: 1444911300\n desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\n id: 1\n name: 'Column #1'\n state: FINE\n without_title: column without title\n ---\n creation_time: 1444911300\n desc: this is a verrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrry long description\n id: 2\n name: 'Column #2'\n state: WARNING\n without_title: column without title\n\n\n::\n\n $ ./example.py work-\n do anything.. OK\n create an excption.. EXCEPTION OCCURRED: No active exception to reraise\n Start with working.. . . . . OK\n Calc 1 + 1.. 2\n Oh, I make an error.. work not complete done\n Oh, I make a warning.. work is complicated\n Start an exception.. EXCEPTION OCCURRED: name 'function_not_found' is not defined\n Make a final error.. this is the end..\n\n::\n\n $ ./example.py work_ 15.4\n Please select the state of your work\n 1) Done\n 2) In Progress\n 3) unknown\n 4) lost\n Please select (1-4) [4]: 2\n Your work is 15.4% In Progress\n\n::\n\n $ ./example.py work_ 15.4\n Please select the state of your work\n 1) Done\n 2) In Progress\n 3) unknown\n 4) lost\n Please select (1-4) [4]: 3\n Your work is 15.4% unknown\n\n::\n\n $ ./example.py work_ 15.4\n Please select the state of your work\n 1) Done\n 2) In Progress\n 3) unknown\n 4) lost\n Please select (1-4) [4]:\n Your work is 15.4% lost\n\n::\n\n $ ./example.py output\n This is a ok: OK\n This is a ok with message:all is fine\n This is a warning: please check this\n Start with working.. . . . . OK\n Id|Name\n 1 Test #1\n 2 Test #2\n Only FYI\n This is a error: this is wrong, please fix\n This is a fatal error: this is a fuckup\n\n::\n\n $ ./example.py output -o tsv\n id name\n 1 Test #1\n 2 Test #2\n\n::\n\n $ ./example.py output -o json\n [{\"id\": 1, \"name\": \"Test #1\"}, {\"id\": 2, \"name\": \"Test #2\"}]\n\n::\n\n $ ./example.py output -o yaml\n id: 1\n name: 'Test #1'\n ---\n id: 2\n name: 'Test #2'\n\n\nLicense\n=======\n\nCopyright (c) 2015-2019 Zalando SE\n\nLicensed under the Apache License, Version 2.0 (the \"License\");\nyou may not use this file except in compliance with the License.\nYou may obtain a copy of the License at\n\nhttp://www.apache.org/licenses/LICENSE-2.0\n\nUnless required by applicable law or agreed to in writing, software\ndistributed under the License is distributed on an \"AS IS\" BASIS,\nWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\nSee the License for the specific language governing permissions and\nlimitations under the License.\n",
"bugtrack_url": null,
"license": "Apache License 2.0",
"summary": "Click utility functions",
"version": "20.10.2",
"split_keywords": [
"click",
"console",
"terminal",
"cli"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7a7ec08007d3fb2bbefb430437a3573373590abedc03566b785d7d6763b22480",
"md5": "8a807d01436cef03fbb5030a4d1c43e5",
"sha256": "c8f33e6d9ec83f68416dd2136a7950125bd256ec39ccc9a85c6e280a16be2bb5"
},
"downloads": -1,
"filename": "clickclick-20.10.2-py2.py3-none-any.whl",
"has_sig": false,
"md5_digest": "8a807d01436cef03fbb5030a4d1c43e5",
"packagetype": "bdist_wheel",
"python_version": "3.8",
"requires_python": null,
"size": 7368,
"upload_time": "2020-10-03T13:36:49",
"upload_time_iso_8601": "2020-10-03T13:36:49.842726Z",
"url": "https://files.pythonhosted.org/packages/7a/7e/c08007d3fb2bbefb430437a3573373590abedc03566b785d7d6763b22480/clickclick-20.10.2-py2.py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c619f91d85941b79964d569a3729bf9f8b7f85ab47240248e77b7c0c8ed6ecc3",
"md5": "1d58cf500697561cb71a8dc164389b85",
"sha256": "4efb13e62353e34c5eef7ed6582c4920b418d7dedc86d819e22ee089ba01802c"
},
"downloads": -1,
"filename": "clickclick-20.10.2.tar.gz",
"has_sig": false,
"md5_digest": "1d58cf500697561cb71a8dc164389b85",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 9914,
"upload_time": "2020-10-03T13:36:47",
"upload_time_iso_8601": "2020-10-03T13:36:47.966384Z",
"url": "https://files.pythonhosted.org/packages/c6/19/f91d85941b79964d569a3729bf9f8b7f85ab47240248e77b7c0c8ed6ecc3/clickclick-20.10.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2020-10-03 13:36:47",
"github": false,
"gitlab": false,
"bitbucket": false,
"lcname": "clickclick"
}