Skip to content

Add --help and --version to plerdall and plerdwatcher - #78

Open
iamllcoolray wants to merge 1 commit into
jmacdotorg:masterfrom
iamllcoolray:cli-help-and-version
Open

Add --help and --version to plerdall and plerdwatcher#78
iamllcoolray wants to merge 1 commit into
jmacdotorg:masterfrom
iamllcoolray:cli-help-and-version

Conversation

@iamllcoolray

Copy link
Copy Markdown

Summary

Adds --help and --version flags to both CLI scripts, using Getopt::Long's
parse-failure path and Pod::Usage for consistent, informative output instead
of the previous silent/confusing failure modes.

  • --version prints <script> is part of Plerd $Plerd::VERSION and exits 0.
    lib/Plerd.pm already declares our $VERSION, so this just surfaces it.
  • --help runs pod2usage(-verbose => 1), printing the script's SYNOPSIS
    and OPTIONS sections (already documented in POD) and exits 0.
  • A failed option parse (e.g. an unrecognized flag) now runs
    pod2usage(-verbose => 0, -exitval => 2) instead of falling through to an
    unrelated "can't find config file" error.
  • Both new options are handled immediately after GetOptions, before any
    config file resolution, so --help/--version work with no config
    present.
  • Also fixes a pre-existing copy-paste bug in plerdwatcher's POD, where the
    --config example referenced bin/plerdall instead of bin/plerdwatcher.

Testing

Added t/cli_options.t, following the system() + Capture::Tiny pattern
used in t/init.t, covering both scripts:

  • --version exits 0, output includes the version string, no stderr
  • --help exits 0, output includes the program name and documents --config, no stderr
  • an unrecognized option exits non-zero

Closes #47, #48

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

plerdall --version should be a thing

1 participant