| 1 | package Exobrain::Idonethis; | ||
| 2 | use Moose; | ||
| 3 | use Exobrain::Config; | ||
| 4 | use feature qw(say); | ||
| 5 | |||
| 6 | # ABSTRACT: Idonethis components for Exobrain | ||
| 7 | our $VERSION = '1.08'; # VERSION | ||
| 8 | |||
| 9 | with 'Exobrain::Component'; | ||
| 10 | |||
| 11 | sub component { "idonethis" }; | ||
| 12 | |||
| 13 | sub services { | ||
| 14 | return ( | ||
| 15 | sink => 'Idonethis::Sink', | ||
| 16 | ); | ||
| 17 | } | ||
| 18 | |||
| 19 | sub setup { | ||
| 20 | |||
| 21 | # Load module and die swiftly on failure | ||
| 22 | eval 'use WebService::Idonethis'; | ||
| 23 | die $@ if $@; | ||
| 24 | |||
| 25 | say "Welcome to the Exobrain::Idonethis setup process."; | ||
| 26 | say "Nothing fancy here, we just need a username/email and password.\n"; | ||
| 27 | |||
| 28 | print "Username or email: "; | ||
| 29 | chomp( my $username = <STDIN> ); | ||
| 30 | |||
| 31 | print "Password: "; | ||
| 32 | chomp( my $password = <STDIN> ); | ||
| 33 | |||
| 34 | # Check to see if we auth okay. | ||
| 35 | |||
| 36 | my $idt = WebService::Idonethis->new( | ||
| 37 | user => $username, | ||
| 38 | pass => $password, | ||
| 39 | ); | ||
| 40 | |||
| 41 | say "\nThanks! Writing configuration..."; | ||
| 42 | |||
| 43 | my $config = | ||
| 44 | "[Components]\n" . | ||
| 45 | "Idonethis=$VERSION\n\n" . | ||
| 46 | |||
| 47 | "[Idonethis]\n" . | ||
| 48 | "user = $username\n" . | ||
| 49 | "pass = $password\n" | ||
| 50 | ; | ||
| 51 | |||
| 52 | my $filename = Exobrain::Config->write_config('Idonethis.ini', $config); | ||
| 53 | |||
| 54 | say "\nConfig written to $filename. Have a nice day!"; | ||
| 55 | |||
| 56 | return; | ||
| 57 | } | ||
| 58 | |||
| 59 | 1; | ||
| 60 | |||
| 61 | __END__ |