| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package NVMPL::Core; |
|
2
|
2
|
|
|
2
|
|
149424
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
91
|
|
|
3
|
2
|
|
|
2
|
|
12
|
use warnings; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
127
|
|
|
4
|
2
|
|
|
2
|
|
13
|
use feature 'say'; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
259
|
|
|
5
|
2
|
|
|
2
|
|
626
|
use NVMPL::Config; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
106
|
|
|
6
|
2
|
|
|
2
|
|
1266
|
use NVMPL::Installer; |
|
|
2
|
|
|
|
|
9
|
|
|
|
2
|
|
|
|
|
151
|
|
|
7
|
2
|
|
|
2
|
|
1241
|
use NVMPL::Uninstaller; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
96
|
|
|
8
|
2
|
|
|
2
|
|
18
|
use NVMPL::Switcher; |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
70
|
|
|
9
|
2
|
|
|
2
|
|
1375
|
use NVMPL::Remote; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
4497
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.2'; |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 NAME |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
NVMPL::Core - Core dispatch module for nvm-pl Node.js version manager |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=head1 VERSION |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
Version 1.2 |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
use NVMPL::Core; |
|
24
|
|
|
|
|
|
|
NVMPL::Core::dispatch('install', '25.1.0'); |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Core command dispatcher for nvm-pl, a Perl-based Node.js version manager. |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 METHODS |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head2 dispatch |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
NVMPL::Core::dispatch($command, @args); |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Dispatch commands to appropriate modules. |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=cut |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
my $CONFIG; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# --------------------------------------------------------- |
|
43
|
|
|
|
|
|
|
# Entry point called from bin/nvm-pl |
|
44
|
|
|
|
|
|
|
# --------------------------------------------------------- |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub dispatch { |
|
47
|
9
|
|
|
9
|
1
|
280174
|
my ($command, @args) = @_; |
|
48
|
|
|
|
|
|
|
|
|
49
|
9
|
|
66
|
|
|
47
|
$CONFIG ||= NVMPL::Config->load(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
9
|
100
|
|
|
|
23
|
unless ($command) { |
|
52
|
1
|
|
|
|
|
40
|
say "No command provided. Try 'nvm-pl --help'"; |
|
53
|
1
|
|
|
|
|
8
|
exit 1; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Super Slick |
|
57
|
8
|
|
|
|
|
28
|
$command =~ s/-/_/g; |
|
58
|
|
|
|
|
|
|
|
|
59
|
8
|
|
|
|
|
70
|
my %commands = ( |
|
60
|
|
|
|
|
|
|
install => \&_install, |
|
61
|
|
|
|
|
|
|
use => \&_use, |
|
62
|
|
|
|
|
|
|
ls => \&_ls, |
|
63
|
|
|
|
|
|
|
ls_remote => \&_ls_remote, |
|
64
|
|
|
|
|
|
|
current => \&_current, |
|
65
|
|
|
|
|
|
|
uninstall => \&_uninstall, |
|
66
|
|
|
|
|
|
|
cache => \&_cache, |
|
67
|
|
|
|
|
|
|
); |
|
68
|
|
|
|
|
|
|
|
|
69
|
8
|
100
|
|
|
|
28
|
if (exists $commands{$command}) { |
|
70
|
7
|
|
|
|
|
26
|
$commands{$command}->(@args); |
|
71
|
|
|
|
|
|
|
} else { |
|
72
|
1
|
|
|
|
|
13
|
say "Unknown command '$command' . Try 'nvm-pl --help'"; |
|
73
|
1
|
|
|
|
|
6
|
exit 1; |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
# --------------------------------------------------------- |
|
78
|
|
|
|
|
|
|
# Command stubs (we'll implement these later) |
|
79
|
|
|
|
|
|
|
# --------------------------------------------------------- |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub _install { |
|
82
|
1
|
|
|
1
|
|
4
|
my ($ver) = @_; |
|
83
|
1
|
|
|
|
|
7
|
NVMPL::Installer::install_version($ver); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub _use { |
|
87
|
1
|
|
|
1
|
|
3
|
my ($ver) = @_; |
|
88
|
1
|
|
|
|
|
6
|
NVMPL::Switcher::use_version($ver); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub _ls { |
|
92
|
1
|
|
|
1
|
|
6
|
NVMPL::Switcher::list_installed(); |
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
sub _ls_remote { |
|
96
|
1
|
|
|
1
|
|
4
|
my @args = @_; |
|
97
|
1
|
50
|
|
|
|
6
|
my $filter = grep { $_ eq '--lts' } @args ? 1 : 0; |
|
|
1
|
|
|
|
|
5
|
|
|
98
|
1
|
|
|
|
|
5
|
NVMPL::Remote::list_remote_versions(lts => $filter); |
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub _current { |
|
102
|
1
|
|
|
1
|
|
6
|
NVMPL::Switcher::show_current(); |
|
103
|
|
|
|
|
|
|
} |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _uninstall { |
|
106
|
1
|
|
|
1
|
|
3
|
my ($ver) = @_; |
|
107
|
1
|
|
|
|
|
7
|
NVMPL::Uninstaller::uninstall_version($ver); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub _cache { |
|
111
|
1
|
|
|
1
|
|
4
|
my ($subcmd) = @_; |
|
112
|
1
|
|
|
|
|
9
|
say "[nvm-pl] Cache command: $subcmd (stub)"; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
1; |