### ----------------------------------------------------
### -- ake
### -- Licenses: Artistic-2.0
### -- Authors: Jonathan Scott Duff <duff@pobox.com>, Alex Daniel, the Raku Community
### -- File: lib/Ake/TaskStore.rakumod
### ----------------------------------------------------
unit module Ake::TaskStore;

our %TASKS is export;

sub make-task($name, &body,
              :@deps=[], :&cond={True}, :$type) is export {
    if %TASKS{$name}:exists and $name ne ‘help’ {
        note “Duplicate task $name”;
        exit 2
    }
    %TASKS{~$name} = $type.new: :$name, :&body, :@deps,
                                :&cond, callframe => callframe
}

sub did-you-mean is export {
    return “\nNo tasks were defined” if %TASKS == 0;
    “\nDid you mean one of these?\n”
    ~ %TASKS.keys.sort».indent(4).join: “\n”
}


