Add version option to display app version #26
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request primarily introduces a versioning feature to the
purl
command-line tool, which is a versatile text processing tool. The changes include the addition of a-version
flag to display the version of the tool, the inclusion of build information in the version output, and updates to the build process to incorporate versioning information. The changes also include the necessary modifications to the test suite to accommodate the new versioning feature.Here are the most important changes:
Versioning feature:
cli/cli.go
: Introduced aversion
function that retrieves the build information if available, otherwise defaults to "(devel)". Added aVersion
variable and anappVersion
field to theCLI
struct. Modified theNewCLI
function to initializeappVersion
with the version information. Added a condition in theRun
method to check for the-version
flag and print the version information if the flag is set. [1] [2] [3] [4]cli/cli.go
: Updated theparseFlags
function to include a-version
flag. Modified the usage message to include the version information.README.md
: Updated the documentation to include the-version
flag.Build process:
Makefile
: Modified thebin/purl
target to includego.mod
andgo.sum
as dependencies and to include versioning information in the build flags.Test suite:
cli/cli_test.go
: Added a test case for the-version
flag.