App-HistHub
view release on metacpan or search on metacpan
lib/App/HistHub.pm view on Meta::CPAN
isa => 'Int',
default => sub { 5 },
);
has update_queue => (
is => 'rw',
isa => 'ArrayRef',
default => sub { [] },
);
has api_endpoint => (
is => 'rw',
isa => 'Str',
required => 1,
);
has api_uid => (
is => 'rw',
isa => 'Str',
);
=head1 NAME
App::HistHub - Sync shell history between multiple PC.
=head1 SYNOPSIS
use App::HistHub;
my $hh = App::HistHub->new(
hist_file => 'path to your history file',
api_endpoint => 'http://localhost:3000/',
);
$hh->run;
=head1 DESCRIPTION
App::HistHub is an application that enables you to sync shell history between multiple computers.
This application consists of two modules: client module (histhubd.pl) and server module (histhub_server.pl).
You need one histhub server. To bootup the server, type following command:
lib/App/HistHub.pm view on Meta::CPAN
Create HistHub object.
Available obtions are:
=over 4
=item hist_file
History file path to watch update
=item api_endpoint
Update API URL.
=back
=head2 spawn
Create POE session and return session object.
=cut
lib/App/HistHub.pm view on Meta::CPAN
$hh->uri_for( $path )
Build api url
=cut
sub uri_for {
my ($self, $path) = @_;
(my $url = $self->api_endpoint) =~ s!/+$!!;
$url . $path;
}
=head2 append_history
$hh->append_history( $session, $api_response );
Update history file
=cut
lib/App/HistHub.pm view on Meta::CPAN
=head1 POE METHODS
=head2 poe__start
=cut
sub poe__start {
my ($self, $kernel, $session) = @_[OBJECT, KERNEL, SESSION];
my $d = $self->ua->request( GET $self->api_endpoint . '/api/init' );
$d->addCallback(sub {
my $res = shift;
my $json = $self->json_driver->decode($res->content);
if ($json->{error}) {
die 'api response error: ' . $json->{error};
}
else {
$self->api_uid( $json->{result}{uid} );
$kernel->post( $session->ID, 'init' );
script/histhubd.pl view on Meta::CPAN
GetOptions(
\my %option,
qw/help histfile=s server=s/,
);
pod2usage(0) if $option{help};
pod2usage(1) unless $option{histfile} and $option{server};
my $hh = App::HistHub->new(
hist_file => $option{histfile},
api_endpoint => $option{server},
);
$hh->run;
=head1 NAME
histhubd.pl - histhub history update script
=head1 SYNOPSIS
histhubd.pl --histfile=~/.zhistory --server=http://localhost:3000
( run in 0.286 second using v1.01-cache-2.11-cpan-27979f6cc8f )