Commits

Diab Jerius  committed fa7806c

initial (non working) client code

  • Participants
  • Parent commits 9365532

Comments (0)

Files changed (1)

File lib/Hg/Lib/Client.pm

+package Hg::Lib::Client;
+
+use Moo;
+use MooX::Types::MooseLike::Base ':all';
+
+use boolean qw[isFalse];
+
+use Scalar::Util qw[ reftype ];
+
+Hg::Lib::Server->shadow_attrs;
+
+has _server => (
+    is => 'lazy',
+    isa => InstanceOf ['Hg::Lib::Server'],
+    init_def => undef,
+    builder  => sub {
+        Hg::Lib::Server->new( Hg::Lib::Server->xtract_attrs( $_[0] ) );
+    },
+);
+
+
+# prep commands for submission to server
+sub _prep_cmd {
+
+    my @cmd = ( shift );
+
+    my $pos = shift;
+
+    $pos = [ $pos ] unless 'ARRAY' eq ref $pos;
+
+    while( my ( $k, $v ) = each %cmds ) {
+
+	$k =~ s/_/-/g;
+
+	$k = (length($k) > 1 ? '--' : '-') . $k;
+
+	$v = [ $v ] unless 'ARRAY' eq reftype $v;
+
+	for my $vv ( @$v ) {
+
+	    next if ! defined $v or isFalse($v);
+
+	    push @cmd, $k, $v;
+	}
+
+    }
+
+    push @cmd, @$pos;
+
+    return \@cmd;
+}
+
+# everything that follows is sugar
+
+sub add {
+
+    my ( $self, $files ) = (shift, shift);
+
+    $files = [ $files ] unless 'ARRAY' eq ref $files;
+
+    my $cmd = _prep_cmd( 'add', $files, { @_ } );
+
+    
+
+}
+
+1;
+
+__END__
+
+=pod
+
+=head1 NAME
+
+Hg::Lib::Client
+
+=head1 VERSION
+
+version 0.01_03
+
+=method
+
+add - add
+
+=head1 AUTHOR
+
+Diab Jerius E<lt>djerius@cpan.orgE<gt>
+
+=head1 COPYRIGHT AND LICENSE
+
+This software is copyright (c) 2013 by Diab Jerius E<lt>djerius@cpan.orgE<gt>.
+
+This is free software; you can redistribute it and/or modify it under
+the same terms as the Perl 5 programming language system itself.
+
+=cut