App-Goto

 view release on metacpan or  search on metacpan

script/g2  view on Meta::CPAN

#!/usr/bin/env perl

use v5.12;
use warnings;
use Config::Tiny;
use App::Goto;

# Quit with help text if asked for it/didn't ask for anything
if (!@ARGV || $ARGV[0] =~ /^--?h/) {
    say 'g2: shortcut utility';
    say 'g2 <label for desired host> [label for command to run remotely]';
    say 'Requires valid config file at /etc/g2rc or ~/.g2rc';
    exit;
    }

# Not helping, so check for a config
my $my_config_file  = "$ENV{HOME}/.g2rc";
my $etc_config_file = "/etc/g2rc";

my $my_config  = Config::Tiny->read( $my_config_file );
my $etc_config = Config::Tiny->read( $etc_config_file );

script/g2  view on Meta::CPAN


unless ($config->{hosts}) {
    die "No valid config file found";
    }

# Config file exists, command has been given. Do what's needed
my $goto = App::Goto->new({ args => \@ARGV, config => $config });

# Handle bad input
unless ($goto->is_success) {
    say $goto->error();
    exit
    }

# Looks like we're good to go
if ($ENV{G2DB}) {
    say $goto->cmd();
    }
else {
    system( $goto->cmd() );
    }

# PODNAME: g2

# ABSTRACT: g2 - command-line application to reduce typing needed to access a server

# VERSION



( run in 0.421 second using v1.01-cache-2.11-cpan-5511b514fd6 )