| 1 | #!/usr/local/bin/perl | ||
| 2 | package SFDC; | ||
| 3 | # ABSTRACT: Command tool for interacting with Salesforce.com | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | use 5.10.0; | ||
| 8 | |||
| 9 | our $VERSION = '0.14'; # TRIAL VERSION | ||
| 10 | |||
| 11 | use App::SFDC; | ||
| 12 | |||
| 13 | sub usage { | ||
| 14 | |||
| 15 | join "\n", | ||
| 16 | "SFDC: Tools for interacting with Salesforce.com", | ||
| 17 | @App::SFDC::commands | ||
| 18 | ? ( | ||
| 19 | "Installed commands:", | ||
| 20 | map {"\t$_"} @App::SFDC::commands, | ||
| 21 | "\nFor more detail, run: SFDC <command> --usage" | ||
| 22 | ) | ||
| 23 | : ( | ||
| 24 | "SFDC: Tools for interacting with Salesforce.com", | ||
| 25 | "It doesn't look like you have any modules installed!", | ||
| 26 | "Try searching CPAN for App::SFDC::Command" | ||
| 27 | ) | ||
| 28 | } | ||
| 29 | |||
| 30 | # The use of shift HAS SIDE EFFECTS. Note that child modules are invoked using | ||
| 31 | # Getopt::Long, which operates on @ARGV; when this program is invoked, we | ||
| 32 | # expect @ARGV to start with an operation which would be invalid as input to | ||
| 33 | # GetOptions, which is why we shift instead of using $_[0] | ||
| 34 | |||
| 35 | my $command = shift; | ||
| 36 | exit 1 unless do { | ||
| 37 | if ($command && grep {/$command/} @App::SFDC::commands) { | ||
| 38 | "App::SFDC::Command::$command"->new_with_options->execute(); | ||
| 39 | } else { | ||
| 40 | print usage; | ||
| 41 | } | ||
| 42 | } | ||
| 43 | |||
| 44 | __END__ |