Skip to main content

Terminal UI to generate config file without learning the documentary.. Read more: https://github.com/ClericPy/ask4args.

Project description

baba

Terminal UI to generate config file without learning the documentary.

Inspired by python-fire, and it maybe need a human-friendly interactive UI.

from ask4args.core import Ask4Args
from typing import List, Dict


def test_normal_function(a: int, b: int = 2,
                         **args_dict: Dict[str, int]) -> str:
    # first a value=1, args_dict['c']=3, others use default.
    # press 1, enter, enter, enter, c, enter, 3, enter, enter
    assert a == 1
    assert b == 2
    assert args_dict['c'] == 3
    return 'success'


def test_keyword_only_function(a: float,
                               b: int = 2,
                               *,
                               c: bool = False,
                               d: str = 'string',
                               **args_dict: Dict[str, int]):
    """Read the doc, and test kw-only args.

    :param a: one float num
    :type a: float
    :param b: one int num, defaults to 4
    :type b: int, optional
    :param c: boolen arg, defaults to False
    :type c: bool, optional
    :param d: string arg, defaults to 'string'
    :type d: str, optional
    :return: return the args_dict
    :rtype: Dict[str, list]
    """
    # press y, 1.1, enter, enter, enter, enter, enter, e, enter, 3, enter, enter
    assert a == 1.1
    assert b == 2
    assert c is False
    assert d == 'string'
    assert args_dict['e'] == 3
    return args_dict


class TestClass(object):

    def test_method(self, a: str, b: int = 1):
        assert a == ''
        assert b == 1

    @classmethod
    def test_class_method(cls, a: str, b: int = 1):
        assert a == ''
        assert b == 1


def test_checkboxes(a: List[int]):
    assert a == [1, 2, 3]


def test_choices(a: int):
    assert a == 1


def test_defaults(a: int):
    assert a == 1


if __name__ == "__main__":
    # Ask4Args(test_normal_function).run()
    # Ask4Args(test_keyword_only_function).run()
    # Ask4Args(TestClass().test_method).run()
    # Ask4Args(TestClass().test_class_method).run()
    # Ask4Args(test_checkboxes, checkboxes={'a': [1, 2, 3, 4, 5]}).run()
    # Ask4Args(test_choices, choices={'a': [1, 2, 3, 4, 5]}).run()
    # Ask4Args(test_defaults, defaults={'a': 1}).run()
    pass

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ask4args-0.0.1-py3-none-any.whl (7.9 kB view details)

Uploaded Python 3

File details

Details for the file ask4args-0.0.1-py3-none-any.whl.

File metadata

  • Download URL: ask4args-0.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.20.1 setuptools/41.0.1 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1

File hashes

Hashes for ask4args-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 659fc7222796c94d30539d731417cb246fecabe0a60d28c6df4cc741bccf96e3
MD5 61e33809e70c5b89a49c9d822722fb95
BLAKE2b-256 877d2d8ddf7b06b6bbc243beb9f42116eebc20fbd27615890d4ececceb7f76de

See more details on using hashes here.

Supported by

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