Differences between revisions 3 and 9 (spanning 6 versions)
Revision 3 as of 2010-07-27 13:45:42
Size: 139
Editor: 134
Comment: Added a link to a very simple command line "parsing" snippet. Feel free to remove if it is inappropriate
Revision 9 as of 2021-02-07 21:56:17
Size: 2249
Editor: IwanAucamp
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
OptParse, [[getopt]], ConfigParser,
... fancy_getopt (?), [[gflags]], [[http://code.google.com/p/py-command-line-options | cmdopts]] ...
#pragma section-numbers on
#pragma heading Option Parsing

<<TableOfContents()>>

## The content of this page is in Public Domain

== Builtin Tools ==

Overview of Python modules for option parsing

 * [[http://docs.python.org/2/library/getopt.html|getopt]] - procedural interface in stdlib for refugees from the C camp
 * [[OptParse|optparse]] - stdlib name for Optik, a revolutionary API for option parsing in Python 2.x
 * [[http://docs.python.org/3/library/argparse.html|argparse]] - `optparse` pumped up for Python 3.x (and included in Python 2.7)

== External tools ==


||<style="width: 20%;"> '''Name''' ||<style="width: 10%;"> '''[[https://hugovk.github.io/top-pypi-packages/|365 Day Ranking]]''' ||<style="width: 20%;"> '''Latest Release''' || '''Description''' ||
|| [[https://github.com/abseil/abseil-py|Abseil Python Common Libraries]]<<BR>>(pypi: [[https://pypi.org/project/absl-py/|absl-py]]) || 103 || 0.11.0 (2020-10-27) || gflags merged into this ||
|| [[https://palletsprojects.com/p/click/|Click]]<<BR>>(pypi: [[https://pypi.org/project/click/|click]]) || 34 || 7.1.2 (2020-04-27) || create beautiful command line interfaces in a composable way with as little code as necessary ||
|| [[https://typer.tiangolo.com/|Typer]]<<BR>>(pypi: [[https://pypi.org/project/typer/|typer]]) || 2321 || 0.3.2 (2020-08-16) || build great CLIs. Easy to code. Based on Python type hints. ||




More:

 * [[http://code.google.com/p/py-command-line-options | cmdopts]] - ...
 * [[http://docopt.org/|docopt]] - no API calls needed, it's awesome!


== The goal of option parsing ==

The option parsing goal can be split in two parts:

  1. identifying the command user needs to execute
  2. changing configuration for the program

For the first part, it will be good if option parsing library could handle 'subcommands'. It is known that 'argparse' can do this and 'optparse' cannot. 'docopt' probably handles this transparently.

For the second thing there should be some strategy to choose how (and which) options are merged into configuration to make the process of program configuration easy for the user and occasional patch contributors.

== See Also ==


 * ConfigParser
 * CommandlineTools

1. Builtin Tools

Overview of Python modules for option parsing

  • getopt - procedural interface in stdlib for refugees from the C camp

  • optparse - stdlib name for Optik, a revolutionary API for option parsing in Python 2.x

  • argparse - optparse pumped up for Python 3.x (and included in Python 2.7)

2. External tools

Name

365 Day Ranking

Latest Release

Description

Abseil Python Common Libraries
(pypi: absl-py)

103

0.11.0 (2020-10-27)

gflags merged into this

Click
(pypi: click)

34

7.1.2 (2020-04-27)

create beautiful command line interfaces in a composable way with as little code as necessary

Typer
(pypi: typer)

2321

0.3.2 (2020-08-16)

build great CLIs. Easy to code. Based on Python type hints.

More:

3. The goal of option parsing

The option parsing goal can be split in two parts:

  1. identifying the command user needs to execute
  2. changing configuration for the program

For the first part, it will be good if option parsing library could handle 'subcommands'. It is known that 'argparse' can do this and 'optparse' cannot. 'docopt' probably handles this transparently.

For the second thing there should be some strategy to choose how (and which) options are merged into configuration to make the process of program configuration easy for the user and occasional patch contributors.

4. See Also

OptionParsing (last edited 2021-02-07 21:56:17 by IwanAucamp)

Unable to edit the page? See the FrontPage for instructions.