Help language development. Donate to The Perl Foundation

Qt::QtWidgets cpan:YGUILLEMO last updated on 2021-08-28

#!/usr/bin/env raku

# This file has been automatically generated by RaQt_maker V0.0.5.
# To modify and regenerate it, see the source code available here: 

sub USAGE ()
    my $ver = "Qt::QtWidgets version 0.0.5";

    print qq:to/END/; 
        {$*PROGRAM-NAME} delivered with $ver
        Print the list of "use" instructions related to Qt::Widgets
        needed by the Raku script whose file name is specified.
        Usage: {$*PROGRAM-NAME} <file name>
    exit 1;

multi sub MAIN(Str $fileName)

    my constant START = "use Qt::QtWidgets::";
    my constant END = ";\n";
#     my constant EXCLUDED
#         = set < QtWidgets QtSlot QtSignal QtSigsloty QtObject >;
    my constant CLASSES = set (

    # Does the file exist and be readable ?
    if $fileName.IO !~~ :f & :r {
        say "Can't read $fileName";
        exit 1;
    # Read the file
    my Str $code = slurp $fileName;
    # Remove all "use" instructions
    $code ~~ s:g/ 'use ' .+? ';'//;
    # Look for all words beginning with "Q"
    $code ~~ m:g/<< 'Q' \w+ >>/;
    # Create and print the "use" instructions based on the found words
    say "";
    say "use Qt::QtWidgets;";
    say [~] START <<~>> ((set $/.list>>.Str) (&) CLASSES).keys.sort <<~>> END;