Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

particle (3326)

  (email not shown publicly)

Journal of particle (3326)

Saturday January 05, 2008
07:49 PM

[perl6]: implement usage message (-h, --help)

[ #35302 ]

my last entry ( described how i added support to the Parrot Compiler Toolkit to support a '--help' command line option for compilers. my next commit enables this option for perl6.

view the patch here:

since i laid the foundation for implementing usage messages in PCT, it was easy to customize it for perl6. i'll walk through it briefly.

the first difference is in the 'onload' subroutine, which is run when the perl6 bytecode is loaded by parrot. after a new HLLCompiler object has been created, i create a new String PMC using a parrot heredoc containing the help text for the command line options specific to perl6. since @larry hasn't written S19, the synopsis on the perl 6 command line interface, these options are likely to change.

the second difference implements the 'usage' method that HLLCompiler calls when the '-h' or '--help' option is passed. if an argument is not passed for the optional parameter 'name', it is defaulted to 'perl6'. a usage message is printed containing the contents of 'name' and the '$usage' attribute of the HLLCompiler object as set above, and the program exits.

based on the techniques i've used to implement '--help', it should be straightforward to implement similar command line options for the perl6 compiler.

related links:

perl 6 synopses:

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • Hi,

    Firstly, thanks very much for your last couple of diary entries, they've been helpful getting me started learning a bit more about parrot and PCT.

    Looking at your second change though, I'm not sure that it's working the way that it's supposed to...

    Does Perl6::Compiler actually sub-class HLLCompiler? It doesn't appear to, since the 'usage' method that you define in perl6.pir never seems to be called. It seems to be using the version defined in HLLCompiler instead, which presumably means that the on