AmberDB
view release on metacpan or search on metacpan
bin/amberdb_cli.pl view on Meta::CPAN
}
my $table = delete $method_args{table} // shift @pos_args;
die "[AMBERDB_ERROR] 'table' parameter required for drop\n" unless defined $table && length $table;
unless ($opt_force) {
if ( -t STDIN ) {
print "\n[UYARI] '$table' tablosu ve iliÅkili tüm indeksler kalıcı olarak silinecek!\n";
print "Onaylamak için tablo adını ('$table') yazın: ";
my $confirm = <STDIN>;
chomp($confirm) if defined $confirm;
if ( !defined $confirm || $confirm ne $table ) {
print "[AMBERDB] Tablo silme iÅlemi iptal edildi.\n";
exit 0;
}
}
else {
die "[AMBERDB_ERROR] Table drop requires 'force=1' or '--force' flag for safety.\n";
}
}
my $ok = $tools->del_table($table);
output_result( { status => ( $ok ? 'ok' : 'error' ), action => 'drop', table => $table }, $opt_format );
exit 0;
}
# ============================================================================
# GENERIC DYNAMIC DISPATCH FALLBACK ($adb->$action or $tools->$action)
# ============================================================================
if ( $adb->can($action) ) {
my $res = eval { $adb->$action( @pos_args, %method_args ) };
if ($@) {
die "[AMBERDB_ERROR] Execution of \$adb->$action failed: $@\n";
}
output_result( $res, $opt_format );
exit 0;
}
if ( $tools->can($action) ) {
my $res = eval { $tools->$action( @pos_args, %method_args ) };
if ($@) {
die "[AMBERDB_ERROR] Execution of \$tools->$action failed: $@\n";
}
output_result( $res, $opt_format );
exit 0;
}
die "[AMBERDB_ERROR] Unknown action or method '$action'. Use 'help' to view available commands.\n";
END {
return unless $opt_time;
return if $opt_help;
return if defined $? && $? != 0;
my $elapsed = eval { tv_interval($t0) } // 0;
my $time_str = sprintf( "%.4fs (%.2f ms)", $elapsed, $elapsed * 1000 );
print "[Time: $time_str]\n";
}
__END__
=encoding utf8
=head1 NAME
amberdb_cli.pl - High-performance Command-Line Console & Embedded Management Utility for AmberDB
=head1 SYNOPSIS
# 1. Overview Dashboard (lists all tables, records, size, engine status)
perl bin/amberdb_cli.pl
perl bin/amberdb_cli.pl format=json
# 2. Token-Based Session Lifecycle (Connect, Configure & Disconnect)
perl bin/amberdb_cli.pl connect path-dbase_dir=./dbstore cfg-language=tr
perl bin/amberdb_cli.pl token=K2A78T02 cfg-no_write=1
perl bin/amberdb_cli.pl token=K2A78T02 disconnect
# 3. Dynamic In-Memory Schema Customization (table_attr)
perl bin/amberdb_cli.pl token=K2A78T02 action=table_attr table=products keep_deleted=1 search_block=[2,3,6]
# 4. CRUD & Query Operations
perl bin/amberdb_cli.pl token=K2A78T02 action=read_id table=users id=10
perl bin/amberdb_cli.pl token=K2A78T02 action=read_all table=products offset=0 limit=20 dir=asc
perl bin/amberdb_cli.pl token=K2A78T02 action=read_list table=users ids=1,2,5,10
perl bin/amberdb_cli.pl token=K2A78T02 action=search_table table=products query="laptop" limit=10
perl bin/amberdb_cli.pl token=K2A78T02 action=insert_id table=users id=0 data='{"name":"Ahmet","status":1}'
perl bin/amberdb_cli.pl token=K2A78T02 action=update_id table=users id=10 data='{"status":2}'
perl bin/amberdb_cli.pl token=K2A78T02 action=delete_id table=users id=10
# 5. Maintenance, Indexing & Disaster Recovery
perl bin/amberdb_cli.pl token=K2A78T02 action=reindex table=products
perl bin/amberdb_cli.pl token=K2A78T02 action=check table=products
perl bin/amberdb_cli.pl token=K2A78T02 action=vacuum table=products
perl bin/amberdb_cli.pl token=K2A78T02 action=export table=products file=products.csv
perl bin/amberdb_cli.pl token=K2A78T02 action=import table=products file=products.csv
perl bin/amberdb_cli.pl token=K2A78T02 action=drop table=temp_products force=1
=head1 DESCRIPTION
C<amberdb_cli.pl> is a direct file-based command-line console and administrative utility for C<AmberDB>. It bypasses network daemon overhead, operating directly upon native database files (C<.db>, C<.inx>, C<.fld>, C<.src>, C<.fac>) at microsecond em...
Key capabilities include:
=over 4
=item * B<Interactive & Non-Interactive Dashboard:> Running with no arguments renders an overview of all database tables, record counts, file sizes, and storage directories.
=item * B<Token-Based Session Persistence:> State, paths, language codes, safety flags, and runtime schema mutations (C<table_attr>) persist across terminal invocations via short session tokens (stored under C<.amberdb_sessions/>).
=item * B<Full CRUD Suite:> Supports positional or key-value record reading, pagination (C<offset>/C<limit>), full-text phonetic search, and bulk operations.
=item * B<Maintenance & Utilities:> Native disaster recovery archiving (C<dump>/C<restore>), CSV export/import, binary index rebuilding (C<reindex>), database compacting (C<vacuum>), and schema inspection.
=item * B<Dynamic Method Reflection:> Any method supported by C<AmberDB> or C<AmberDB::Tools> can be dispatched dynamically via C<action=E<lt>methodE<gt>>.
=back
=head1 SESSIONS & ARGUMENT CONVENTIONS
=head2 Argument Formats
( run in 1.484 second using v1.01-cache-2.11-cpan-364913b4093 )