File Coverage

blib/lib/App/Rakubrew/Shell/Tcsh.pm
Criterion Covered Total %
statement 26 55 47.2
branch 1 8 12.5
condition 0 6 0.0
subroutine 9 16 56.2
pod 0 8 0.0
total 36 93 38.7


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