Skip to main content

Install

  • pip install obj2cli

Usage(single)

import sys
import obj2cli


class A:
    def __init__(self, arg1, arg2):
        self.a = arg1
        self.b = arg2

    def call1(self, c, d=None):
        print("hello {} c={}, d={}".format(self.__dict__, c, d))


if __name__ == "__main__":
    obj2cli.main_single(A, A, sys.argv[1:])
# python cmd.py --help
usage: A [-h] [--arg1 str] [--arg2 str] {call1} ...

Initialize self. See help(type(self)) for accurate signature.

positional arguments:
  {call1}
    call1

optional arguments:
  -h, --help  show this help message and exit
  --arg1 str
  --arg2 str

# python cmd.py call1 --help
usage: A call1 [-h] [-c str] [-d str]

optional arguments:
  -h, --help  show this help message and exit
  -c str
  -d str

# python cmd.py --arg1 123 --arg2 345 call1 -c hello -d world
hello {'a': '123', 'b': '345'} c=hello, d=world

Usage(multi)

import sys
import obj2cli


class A:
    def __init__(self, a, b):
        self.a = a
        self.b = b

    def call1(self, c, d):
        print("hello {}: {}, c={}, d={}".format(self.__class__.__name__, self.__dict__, c, d))


class B(A):
    pass


if __name__ == "__main__":
    obj2cli.main_cls({A: A, B: B}, sys.argv[1:])

Usage(cli)

# obj2cli --module os.path --function basename -- --help
usage: basename [-h] [-p str]

Returns the final component of a pathname

optional arguments:
  -h, --help  show this help message and exit
  -p str

# obj2cli --module os.path --function basename -- -p /usr/bin/ls
ls

# obj2cli --module logging --function warning --positional -- --help
usage: warning [-h] str [str [str ...]]

Log a message with severity 'WARNING' on the root logger. If the logger has no
handlers, call basicConfig() to add a console handler with a pre-defined format.

positional arguments:
  str
  str

optional arguments:
  -h, --help  show this help message and exit
# obj2cli --module logging --function warning --positional -- "hello %s" "world"
2020-01-04 23:16:05,264 WARNING hello world

Links

Metadata

Release files for obj2cli 0.0.4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for obj2cli 0.0.4
File Interpreter ABI Platform Actions
obj2cli-0.0.4-py3-none-any.whl Python 3 none any Details for obj2cli-0.0.4-py3-none-any.whl

Release files / obj2cli-0.0.4-py3-none-any.whl

Download URL obj2cli-0.0.4-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
792332f0d3ec4532f6b2ce6ead7c8fb0573d69d9c7d36087d0bcaa5d999235ac
BLAKE2b-256 checksum
How to use checksums
c90463fee3f806da2c0406b68a621e7aff5525a4175c0f3718fc1f9f5d30999d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

Security for obj2cli 0.0.4

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page