Commit | Line | Data |
1612b73d |
1 | package Rakudo::Star::Paths; |
2 | |
3 | use strict; |
4 | use warnings FATAL => 'all'; |
5 | use File::Basename qw(dirname); |
6 | use File::Spec::Functions qw(catdir); |
7 | |
8 | sub base_path { |
9 | catdir(dirname(__FILE__), 'Install') |
10 | } |
11 | |
12 | sub bin_path { |
13 | my $class = shift; |
14 | catdir($class->base_path, 'bin'); |
15 | } |
16 | |
17 | sub env_PATH { |
18 | my $class = shift; |
19 | 'export PATH='.join(':', $class->bin_path, $ENV{PATH}?$ENV{PATH}:())."\n"; |
20 | } |
21 | |
22 | sub import { |
23 | if ($0 eq '-') { |
24 | print shift->env_PATH; |
25 | exit 0; |
26 | } |
27 | } |
28 | |
29 | =head1 NAME |
30 | |
31 | Rakudo::Star::Paths - find your rakudo install |
32 | |
33 | =head1 SYNOPSIS |
34 | |
35 | bash$ perl -MRakudo::Star::Paths |
36 | export PATH=/path/to/rakudo/star/bin:... |
37 | |
38 | bash$ eval $(perl -MRakudo::Star::Paths) |
39 | # PATH env var is now set |
40 | |
41 | bash$ perl -MRakudo::Star::Paths -e 'print Rakudo::Star::Paths->bin_path' |
42 | /path/to/rakudo/star/bin |
43 | |
44 | =head1 COPYRIGHT |
45 | |
46 | See L<Rakudo::Star/COPYRIGHT> |
47 | |
48 | =head1 LICENSE |
49 | |
50 | See L<Rakudo::Star/LICENSE> |
51 | |
52 | =cut |
53 | |
54 | 1; |