Skip to main content

Library for writing simple terminal apps

Project description

termapp

CI Status Releases PyPi Wheel Python Versions

Create terminal applications with python.

Installation

pip install termapp

Usage

import asyncio

from termapp import __version__
from termapp.styles import BOLD
from termapp.asyncio import create_app

app = create_app()


async def start():
    await app.write_line(f"termapp demo app v{__version__}", BOLD)
    await app.write_line('This app demonstrates the capabilities of the termapp module.')

    await app.info('info is used to introduce an important step in the app.')
    await app.details('details can be used to add additional informationen.')

    await app.warn('warn shows a warning')
    await app.details('which can also be enhanced with a details message.')

    await app.danger('error reports an error message')
    await app.details('which can also be enhanced with a details message.')

    await app.start_progress(show_completion=True)
    await asyncio.sleep(5)
    await app.stop_progress()
    await app.details('Longer operation finished.')

    await app.success('success is used to indicate success')

    await app.failure('failure is used to indicate the operation failed')


async def warn_later():
    await asyncio.sleep(0.5)
    await app.update_progress(completion=0.3, message='Some task to be done')
    await asyncio.sleep(0.5)
    await app.update_progress(completion=0.6)
    await asyncio.sleep(0.5)
    await app.update_progress(message='Another task to be done')
    await asyncio.sleep(0.5)
    await app.update_progress(completion=0.9)
    await asyncio.sleep(1)
    await app.warn('Something unexpected happened')


async def main():
    return await asyncio.gather(start(), warn_later())

asyncio.run(main())

License

Copyright 2022 Alexander Metzner.

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

termapp-0.1.2.tar.gz (11.0 kB view details)

Uploaded Source

Built Distribution

termapp-0.1.2-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file termapp-0.1.2.tar.gz.

File metadata

  • Download URL: termapp-0.1.2.tar.gz
  • Upload date:
  • Size: 11.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for termapp-0.1.2.tar.gz
Algorithm Hash digest
SHA256 104b9bbe147e09cea3319d7fd56b1abc0ac84b3335c7c1c6b3c2f2e0075497e2
MD5 9179306b6cfb22b2e2baf8494097614e
BLAKE2b-256 1adb6e6d8ad85aaf329d713d327edfd78939fcc82aee0be7adbdde14f8df86d5

See more details on using hashes here.

File details

Details for the file termapp-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: termapp-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for termapp-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 079ead174d73cb902d47f724da480f693264cf3df640eb99f146de36cad7d5be
MD5 26f3627622da93c25f18411eddb6d557
BLAKE2b-256 ecd57a037d8751f7e4e4166b262248530627cc52e187fba87351ce830a62148b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page