Help language development. Donate to The Perl Foundation

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

bin/guessuse
#!/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: 
#         https://github.com/yguillemot/RaQt_maker
# 


sub USAGE ()
{
    #BEGIN_INSERTION_HERE
    #VERSION_NUMBER
    my $ver = "Qt::QtWidgets version 0.0.5";
    #END_INSERTION_HERE


    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>
            
        END
        
    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 (
        #BEGIN_INSERTION_HERE
        #LIST_OF_CLASSES
                "QApplication",
                "QAbstractButton",
                "QAbstractScrollArea",
                "QAbstractSlider",
                "QAction",
                "QBoxLayout",
                "QBrush",
                "QCheckBox",
                "QCloseEvent",
                "QColor",
                "QCoreApplication",
                "QDial",
                "QDialog",
                "QEvent",
                "QFileDialog",
                "QFont",
                "QFrame",
                "QGroupBox",
                "QGuiApplication",
                "QHBoxLayout",
                "QImage",
                "QInputEvent",
                "QLabel",
                "QLayout",
                "QLayoutItem",
                "QLineEdit",
                "QMenu",
                "QMessageBox",
                "QMouseEvent",
                "QPaintDevice",
                "QPaintEvent",
                "QPainter",
                "QPen",
                "QPoint",
                "QPointF",
                "QPushButton",
                "QRadioButton",
                "QRect",
                "QRegion",
                "QResizeEvent",
                "QSize",
                "QSlider",
                "QTextEdit",
                "QTimer",
                "QVBoxLayout",
                "QWidget",
                "Qt",
        #END_INSERTION_HERE

    );
    
    # 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;
}