forked from python-semver/python-semver
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix python-semver#59: Implement command line interface
* Extend setup.py with entry_point key and point to semver.main. The script is named "semver" * Introduce 3 new functions: * createparser: creates and returns an argparse.ArgumentParser instance * process: process the CLI arguments and call the requested actions * main: entry point for the application script * Add test cases * sort import lines of semver functions/class with isort tool * sort list of SEMVERFUNCS variable * Extend documentation * Add sphinx-argparse as a doc requirement * Include new cli.rst file which (self)documents the arguments of the semver script with the help of sphinx-argparse * Extend extensions variable in conf.py to be able to use the sphinx-argparse module
- Loading branch information
Showing
7 changed files
with
233 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
CLI | ||
=== | ||
|
||
The library provides also a command line interface. This allows to include | ||
the functionality of semver into shell scripts. | ||
|
||
Using the semver Script | ||
----------------------- | ||
|
||
The script name is :command:`semver` and provides the subcommands ``bump`` | ||
and ``compare``. | ||
|
||
To bump a version, you pass the name of the part (major, minor, patch, prerelease, or | ||
build) and the version string, for example:: | ||
|
||
$ semver bump major 1.2.3 | ||
2.0.0 | ||
$ semver bump minor 1.2.3 | ||
1.3.0 | ||
|
||
If you pass a version string which is not a valid semantical version, you get | ||
an error message:: | ||
|
||
$ semver bump build 1.5 | ||
ERROR 1.5 is not valid SemVer string | ||
|
||
To compare two versions, use the ``compare`` subcommand. The result is | ||
|
||
* ``-1`` if first version is smaller than the second version, | ||
* ``0`` if both are the same, | ||
* ``1`` if the first version is greater than the second version. | ||
|
||
For example:: | ||
|
||
$ semver compare 1.2.3 2.4.0 | ||
|
||
|
||
.. _interface: | ||
|
||
Interface | ||
--------- | ||
|
||
.. argparse:: | ||
:ref: semver.createparser | ||
:prog: semver | ||
.. :path: compare |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ Semver |version| -- Semantic Versioning | |
readme | ||
install | ||
usage | ||
cli | ||
development | ||
api | ||
changelog | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
# requirements file for documentation | ||
sphinx | ||
sphinx_rtd_theme | ||
sphinx-argparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters