LittleJack has asked for the wisdom of the Perl Monks concerning the following question:

From the Tutorial:

dancer2 -a MyApp

Result:

Unknown option: a Usage: dancer2 [-h] -h --help --man [subcommand] at /usr/local/share/p +erl/5.18.2/CLI/Osprey/Descriptive/Usage.pm line 328.

Shakes, as the kids say, my head. Literally the first thing you do in the Tutorial (for this version, I checked!) and I'm already stuck. And the error message is pretty ugly too.

Did I miss something?

Replies are listed 'Best First'.
Re: Starting out with Dancer and falling at the first hurdle
by stevieb (Canon) on Mar 31, 2022 at 02:41 UTC

    Very cryptic and bizarre. Although I've always been pleased with the Dancer2 documentation, I don't believe I've ever used that functionality before. I don't like how odd the 'help' messages are.

    Here's what I've got on v0.301004:

    steve@maezi ~/scratch >dancer2 -a Unknown option: a Usage: dancer2 [-h] -h --help --man [subcommand] at /Users/steve/perl5 +/perlbrew/perls/perl-5.32.1/lib/site_perl/5.32.1/CLI/Osprey/Descripti +ve/Usage.pm line 329. steve@maezi ~/scratch >dancer2 -h Usage: dancer2 [-h] [-h] [--help] [--man] [subcommand] Subcommands available: gen | version -h show a short help message --help show a long help message --man show the manual steve@maezi ~/scratch >dancer2 gen application is missing Usage: dancer2 gen [-acdghoprsx] [-p|--path directory] [-a|--applicati +on appname] [-d|--directory directory] [-c|--docker] [-g|--git] [-x|--no-check] [-o|--overwrite] [-r|--remo +te URI] [-s|--skel directory] [-h] [--help] [--man]

    ...ahh, looks like we may be getting somewhere!

    steve@maezi ~/scratch >dancer2 gen --help Usage: dancer2 gen [-acdghoprsx] [-p|--path directory] [-a|--applicati +on appname] [-d|--directory directory] [-c|--docker] [-g|--git] [-x|--no-check] [-o|--overwrite] [-r|--remo +te URI] [-s|--skel directory] [-h] [--help] [--man] -p|--path directory application path (default: current directory +) -a|--application appname application name -d|--directory directory application directory (default: same as appl +ication name) -c|--docker create a dockerfile (container definition) -g|--git init git repository -x|--no-check don't check latest Dancer2 version (default: + check - requires internet) -o|--overwrite overwrite existing files -r|--remote URI URI for git repository (implies -g) -s|--skel directory skeleton directory -h show a short help message --help show a long help message --man show the manual

    Let's try it:

    steve@maezi ~/scratch >dancer2 gen -a AppName The latest stable Dancer2 release is 0.400000. You are currently using + 0.301004. Please check https://metacpan.org/pod/Dancer2/ for updates. + AppName + AppName/cpanfile + AppName/MANIFEST.SKIP + AppName/config.yml + AppName/Makefile.PL + AppName/.dancer + AppName/bin + AppName/bin/app.psgi + AppName/environments + AppName/environments/production.yml + AppName/environments/development.yml + AppName/t + AppName/t/001_base.t + AppName/t/002_index_route.t + AppName/public + AppName/public/favicon.ico + AppName/public/dispatch.cgi + AppName/public/500.html + AppName/public/404.html + AppName/public/dispatch.fcgi + AppName/lib + AppName/lib/AppName.pm + AppName/views + AppName/views/index.tt + AppName/public/css + AppName/public/css/style.css + AppName/public/css/error.css + AppName/public/images + AppName/public/images/perldancer-bg.jpg + AppName/public/images/perldancer.jpg + AppName/public/javascripts + AppName/public/javascripts/jquery.js + AppName/views/layouts + AppName/views/layouts/main.tt Your new application is ready! To run it: cd AppName plackup bin/app.psgi To access your application, point your browser to http://localhost:500 +0 If you need community assistance, the following resources are availabl +e: - Dancer website: https://perldancer.org - Twitter: https://twitter.com/PerlDancer/ - GitHub: https://github.com/PerlDancer/Dancer2/ - Mailing list: https://lists.perldancer.org/mailman/listinfo/dancer-u +sers - IRC: irc.perl.org#dancer Happy Dancing!

    So it appears as though the tutorial is missing the gen keyword/command. If I get a chance tomorrow morning, I'll create a pull request with the fix (unless someone beats me to it).

        That's great and it's nice to see a well-organised repo and a responsive team.

        Not to take advantage of you, but what about the fact that the 'correct usage' message apparently comes from a die() in CLI::Osprey::Descriptive::Usage … whatever that is. It seems like a module with that name should be improving the user experience, not making it uglier.

      Thanks for your reply and for following up.

      I got very busy yesterday and didn't have a chance to reply—I eventually figured out the gen trick myself and have successfully created my first Dancer app.