AmberDB
view release on metacpan or search on metacpan
bin/amberdb_cli.pl view on Meta::CPAN
# Direct file-based embedded execution, token-based session lifecycle, dynamic method reflection, and dash-tolerant argument parser.
use 5.016;
use strict;
use warnings;
use File::Basename qw(dirname basename);
use Cwd qw(abs_path getcwd);
use File::Spec;
use File::Path qw(make_path remove_tree);
use JSON::PP qw(encode_json decode_json);
use Data::Dumper;
use Time::HiRes qw(gettimeofday tv_interval);
our $t0 = [gettimeofday];
BEGIN {
my $script_path = __FILE__;
$script_path =~ s{[\\/]+}{/}g;
my $bin_dir = $script_path =~ m{^(.*)/[^/]+$} ? $1 : '.';
my $lib_dir = "$bin_dir/../lib";
my $abs_lib = eval { abs_path($lib_dir) } // $lib_dir;
bin/amberdb_cli.pl view on Meta::CPAN
=head1 OUTPUT FORMATS
The output format can be controlled using C<format=E<lt>typeE<gt>>:
=over 4
=item * C<table:> (Default) Human-readable ASCII terminal table.
=item * C<json:> Machine-readable JSON output, ideal for shell pipelines, Web UIs, and external scripts.
=item * C<raw:> Direct Perl Data::Dumper serialization.
=back
=head1 SEE ALSO
L<AmberDB>, L<AmberDB::Tools>, L<amberdb_setup.pl>
Official Wiki: L<https://github.com/marufcetin/amberdb/wiki/Guide-CLI>
=head1 AUTHOR
lib/AmberDB/Base.pm view on Meta::CPAN
}
sub _save_connect_config {
my ( $self, $data ) = @_;
my $file = $self->_connect_file();
return unless defined $file && ref($data) eq 'HASH';
my ($dir) = $file =~ m{^(.+)[/\\][^/\\]+$};
$self->make_path($dir) if $dir && !$self->dir_exist($dir);
require Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Sortkeys = 1;
my $dump = Data::Dumper::Dumper($data);
$dump =~ s/^\s+|\s+$//g;
if ( open my $fh, '>', $file ) {
print $fh "# AmberDB Database Connection & Client Auth Profile\n";
print $fh "return " . $dump . ";\n";
close $fh;
return 1;
}
return 0;
}
lib/AmberDB/Base.pm view on Meta::CPAN
sub _save_session {
my ( $self, $token, $data ) = @_;
return unless defined $token && length $token;
my $sf = $self->session_file($token);
return unless $sf;
my ($dir) = $sf =~ m{^(.+)[/\\][^/\\]+$};
$self->make_path($dir) if $dir && !$self->dir_exist($dir);
require Data::Dumper;
local $Data::Dumper::Terse = 1;
local $Data::Dumper::Indent = 1;
local $Data::Dumper::Sortkeys = 1;
my $dump = Data::Dumper::Dumper($data);
$dump =~ s/^\s+|\s+$//g;
if ( open my $fh, '>', $sf ) {
print $fh "# AmberDB Active CLI Session Token: $token\n";
print $fh "return " . $dump . ";\n";
close $fh;
}
# Also sync local .amberdb/session/sess_$token
my $local_dir = ".amberdb/session";
( run in 1.040 second using v1.01-cache-2.11-cpan-80ec619307d )