NOTE:
This project is abandoned and unsupported. Use argparse or docopt instead.
cmdstyle
cmdstyle is a library for creating command line interfaces using the command style used by programs like svn or hg.
Example
Sample File:
#! /usr/bin/env python3.2
import sys
import cmdstyle
class HelloCommand(cmdstyle.Command):
'Print a greeting'
name = cmdstyle.PosParam()
shout = cmdstyle.Flag(
description='Print the greeting in upper case',
shortname='')
exclamations = cmdstyle.Option(
description='The number of exclamation marks used to end the '
'greeting',
default=1)
def __call__(self):
#Note that the library does not do validations
exclamations_int = int(self.exclamations)
greeting = 'Hello'
if self.name:
greeting += ', ' + self.name
if self.shout:
greeting = greeting.upper()
greeting += exclamations_int * '!'
print(greeting)
class ByeCommand(cmdstyle.Command):
'Print bye'
def __call__(self):
print('Bye!')
program = cmdstyle.Program(
'sample.py',
'Sample Program',
'Just a sample program',
'http://...')
program.register(HelloCommand())
program.register(ByeCommand())
if __name__ == '__main__':
program.run(sys.argv)
Sample Being Used:
$ ./sample.py Use `sample.py help` for usage. $ ./sample.py help usage: sample.py <command> [options] [args] Sample Program Just a sample program Available commands: bye hello Use `sample.py help <command>` for help on a specific command. See http://... for additional information. $ ./sample.py help hello hello: Print a greeting usage: hello NAME Options: --shout Print the greeting in upper case -e --exclamations ARG The number of exclamation marks used to end the greeting $ ./sample.py hello Hello! $ ./sample.py hello --shout --exclamations 3 HELLO!!!
Metadata
Release files for cmdstyle 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| cmdstyle-0.1.0.tar.gz | 10.2 kB | Without provenance | Details |
Release files / cmdstyle-0.1.0.tar.gz
| Download URL | cmdstyle-0.1.0.tar.gz |
|---|---|
| Size | 10.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
67a2ceb2e88a858fa3d19c13c5a42e7976bdf94cb81198bc9c0ee3fdad8433e9
|
|
BLAKE2b-256 checksum How to use checksums |
4c214319107b4469283b83b3ebdec2eb1b1e7a9004767368df0574aa7803faff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for cmdstyle 0.1.0
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.