[Bps-public-commit] r16067 - in Prophet/branches/dispatcher: lib/Prophet/CLI
sartak at bestpractical.com
sartak at bestpractical.com
Thu Sep 25 15:40:51 EDT 2008
Author: sartak
Date: Thu Sep 25 15:40:50 2008
New Revision: 16067
Modified:
Prophet/branches/dispatcher/ (props changed)
Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
Log:
r72472 at onn: sartak | 2008-09-25 15:37:11 -0400
create command
Modified: Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm
==============================================================================
--- Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm (original)
+++ Prophet/branches/dispatcher/lib/Prophet/CLI/Dispatcher.pm Thu Sep 25 15:40:50 2008
@@ -26,12 +26,40 @@
required => 1,
);
+has record => (
+ is => 'rw',
+ isa => 'Prophet::Record',
+ documentation => 'If the command operates on a record, it will be stored here.',
+);
+
on ['server'] => sub {
my $self = shift;
my $server = $self->setup_server;
$server->run;
};
+on ['create'] => sub {
+ my $self = shift;
+ my $record = $self->context->_get_record_object;
+
+ my ($val, $msg) = $record->create(props => $self->cli->edit_props);
+
+ if (!$val) {
+ warn "Unable to create record: " . $msg . "\n";
+ }
+ if (!$record->uuid) {
+ warn "Failed to create " . $record->record_type . "\n";
+ return;
+ }
+
+ $self->record($record);
+
+ printf "Created %s %s (%s)\n",
+ $record->record_type,
+ $record->luid,
+ $record->uuid;
+};
+
on qr/()/ => sub {
my $self = shift;
$self->fatal_error("The command you ran could not be found. Perhaps running '$0 help' would help?");
More information about the Bps-public-commit
mailing list