SD/CLI/Command/Shell.pm untested

filter: Statementstmt 0.0% 0 / 19 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 30 CC 2 SCAR 12.8
CC
2
Cov
0%
preamble
6.0
usage_msg
2.0
prompt
2.0
CRAP 3.6
1 package App::SD::CLI::Command::Shell;
2 use Any::Moose;
3 extends 'Prophet::CLI::Command::Shell';
4  
5 has project_name => (
6 isa => 'Str',
7 is => 'rw',
8 lazy => 1,
9 default => sub {
10 my $self = shift;
11 if ( $self->app_handle->handle->replica_exists ) {
12 return $self->app_handle->setting( label => 'project_name' )->get()->[0];
13 } else {
14 return 'No database found';
15 }
16 }
17 );
18  
19 sub usage_msg {
20 my $self = shift;
21 my $cmd = $self->cli->get_script_name;
22  
23 return <<"END_USAGE";
24 usage: ${cmd}\[cmd]
25 ${cmd}--version | -V
26 END_USAGE
27 }
28  
29 sub preamble {
30 my $self = shift;
31 my @out = (
32 "SD for " . $self->project_name . " ($App::SD::VERSION; Prophet $Prophet::VERSION)",
33 'Type "help", "about", or "copying" for more information.'
34 );
35  
36 if ( !$self->app_handle->handle->replica_exists ) {
37 push @out, '', "No SD database was found at " . $self->app_handle->handle->url(),
38 'Type "help init" and "help environment" for tips on how to sort that out.';
39 }
40  
41 return join( "\n", @out );
42  
43 }
44  
45 sub prompt {
46 my $self = shift;
47  
48 return $self->project_name . "> ";
49 }
50  
51 1;
52