stop <reason> ** Tell all Bucardo processes to stop permanently
- list <type> [name] ** View information about dbs, dbgroups, herds, syncs, tables, or sequences
+ list <type> [name] ** View information about dbs, dbgroups, herds, syncs, tables, sequences or "all" of them
add <type> <name> ** Add a db, dbgroup, herd, sync, table, or sequence
remove <type> <name> ** Remove a db, dbgroup, herd, sync, table, or sequence
For detailed help on the above, prefix with a help like this:
## Show information about one or more items in the bucardo database
## Arguments: none, but parses nouns
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
my $usage = usage('list');
## Account for variations and abbreviations
$thing = standardize_name($thing);
- ## All of these will exit and do not return
- list_customcodes() if $thing eq 'customcode';
- list_customnames() if $thing eq 'customname';
- list_customcols() if $thing eq 'customcols';
- ## The dbgroup must be checked before the database (dbg vs db)
- list_dbgroups() if $thing eq 'dbgroup';
- list_databases() if $thing eq 'database';
- list_herds() if $thing eq 'herd';
- list_syncs() if $thing eq 'sync';
- list_tables() if $thing eq 'table';
- list_sequences() if $thing eq 'sequence';
-
- ## Cannot list anything else
- warn "$usage\n";
- exit 1;
+ SWITCH: {
+ $thing eq 'customcode' and do {
+ list_customcodes();
+ last SWITCH;
+ };
+ $thing eq 'customname' and do {
+ list_customnames();
+ last SWITCH;
+ };
+ $thing eq 'customcols' and do {
+ list_customcols();
+ last SWITCH;
+ };
+ ## The dbgroup must be checked before the database (dbg vs db)
+ $thing eq 'dbgroup' and do {
+ list_dbgroups();
+ last SWITCH;
+ };
+ $thing eq 'database' and do {
+ list_databases();
+ last SWITCH;
+ };
+ $thing eq 'herd' and do {
+ list_herds();
+ last SWITCH;
+ };
+ $thing eq 'sync' and do {
+ list_syncs();
+ last SWITCH;
+ };
+ $thing eq 'table' and do {
+ list_tables();
+ last SWITCH;
+ };
+ $thing eq 'sequence' and do {
+ list_sequences();
+ last SWITCH;
+ };
+ $thing eq 'all' and do {
+ print "-- customcodes:\n"; list_customcodes();
+ print "-- customnames:\n"; list_customnames();
+ print "-- customcols:\n"; list_customcols();
+ print "-- dbgroups:\n"; list_dbgroups();
+ print "-- databases:\n"; list_databases();
+ print "-- herds:\n"; list_herds();
+ print "-- syncs:\n"; list_syncs();
+ print "-- tables:\n"; list_tables();
+ print "-- sequences:\n"; list_sequences();
+ print "\n";
+ last SWITCH;
+ };
+ ## catch all
+ ## Cannot list anything else
+ warn "$usage\n";
+ exit 1;
+
+ } # SWITCH
+
+ exit 0;
} ## end of list_item
## Show information about databases. Queries the bucardo.db table
## Arguments: zero or more
## 1+ Databases to view. Can be "all" and can have wildcards
- ## Returns: undef
+ ## Returns: 0 on success, -1 on error
## Example: bucardo list db sale%
## Grab our generic usage message
## Might be no databases yet
if (! keys %$DB) {
print "No databases have been added yet\n";
- exit 1;
+ return -1;
}
## If not doing all, keep track of which to show
## No matches?
if (@nouns and ! keys %matchdb) {
print "No matching databases found\n";
- exit 1;
+ return -1;
}
## We only show the type if they are different from each othera
}
}
- exit 0;
+ return 0;
} ## end of list_databases
## Show information about all or some subset of the bucardo.dbgroup table
## Arguments: zero or more
## 1+ Groups to view. Can be "all" and can have wildcards
- ## Returns: undef
+ ## Returns: 0 on success, -1 on error
## Example: bucardo list dbgroups
## Grab our generic usage message
## Might be no groups yet
if (! keys %$DBGROUP) {
print "No database groups have been added yet\n";
- exit 1;
+ return -1;
}
## If not doing all, keep track of which to show
## No matches?
if (@nouns and ! keys %matchdbg) {
print "No matching database groups found\n";
- exit 1;
+ return -1;
}
## Figure out the length of each item for a pretty display
$VERBOSE >= 2 and show_all_columns($info);
}
- exit 0;
+ return 0;
} ## end of list_dbgroups
## Show information about all or some subset of the bucardo.customname table
## Arguments: zero or more
## 1+ Names to view. Can be "all" and can have wildcards
- ## Returns: undef
+ ## Returns: 0 on success, -1 on error
## Example: bucardo list customname
## Grab our generic usage message
## Might be no entries yet
if (! keys %$CUSTOMNAME) {
print "No customnames have been added yet\n";
- exit 1;
+ return -1;
}
my $cn = $CUSTOMNAME->{list};
## No matches?
if (@nouns and ! $matches) {
print "No matching customnames found\n";
- exit 1;
+ return -1;
}
## Figure out the length of each item for a pretty display
}
- exit 0;
+ return 0;
} ## end of list_customnames
## Show information about all or some subset of the bucardo.customcols table
## Arguments: zero or more
## 1+ Names to view. Can be "all" and can have wildcards
- ## Returns: undef
+ ## Returns: 0 on success, -1 on error
## Example: bucardo list customcols
## Grab our generic usage message
## Might be no entries yet
if (! keys %$CUSTOMCOLS) {
print "No customcols have been added yet\n";
- exit 1;
+ return -1;
}
my $cc = $CUSTOMCOLS->{list};
## No matches?
if (@nouns and ! $matches) {
print "No matching customcols found\n";
- exit 1;
+ return -1;
}
## Figure out the length of each item for a pretty display
}
- exit 0;
+ return 0;
} ## end of list_customcols
## Show information about all or some tables in the 'goat' table
## Arguments: none (reads nouns for a list of tables)
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
## Example: bucardo list tables
## Grab our generic usage message
## Might be no tables yet
if (! keys %$TABLE) {
print "No tables have been added yet\n";
- exit 1;
+ return -1;
}
## If not doing all, keep track of which to show
## No matches?
if (@nouns and ! keys %matchtable) {
print "No matching tables found\n";
- exit 1;
+ return -1;
}
## Figure out the length of each item for a pretty display
$VERBOSE >= 2 and show_all_columns($row);
}
- exit 0;
+ return 0;
} ## end of list_tables
## Show information about all or some subset of the 'herd' table
## Arguments: none, parses nouns for herd names
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
my $usage = usage('list_herds');
$sth->finish();
printf "There are no%s entries in the 'herd' table.\n",
$WHERE ? ' matching' : '';
- exit 1;
+ return -1;
}
$info = $sth->fetchall_arrayref({});
$VERBOSE >= 2 and show_all_columns($row);
}
- exit 0;
+ return 0;
} ## end of list_herds
## Show information about all or some subset of the 'sync' table
## Arguments: none (reads nouns for a list of syncs)
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
my $usage = usage('list_syncs');
## Nothing found? We're out of here
if (! keys %$syncs) {
print "No syncs found\n";
- exit 1;
+ return -1;
}
## Determine the size of the output strings for pretty aligning later
} ## end of each sync
- exit 0;
+ return 0;
} ## end of list_syncs
## Show information about all or some subset of the 'customcode' table
## Arguments: none, parses nouns for customcodes
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
my $usage = usage('list_customcodes');
$sth->finish();
printf "There are no%s entries in the 'customcode' table.\n",
$WHERE ? ' matching' : '';
- exit 1;
+ return -1;
}
$info = $sth->fetchall_arrayref({});
$VERBOSE >= 2 and show_all_columns($row);
}
- exit 0;
+ return 0;
} ## end of list_customcodes
## Show information about all or some sequences in the 'goat' table
## Arguments: none (reads nouns for a list of sequences)
- ## Returns: never, exits
+ ## Returns: 0 on success, -1 on error
my $usage = usage('list_sequences');
$sth->finish();
printf "There are no%s entries in the 'goat' table.\n",
$WHERE ? ' matching' : '';
- exit 1;
+ return -1;
}
$info = $sth->fetchall_arrayref({});
}
- exit 0;
+ return 0;
} ## end of list_sequences
return qq{Usage: list <type> [options]
Shows information about items in the internal Bucardo database.
The type is one of: db, dbgroup, table, sequence, herd, sync,
- customcode, customcols, or customname
+ customcode, customcols, customname, or all to see everything at once.
For more information, run: $progname help list <type>};
}
if ('list_customcode' eq $name) {