Skip to content

Commit

Permalink
Prepare for release 0.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
babab committed Jun 4, 2015
1 parent c32e6a7 commit b472f13
Show file tree
Hide file tree
Showing 8 changed files with 297 additions and 193 deletions.
11 changes: 7 additions & 4 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,21 @@ Change Log
pycommand adheres to `Semantic Versioning <http://semver.org/>`_.


0.3.0 - Development version - UNRELEASED
----------------------------------------
0.3.0 - 2015-06-04
------------------

Added
#####
- Shortcut ``run_and_exit()`` for reading from ``sys.argv[1:]`` and exiting
the interpreter via ``sys.exit(status)``
- Package as wheel distribution to speed up installations
- Add ``man pycommand`` ability, i.e. install mandoc in ``/usr/share/man3/``

Changed
#######
- Add support for getting flags by attribute like ``self.flags.help``.
The default approach for normal dicts like ``self.flags['help']``
remains valid.
- Package as wheel distribution to speed up installations
- Add ``man pycommand`` ability, i.e. install mandoc in ``/usr/share/man3/``


0.2.0 - 2015-05-21
Expand Down
19 changes: 10 additions & 9 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ pycommand 0.3.0

.. image:: https://travis-ci.org/babab/pycommand.svg?branch=master
:target: https://travis-ci.org/babab/pycommand
:alt: Build Status

.. image:: https://readthedocs.org/projects/pycommand/badge/?version=stable
:target: https://readthedocs.org/projects/pycommand/?badge=stable
:alt: Documentation Status

**A clean and simplistic alternative for argparse, optparse and getopt**

Expand All @@ -14,15 +19,11 @@ can create (multiple levels of) subcommands, with the ability to pass
the values of optional arguments of a command object to its subcommand
objects. Supported Python versions are 2.7 and 3.2 and later.

- PyPI: https://pypi.python.org/pypi/pycommand/
- User and API docs: http://pythonhosted.org/pycommand/
- Bitbucket: https://bitbucket.org/babab/pycommand
- Github: https://github.com/babab/pycommand

.. note::

This README reflects the development version. For the latest release
documentation, visit http://pythonhosted.org/pycommand/
- Bitbucket: https://bitbucket.org/babab/pycommand
- PyPI: https://pypi.python.org/pypi/pycommand/
- Documentation (latest stable PyPI version) - http://pythonhosted.org/pycommand/
- Documentation (all versions) - http://pycommand.readthedocs.org


Download and install
Expand All @@ -40,7 +41,7 @@ To work with the current development version, do something like this:
$ git clone git://bitbucket.org/babab/pycommand.git
# cd pycommand
# pip install --upgrade -e .
# pip install -e .
Quick setup from a template
Expand Down
12 changes: 9 additions & 3 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ pycommand 0.3.0

.. image:: https://travis-ci.org/babab/pycommand.svg?branch=master
:target: https://travis-ci.org/babab/pycommand
:alt: Build Status

.. image:: https://readthedocs.org/projects/pycommand/badge/?version=stable
:target: https://readthedocs.org/projects/pycommand/?badge=stable
:alt: Documentation Status

.. toctree::
:maxdepth: 2
Expand All @@ -17,10 +22,11 @@ can create (multiple levels of) subcommands, with the ability to pass
the values of optional arguments of a command object to its subcommand
objects. Supported Python versions are 2.7 and 3.2 and later.

- PyPI: https://pypi.python.org/pypi/pycommand/
- User and API docs: http://pythonhosted.org/pycommand/
- Github: https://github.com/babab/pycommand
- Bitbucket: https://bitbucket.org/babab/pycommand
- PyPI: https://pypi.python.org/pypi/pycommand/
- Documentation (latest stable PyPI version) - http://pythonhosted.org/pycommand/
- Documentation (all versions) - http://pycommand.readthedocs.org


