Skip to main content

A library to quickly build monolithic commandline tools.

Project description

Clank
=====
A library to quickly build monolithic commandline tools.

Standard Example
----------------
This creates a tool with a `hello` command which prints "Hello, world!":

from clank import Command, HelpCommand, Manager, UsageCommand

```python
class HelloCommand(Command):
"""Say hello."""
name = 'hello'

def run(self, args):
print("Hello, world!")

if __name__ == '__main__':
Manager([HelloCommand, HelpCommand, UsageCommand]).run()
```

Argument Example
----------------
The `ArgumentCommand` class uses `argparse` to parse commandline arguments.
This code reimplments the `HelloCommand` class to accept a name as an option:

```python
from clank import ArgumentCommand, HelpCommand, Manager, UsageCommand

class HelloCommand(ArgumentCommand):
"""Say hello."""
name = 'hello'

def add_arguments(self):
self.argparser.add_argument(
'-n', '--name', dest='name', nargs=1, default='world',
help="The name to run the app in.")

def run(self, args):
self.parse_args(args)
print("Hello, {}!".format(self.options.name))

if __name__ == '__main__':
Manager([HelloCommand, HelpCommand, UsageCommand]).run()
```

License
-------
Copyright (c) 2014 Ryan Bourgeois. This project and all of its contents is
licensed under the BSD-derived license as found in the included [LICENSE][1]
file.

[1]: https://github.com/BlueDragonX/clank/blob/master/LICENSE "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

clank-0.1.2.tar.gz (5.1 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: clank-0.1.2.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for clank-0.1.2.tar.gz
Algorithm Hash digest
SHA256 45d896ee2aa6dc094859f5371745d7819b0663c359179d0ce51607d472a61d7e
MD5 41e18db683ab7ae61d986614e756972c
BLAKE2b-256 659fbc22223c3c245ce9ca1658996e610621343b9529267c4940a26dcf2c150d

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