Skip to content

Instantly share code, notes, and snippets.

@sdondley
Created June 21, 2022 11:34
Show Gist options
  • Select an option

  • Save sdondley/9c7620a8945f06847591d6fa6b8ef587 to your computer and use it in GitHub Desktop.

Select an option

Save sdondley/9c7620a8945f06847591d6fa6b8ef587 to your computer and use it in GitHub Desktop.

Revisions

  1. sdondley created this gist Jun 21, 2022.
    61 changes: 61 additions & 0 deletions Menu.rakumod
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,61 @@
    use Injector;
    use Menu::Simple;
    unit class Distribution::Resources::Menu;

    class ResourceMenu is export {
    has CompUnit::Repository::Distribution $.dist is injected<dist>;
    has Menu $.menu is rw;

    method action(Str $path) {
    say $path;
    my $file = %?RESOURCES{$path};
    say $file;
    }

    method resources() {
    self.dist.meta<resources>
    }

    method build-menu() {
    my $menu = Menu.new();
    $menu.add-option('test.txt', { self.action('testing/test.txt') });
    self.menu = $menu;
    }

    method execute-menu() {
    self.menu.execute;
    }


    }

    =begin pod
    =head1 NAME
    Distribution::Resources::Menu - blah blah blah
    =head1 SYNOPSIS
    =begin code :lang<raku>
    use Distribution::Resources::Menu;
    =end code
    =head1 DESCRIPTION
    Distribution::Resources::Menu allows users to navigate and select a file from a
    distribution's C<resources> directory.
    =head1 AUTHOR
    Steve Dondley <[email protected]>
    =head1 COPYRIGHT AND LICENSE
    Copyright 2022 Steve Dondley
    This library is free software; you can redistribute it and/or modify it under the Artistic License 2.0.
    =end pod