Chit/Command/role.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 9 Podpod 0.0% 0 / 3 totaltotal 0.0% 0 / 51 CC 2 SCAR 10.3
CC
2
Cov
0%
execute
6.0
abstract
2.0
opt_spec
2.0
CRAP 2.8
1 use v5.20;
2 use strict;
3 use warnings;
4 use experimental qw( signatures lexical_subs postderef );
5  
6 package App::Chit::Command::role;
7  
8 use App::Chit -command;
9  
10 use App::Chit::Util ();
11  
12 our $AUTHORITY = 'cpan:TOBYINK';
13 our $VERSION = '0.001001';
14  
15 sub abstract {
16 return "Show or set ChatGPT's role in the chat."
17 }
18  
19 sub opt_spec {
20 return (
21 [ "set=s", "set role" ],
22 );
23 }
24  
25 sub execute ( $self, $opt, $args ) {
26 my $dir = App::Chit::Util::find_chit_dir()
27 or $self->usage_error("need to initialize chit first");
28 my $chit = App::Chit::Util::load_chit( $dir );
29
30 if ( $opt->{set} ) {
31 say "Previous role: ", $chit->{role};
32 say "Setting role to: ", $opt->{set};
33 $chit->{role} = $opt->{set};
34 }
35 else {
36 say $chit->{role};
37 }
38
39 App::Chit::Util::save_chit( $dir, $chit );
40 }
41  
42 1;