<commit_before>package Silki::CLI::Export;

use strict;
use warnings;
use namespace::autoclean;
use autodie;

use Cwd qw( abs_path );
use Path::Class qw( dir );
use Silki::Schema::Process;
use Silki::Schema::Wiki;
use Silki::Types qw( Str );
use Silki::Wiki::Exporter;

use Moose;
use Moose::Util::TypeConstraints;

with qw( MooseX::Getopt::Dashes Silki::Role::CLI::HasOptionalProcess );

{
    subtype 'Wiki', as 'Silki::Schema::Wiki';
    coerce 'Wiki',
        from Str,
        via { Silki::Schema::Wiki->new( short_name => $_ ) };

    MooseX::Getopt::OptionTypeMap->add_option_type_to_map( 'Wiki' => '=s' );

    has wiki => (
        is       => 'ro',
        isa      => 'Wiki',
        required => 1,
        coerce   => 1,
    );
}

has file => (
    is        => 'ro',
    isa       => Str,
    predicate => '_has_file',
);

sub _run {
    my $self = shift;

    my %p = (
        wiki => $self->wiki(),
        log  => $self->_log_coderef(),
    );

    my $tarball = Silki::Wiki::Exporter->new(%p)->tarball();

    my $new_name
        = $self->_has_file()
        ? $self->file()<commit_msg>Add usage docs<commit_after>package Silki::CLI::Export;

use strict;
use warnings;
use namespace::autoclean;
use autodie;

use Cwd qw( abs_path );
use Path::Class qw( dir );
use Silki::Schema::Process;
use Silki::Schema::Wiki;
use Silki::Types qw( Str );
use Silki::Wiki::Exporter;

use Moose;
use Moose::Util::TypeConstraints;

with qw( MooseX::Getopt::Dashes Silki::Role::CLI::HasOptionalProcess );

{
    subtype 'Wiki', as 'Silki::Schema::Wiki';
    coerce 'Wiki',
        from Str,
        via { Silki::Schema::Wiki->new( short_name => $_ ) };

    MooseX::Getopt::OptionTypeMap->add_option_type_to_map( 'Wiki' => '=s' );

    has wiki => (
        is            => 'ro',
        isa           => 'Wiki',
        required      => 1,
        coerce        => 1,
        documentation => 'The short name of the wiki to export. Required.',
    );
}

has file => (
    is        => 'ro',
    isa       => Str,
    predicate => '_has_file',
    documentation =>
        'The name of the tarball to be created.'
        . ' If not specified, the tarball is created as'
        . ' export-of-<short-name>.tar.gz in the current directory',
);

sub _run {
    my $self = shift;

    my %p = (
        wiki => $self->wiki(),
        log  => $self->_log_coderef(),
    );

    my $tarball = Silki::Wiki::Exporter->new(%p)->tarball();

    my $new_name
        = $self->_has_file()
        ? $self->file()
{'fraction_non_alphanumeric': 0.17059528565721135, 'fraction_numerical': 0.0015980823012385138, 'mean_word_length': 2.541725601131542, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 48, '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': '6402166', 'n_tokens_mistral': 909, 'n_tokens_neox': 880, 'n_words': 205}