lib/WWW/Hetzner/Robot/CLI.pm untested

filter: Statementstmt 0.0% 0 / 47 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 5 Podpod 0.0% 0 / 1 totaltotal 0.0% 0 / 53 CC 1 SCAR 6.9
CC
1
Cov
0%
execute
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package WWW::Hetzner::Robot::CLI;
2  
3 # ABSTRACT: Hetzner Robot CLI
4  
5 use Moo;
6 use MooX::Cmd;
7 use MooX::Options;
8 use WWW::Hetzner::Robot;
9  
10 our $VERSION = '0.102';
11  
12  
13 option user => (
14 is => 'ro',
15 format => 's',
16 short => 'u',
17 doc => 'Robot user (default: HETZNER_ROBOT_USER env)',
18 default => sub { $ENV{HETZNER_ROBOT_USER} },
19 );
20  
21  
22 option password => (
23 is => 'ro',
24 format => 's',
25 short => 'p',
26 doc => 'Robot password (default: HETZNER_ROBOT_PASSWORD env)',
27 default => sub { $ENV{HETZNER_ROBOT_PASSWORD} },
28 );
29  
30  
31 option output => (
32 is => 'ro',
33 format => 's',
34 short => 'o',
35 doc => 'Output format: table, json (default: table)',
36 default => 'table',
37 );
38  
39  
40 has robot => (
41 is => 'lazy',
42 builder => sub {
43 my ($self) = @_;
44 WWW::Hetzner::Robot->new(
45 user => $self->user,
46 password => $self->password,
47 );
48 },
49 );
50  
51  
52 sub execute {
53 my ($self, $args, $chain) = @_;
54  
55 print "Usage: hrobot.pl [options] <command> [command-options]\n\n";
56 print "Global options (must come BEFORE the command):\n";
57 print " -u, --user Robot webservice user\n";
58 print " -p, --password Robot webservice password\n";
59 print " -o, --output Output format: table, json\n";
60 print "\nCommands:\n";
61 print " server Manage dedicated servers\n";
62 print " key Manage SSH keys\n";
63 print " reset Reset a server\n";
64 print " wol Wake-on-LAN\n";
65 print " traffic Query traffic statistics\n";
66 print " boot Boot configuration (rescue, linux, vnc, windows)\n";
67 print " rdns Manage reverse DNS entries\n";
68 print " failover Manage failover IP routing\n";
69 print "\nExamples:\n";
70 print " hrobot.pl server list\n";
71 print " hrobot.pl -u user -p pass server list\n";
72 print " hrobot.pl --output json server describe 123456\n";
73 print " hrobot.pl boot rescue 123456 --enable --os linux\n";
74 print " hrobot.pl failover 203.0.113.60 --to 198.51.100.10\n";
75 print "\nEnvironment variables:\n";
76 print " HETZNER_ROBOT_USER Default for --user\n";
77 print " HETZNER_ROBOT_PASSWORD Default for --password\n";
78 print "\nRun 'hrobot.pl <command> --help' for command-specific options.\n";
79 }
80  
81  
82  
83 1;
84  
85 __END__