App-AltSQL

 view release on metacpan or  search on metacpan

lib/App/AltSQL/Plugin/Dump.pm  view on Meta::CPAN

 "3","Cow"

HTML:

 .dump out.html select * from users;

out.html:

=begin html

<style>table{margin: 1em 1em 1em 2em;background: whitesmoke;border-collapse: collapse;}table th, table td{border: 1px gainsboro solid;padding: 0.2em;}table th{background: gainsboro;text-align: left;}</style><table><tr><th>id</th><th>name</th></tr><tr...

=end html

JSON:

 .dump out.json select * from users;

out.json:

 [{"name":"Moo","id":"1"},{"name":"Pie","id":"2"},{"name":"Cow","id":"3"}]

lib/App/AltSQL/Plugin/Dump/Format/html.pm  view on Meta::CPAN

package App::AltSQL::Plugin::Dump::Format::html;

use Moose::Role;

sub format {
    my ($self, %params) = @_;

    my $table_data = $params{table_data};

    # ehhh prob shouldn't put this here but couldn't resist.
    my $css = 'table{margin: 1em 1em 1em 2em;background: whitesmoke;border-collapse: collapse;}table th, table td{border: 1px gainsboro solid;padding: 0.2em;}table th{background: gainsboro;text-align: left;}';

    my $html  = "<style>$css</style><table>";
       $html .= '<tr>' . join( '', map{ '<th>' . escape($_->{name}) . '</th>' } @{ $table_data->{columns} } ) . "</tr>";

    for my $row (@{ $table_data->{rows} }) {
        $html .=  '<tr>' . join( '', map {'<td>' . escape($_) . '</td>' } @$row ) . '</tr>';
    }

    $html .= '</table>';

lib/App/AltSQL/Term.pm  view on Meta::CPAN

	$self->{term} = $term;

	# Require the tab key to be hit twice before showing the list of autocomplete items
	$term->Attribs->{autolist} = 0;

	$term->Attribs->{completion_function} = sub {
		$self->completion_function(@_);
	};

	$term->Attribs->{beat} = sub {
		# Check on things in the background here; called every second there is no input from the user
	};

	$term->bindkey('^Z', sub {
		# The Term::ReadLine::Zoid uses Term::ReadKey in 'raw' mode which disables all signals
		# If we can find a way to background ourselves at this point, that's the only option that I can see
		$self->log_info("Backgrounding is not currently possible");
	});

	$term->bindkey('^D', sub {
		print "\n";
		$self->app->shutdown();
	});

	$term->bindkey('return', sub { $self->return_key });



( run in 0.604 second using v1.01-cache-2.11-cpan-fe3c2283af0 )