MouseX...Dashes(3pm)

πŸ“¦
version 0.38 Β· 4 versions
, in debian bookworm, ubuntu jammy, ubuntu noble

NAME ✨

Hey bestie, welcome to MouseX::Getopt::Dashes(3pm) β€” the header shortens it to MouseX...Dashes(3pm), and it lives in the User Contributed Perl Documentation. It's giving convert underscores in attribute names to dashes πŸ’… no cap.

SYNOPSIS πŸŽ€

Okay so here's the whole vibe:

         package My::App;
         use Mouse;
         with 'MouseX::Getopt::Dashes';

         # Will be called as --some-thingy, not --some_thingy
         has 'some_thingy' => (
             is      => 'ro',
             isa     => 'Str',
             default => 'foo'
         );

         # Will be called as --another_thingy, not --another-thingy
         has 'another_thingy' => (
             traits   => [ 'Getopt' ],
             cmd_flag => 'another_thingy'
             is       => 'ro',
             isa      => 'Str',
             default  => 'foo'
         );

         # use as MouseX::Getopt

DESCRIPTION πŸ¦‹

Okay so this is a version of MouseX::Getopt that converts underscores in attribute names to dashes when it's generating command line flags. So like, some_thingy can show up as --some-thingy instead of --some_thingy, and that's literally the whole point. πŸ’…

You can selectively disable this on a per-attribute basis by supplying a cmd_flag argument with the command flag you'd like for a given attribute. And bestie, listen: no underscore to dash replacement will be done on the cmd_flag. So if you set it, it stays exactly how you wrote it. periodt.

That's the little caveat: the cmd_flag itself does not get the underscore-to-dash glow-up. πŸ™ˆ

mwah πŸ’‹ this page came from the User Contributed Perl Documentation, it's running on perl v5.32.1, and it's dated 2021-09-16. bye bestie, go slay those flags πŸ«ΆπŸ’–

πŸ“¦ where this page comes from