<commit_before>package CSG::Storage::SlotFS::Command::update_project;

use CSG::Storage::SlotFS -command;

sub opt_spec {
  return ();
}

sub validate_args {
  my ($self, $opts, $args) = @_;
}

sub execute {
  my ($self, $opts, $args) = @_;
}

1;

__END__

=head1

CSG::Storage::SlotFS::Command::update_project - Update a projects details
<commit_msg>working now<commit_after>package CSG::Storage::SlotFS::Command::update_project;

use CSG::Storage::SlotFS -command;

use CSG::Storage::Slots::DB;

sub opt_spec {
  return (
    ['project|p=s', 'Project to modifiy', {required => 1}],
    ['name=s',      'New project name',   {requried => 1}]
  );
}

sub validate_args {
  my ($self, $opts, $args) = @_;

  my $schema = CSG::Storage::Slots::DB->new();
  my $project = $schema->resultset('Project')->find({name => $opts->{project}});
  unless ($project) {
    $self->usage_error('Project does not exist');
  }

  if ($schema->resultset('Project')->find({name => $opts->{name}})) {
    $self->usage_error('New project name already exists');
  }


}

sub execute {
  my ($self, $opts, $args) = @_;

  my $schema = CSG::Storage::Slots::DB->new();
  my $project = $schema->resultset('Project')->find({name => $opts->{project}});
  $project->update({name => $opts->{name}});
}

1;

__END__

=head1

CSG::Storage::SlotFS::Command::update_project - Update a projects details

{'fraction_non_alphanumeric': 0.20702267739575714, 'fraction_numerical': 0.0043891733723482075, 'mean_word_length': 4.772151898734177, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2555883', 'n_tokens_mistral': 495, 'n_tokens_neox': 488, 'n_words': 101}