File Coverage

blib/lib/App/Rakubrew/Shell/Tcsh.pm
Criterion Covered Total %
statement 29 58 50.0
branch 1 8 12.5
condition 0 6 0.0
subroutine 10 17 58.8
pod 0 8 0.0
total 40 97 41.2


line stmt bran cond sub pod time code
1             package App::Rakubrew::Shell::Tcsh;
2 1     1   8 use App::Rakubrew::Shell;
  1         2  
  1         74  
3             our @ISA = "App::Rakubrew::Shell";
4 1     1   6 use strict;
  1         2  
  1         41  
5 1     1   6 use warnings;
  1         3  
  1         52  
6 1     1   19 use 5.010;
  1         4  
7              
8 1     1   5 use Encode::Locale qw(env);
  1         3  
  1         87  
9              
10 1     1   6 use App::Rakubrew::Variables;
  1         2  
  1         820  
11 1     1   10 use App::Rakubrew::Tools;
  1         2  
  1         102  
12 1     1   7 use App::Rakubrew::VersionHandling;
  1         3  
  1         187  
13 1     1   7 use App::Rakubrew::Build;
  1         3  
  1         832  
14              
15             sub supports_hooking {
16 0     0 0 0 my $self = shift;
17 0         0 1;
18             }
19              
20             sub install_note {
21 1     1 0 867 my $text = <
22             Load $brew_name automatically in `tcsh` by adding
23              
24             eval `$brew_exec init Tcsh`
25              
26             to ~/.tcshrc.
27             This can be easily done using:
28              
29             echo 'eval `$brew_exec init Tcsh`' >> ~/.tcshrc
30             EOT
31              
32 1 50       6 if ($prefix =~ / /) {
33 0         0 $text .= <
34              
35             =================================== WARNING ==================================
36              
37             rakubrews home directory is currently
38              
39             $prefix
40              
41             That folder contains spaces. This will break building rakudos as the build
42             system currently doesn't work in such a path. You can work around this problem
43             by changing that folder to a directory without spaces. Do so by putting
44              
45             setenv RAKUBREW_HOME /some/folder/without/space/rakubrew
46              
47             in your `~/.tcshrc` file *before* the `eval` line.
48             EOW
49             }
50 1         25 return $text;
51             }
52              
53             sub get_init_code {
54 0     0 0   my $self = shift;
55 0           my $path = env('PATH');
56 0           $path = $self->clean_path($path);
57 0 0         if (get_brew_mode() eq 'env') {
58 0           my $version = get_global_version();
59 0 0 0       if ($version && $version ne 'system' && !is_version_broken($version)) {
      0        
60 0           $path = join(':', get_bin_paths($version), $path);
61             }
62             }
63             else { # get_brew_mode() eq 'shim'
64 0           $path = join(':', $shim_dir, $path);
65             }
66 0           return "setenv PATH \"$path\" && alias $brew_name '$brew_exec internal_hooked Tcsh \\!* && eval \"`$brew_exec internal_shell_hook Tcsh post_call_eval \\!*`\"' && complete $brew_name 'p,*,`$brew_exec internal_shell_hook Tcsh completions \"\$COMMAND_LINE\"`,'";
67             }
68              
69             sub post_call_eval {
70 0     0 0   my $self = shift;
71 0           $self->print_shellmod_code(@_);
72             }
73              
74             sub get_path_setter_code {
75 0     0 0   my $self = shift;
76 0           my $path = shift;
77 0           return "setenv PATH \"$path\"";
78             }
79              
80             sub get_shell_setter_code {
81 0     0 0   my $self = shift;
82 0           my $version = shift;
83 0           return "setenv $env_var \"$version\"";
84             }
85              
86             sub get_shell_unsetter_code {
87 0     0 0   my $self = shift;
88 0           return "unsetenv $env_var";
89             }
90              
91             sub completions {
92 0     0 0   my $self = shift;
93 0           my $command = shift;
94 0           my @words = split ' ', $command;
95 0           my $index = @words - 1;
96 0 0         $index++ if $command =~ / $/;
97              
98 0           my @completions = $self->get_completions($self->strip_executable($index, @words));
99 0           say join(' ', @completions);
100             }
101              
102             1;
103