Amazon-S3-Thin

 view release on metacpan or  search on metacpan

eg/s3  view on Meta::CPAN

#!/usr/bin/env perl
# command tool like aws s3
use strict;
use warnings;
use FindBin;
use lib $FindBin::Bin . '/../lib';
use Amazon::S3::Thin;
use Config::Tiny;

S3::CLI->new->run(@ARGV);


package S3::CLI;
use strict;
use warnings;
use Getopt::Long;
use Amazon::S3::Thin;
use Data::Dumper;

sub new {
    return bless {}, shift;
}

sub help {
    my ($self, @args) = @_;
    require Pod::Usage;
    Pod::Usage::pod2usage(0);
}

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

    our $VERSION = "0.25";

    my $p = Getopt::Long::Parser->new(
        config => [qw(posix_default no_ignore_case bundling)],
        );

    $p->getoptionsfromarray(
        \@args,
        "p|profile=s"   => \(my $profile = "default"),
        "r|region=s"    => \(my $region),
        "h|help"        => \(my $help),
        "version"       => \(my $version),
        "v|verbose"     => \($self->{verbose}),
    );
    if ($version) {
        printf "s3 %s\n", $VERSION;
        exit 0;
    }
    if ($help) {
        $self->help();
        exit 0;
    }

    # https://docs.aws.amazon.com/cli/latest/userguide/cli-config-files.html
    my $cred_file = $ENV{HOME} . "/.aws/credentials";
    my $config_file = $ENV{HOME} . "/.aws/config";

    if (-f $config_file and !defined $region) {
        my $config = Config::Tiny->read($config_file)->{$profile};
        $region = $config->{region};
    }

    if (-f $cred_file) {
        my $crd = Config::Tiny->read($cred_file)->{$profile};



( run in 2.175 seconds using v1.01-cache-2.11-cpan-8f98c5d2c55 )