Skip to main content

$ pip install clop

$ pydoc clop

$ python -m clop # Run the demo

clop provides minimal command line option specification and processing.

When your command line processing requires the power of a king on a real horse, use argparse in the standard python library.

When banging two coconut halves together on a stick pony is good enough, use clop.

A single class to specify command line options, process a command line against those options, and make the processed results available as a dict. Also provides a simple help string for each option and the calling program.

  """Your program."""

  from clop import Clop

  ...

  # Make a Clop object.
  clp = Clop()

  # Specify acceptable options and their arguments.
  clp.addOptionDef(letter = 'k',
      required = True,
      numArgs = 3,
      help = 'Help for option k')

  ...

  # optArgs is a dictionary of options and arguments
  optArgs = clp.processCmdLine(sys.argv[1:])

  ...

  # Print the help string when you need it.
  helpStr = clp.helpString('clop:\nShort demo of the clop module.')
  print(helpStr)

clop:
Short demo of the clop module.

REQUIRED OPTIONS:
k: Help for option k
  Allowed arguments: Exactly 3
m: Help for option m
  Allowed arguments: Exactly 1
n: Help for option n
  Allowed arguments: 0 or more

OPTIONAL OPTIONS:
o: Help for option o
  Allowed arguments: Exactly 0
p: Help for option p
  Allowed arguments: Exactly 1
q: Help for option q
  Allowed arguments: 0 or more

clop includes a demo in its main() function:

$ python -m clop -k 1 2 3 -m one-two -n 3 4 5 -o -p 1 -q "one two"

{'k': ['1', '2', '3'], 'm': ['one-two'], 'o': [], 'n': ['3', '4', '5'], 'q': ['one two'], 'p': ['1']}

  • Options are a dash and a single letter: -o

  • An option can be followed by zero or more arguments.

  • An option can only be specified with its letter (-o). No –long options.

  • An option letter can be any “letter” where letter.isalpha() is True.

  • Options cannot be composed. Only one character per dash, not -olmp.

  • Options can appear in any order on the command line.

  • Options and arguments on the command line are strings. The calling program does any type and value checking and conversion of arguments after clop’s command line processing. Clop makes no judgments other than allowed options and arguments.

More clop features are unlikely. If you need more, argparse is excellent, and comes with a real horse.

Release files for clop 0.2.8

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

Source distribution (sdist)

Source distribution for clop 0.2.8
File Size Uploaded
clop-0.2.8.tar.gz 5.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for clop 0.2.8
File Interpreter ABI Platform
clop-0.2.8-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 12.6 kB

Release files / clop-0.2.8.tar.gz

Download URL clop-0.2.8.tar.gz
Size 5.0 kB
Tags Source
SHA-256 checksum
How to use checksums
052462315ee31626401cb940f54eb0e097e57dd82800c7583a7ed5479f17410b
BLAKE2b-256 checksum
How to use checksums
d4b2b0cbc73b2937fdae1e048adcd52b97b4b0ab41d2692bff9918858ec835f3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release files / clop-0.2.8-py2.py3-none-any.whl

Download URL clop-0.2.8-py2.py3-none-any.whl
Size 7.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
8dfef36497191ca7787e3a19e36cbed782ab79c16e1e90d103e3720d603f66b9
BLAKE2b-256 checksum
How to use checksums
7743250758223795d6b01ce7fec88c20ca0b172febbb0ea1dbf19cd6ed2ae7f9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Release history Release notifications | RSS feed

This release

0.2.8 This release

2 release files

0.2.7

2 release files

0.2.6

1 release file

0.2.5

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1

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