Download and install
Expand All @@ -38,7 +44,7 @@ To work with the current development version, do something like this:
$ git clone git://bitbucket.org/babab/pycommand.git
# cd pycommand
# pip install --upgrade -e .
# pip install -e .
Quick setup from a template
Expand Down
105 changes: 70 additions & 35 deletions pycommand.3
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.\" Man page generated from reStructuredText.
.
.TH "PYCOMMAND" "3" "May 21, 2015" "0.2.0" "pycommand"
.TH "PYCOMMAND" "3" "June 04, 2015" "0.3.0" "pycommand"
.SH NAME
pycommand \- pycommand Documentation
.
Expand Down Expand Up @@ -30,7 +30,7 @@ level margin: \\n[rst2man-indent\\n[rst2man-indent-level]]
.\" new: \\n[rst2man-indent\\n[rst2man-indent-level]]
.in \\n[rst2man-indent\\n[rst2man-indent-level]]u
..
\fI\%\fP
\fI\%Build Status\fP\fI\%Documentation Status\fP
.sp
\fBA clean and simplistic alternative for argparse, optparse and getopt\fP
.sp
Expand All @@ -41,6 +41,18 @@ code. It has support for subcommands and also nesting commands, so you
can create (multiple levels of) subcommands, with the ability to pass
the values of optional arguments of a command object to its subcommand
objects. Supported Python versions are 2.7 and 3.2 and later.
.INDENT 0.0
.IP \(bu 2
Github: \fI\%https://github.com/babab/pycommand\fP
.IP \(bu 2
Bitbucket: \fI\%https://bitbucket.org/babab/pycommand\fP
.IP \(bu 2
PyPI: \fI\%https://pypi.python.org/pypi/pycommand/\fP
.IP \(bu 2
Documentation (latest stable PyPI version) \- \fI\%http://pythonhosted.org/pycommand/\fP
.IP \(bu 2
Documentation (all versions) \- \fI\%http://pycommand.readthedocs.org\fP
.UNINDENT
.SH DOWNLOAD AND INSTALL
.sp
If you have pip installed, you can just:
Expand All @@ -63,7 +75,7 @@ To work with the current development version, do something like this:
.ft C
$ git clone git://bitbucket.org/babab/pycommand.git
# cd pycommand
# python setup.py install
# pip install \-e .
.ft P
.fi
.UNINDENT
Expand Down Expand Up @@ -167,33 +179,38 @@ class BasicExampleCommand(pycommand.CommandBase):
error \-\- Thrown by GetoptError when parsing illegal
arguments

flags \-\- OrderedDict of parsed options and corresponding
flags \-\- Object/dict of parsed options and corresponding
arguments, if any.

usage \-\- String with usage information. The string
is compiled using the values found for \(gausagestr\(ga,
\(gadescription\(ga, \(gaoptionList\(ga and \(gausageTextExtra\(ga.

\(aq\(aq\(aq
if self.flags[\(aqhelp\(aq]:
if self.flags.help:
print(self.usage)
return
elif self.flags[\(aqversion\(aq]:
return 0
elif self.flags.version:
print(\(aqPython version \(aq + sys.version.split()[0])
return
elif self.flags[\(aqfile\(aq]:
print(\(aqfilename = \(aq + self.flags[\(aqfile\(aq])
return
return 0
elif self.flags.file:
print(\(aqfilename = \(aq + self.flags.file)
return 0

print(\(aqProgram completed. Try adding "\-\-help"\(aq)

if __name__ == \(aq__main__\(aq:
cmd = BasicExampleCommand(sys.argv[1:])
if cmd.error:
print(\(aqerror: {0}\(aq.format(cmd.error))
sys.exit(1)
else:
sys.exit(cmd.run())
# Shortcut for reading from sys.argv[1:] and sys.exit(status)
pycommand.run_and_exit(BasicExampleCommand)

# The shortcut is equivalent to the following:

# cmd = BasicExampleCommand(sys.argv[1:])
# if cmd.error:
# print(\(aqerror: {0}\(aq.format(cmd.error))
# sys.exit(1)
# else:
# sys.exit(cmd.run())
.ft P
.fi
.UNINDENT
Expand Down Expand Up @@ -290,7 +307,7 @@ class FullExampleCommand(pycommand.CommandBase):
# :Parameters:
# \- \(gaoptionName\(ga: String. Name of option
# \- \(gavalue\(ga: Mixed. Value of parsed flag\(ga
cmd.registerParentFlag(\(aqfile\(aq, self.flags[\(aqfile\(aq])
cmd.registerParentFlag(\(aqfile\(aq, self.flags.file)

if cmd.error:
print(\(aqfull\-example {cmd}: {error}\(aq
Expand All @@ -301,12 +318,8 @@ class FullExampleCommand(pycommand.CommandBase):


if __name__ == \(aq__main__\(aq:
cmd = FullExampleCommand(sys.argv[1:])
if cmd.error:
print(\(aqerror: {0}\(aq.format(cmd.error))
sys.exit(1)
else:
sys.exit(cmd.run())
# Shortcut for reading from sys.argv[1:] and sys.exit(status)
pycommand.run_and_exit(FullExampleCommand)
.ft P
.fi
.UNINDENT
Expand Down Expand Up @@ -357,7 +370,7 @@ error: command doesnotexist does not exist
A clean and simplistic alternative for argparse, optparse and getopt
.INDENT 0.0
.TP
.B class pycommand.CommandBase(argv=[\(aq\-b\(aq, \(aqhtml\(aq, \(aq\-d\(aq, \(aq_build/doctrees\(aq, \(aq.\(aq, \(aq_build/html\(aq])
.B class pycommand.CommandBase(argv=[\(aq\-b\(aq, \(aqman\(aq, \(aq\-d\(aq, \(aq_build/doctrees\(aq, \(aq.\(aq, \(aq_build/man\(aq])
Base class for (sub)commands
.INDENT 7.0
.TP
Expand Down Expand Up @@ -452,6 +465,21 @@ String. Optional extra usage information
String. Usage synopsis
.UNINDENT
.UNINDENT
.INDENT 0.0
.TP
.B exception pycommand.OptionError
Options/Flags AttributeError exception
.UNINDENT
.INDENT 0.0
.TP
.B class pycommand.dictobject
A dictionary with getters by attribute, used for flags
.UNINDENT
.INDENT 0.0
.TP
.B pycommand.run_and_exit(command_class)
A shortcut for reading from sys.argv and exiting the interpreter
.UNINDENT
.SH WHY WAS IT CREATED?
.sp
When parsing command line program arguments, I sometimes work with
Expand All @@ -463,20 +491,27 @@ The \fICommandBase\fP class was originally written for \fIDisPass\fP,
which is a password manager/generator, as a means to easily define new
subcommands and have auto\-generated usage messages. Because I want to
have this in other projects I\(aqve decided to put it in the cheeseshop.
.SH CONTRIBUTING
.SH CHANGE LOG
.sp
You can use Bitbucket or Github for discussing code, reporting bugs and
sending pull\-requests.
pycommand adheres to \fI\%Semantic Versioning\fP\&.
.SS 0.3.0 \- 2015\-06\-04
.SS Added
.INDENT 0.0
.IP \(bu 2
Bitbucket: \fI\%https://bitbucket.org/babab/pycommand\fP
Shortcut \fBrun_and_exit()\fP for reading from \fBsys.argv[1:]\fP and exiting
the interpreter via \fBsys.exit(status)\fP
.IP \(bu 2
Github: \fI\%https://github.com/babab/pycommand\fP
Package as wheel distribution to speed up installations
.IP \(bu 2
Add \fBman pycommand\fP ability, i.e. install mandoc in \fB/usr/share/man3/\fP
.UNINDENT
.SS Changed
.INDENT 0.0
.IP \(bu 2
Add support for getting flags by attribute like \fBself.flags.help\fP\&.
The default approach for normal dicts like \fBself.flags[\(aqhelp\(aq]\fP
remains valid.
.UNINDENT
.SH CHANGE LOG
.sp
All notable changes to pycommand will be documented here. The project
adheres to \fI\%Semantic Versioning\fP\&.
.SS 0.2.0 \- 2015\-05\-21
.SS Added
.INDENT 0.0
Expand Down Expand Up @@ -519,6 +554,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.SH AUTHOR
Benjamin Althues
.SH COPYRIGHT
2013, Benjamin Althues
2013-2015, Benjamin Althues
.\" Generated by docutils manpage writer.
.
Loading

0 comments on commit b472f13

Please sign in to comment.