diff --git a/Changes b/Changes index 795f242..312fd7e 100644 --- a/Changes +++ b/Changes @@ -1,4 +1,5 @@ + Add script/dwimmer to enable adding user from the command line. Enable some special characters in the filename: space ( ), dot (.), $, @ and %. Eliminate cache from the Ajax get requests as IE (both 8 and 9) would cache by default. diff --git a/Makefile.PL b/Makefile.PL index 0076331..6948087 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -55,6 +55,7 @@ bugtracker 'http://github.com/szabgab/dwimmer'; repository 'http://github.com/szabgab/dwimmer'; install_script 'script/dwimmer_setup.pl'; +install_script 'script/dwimmer'; # Copy files to share before installing (but it is not included in the distribution) foreach my $module (qw(File::Copy::Recursive File::Spec)) { diff --git a/script/dwimmer b/script/dwimmer new file mode 100644 index 0000000..6464efc --- /dev/null +++ b/script/dwimmer @@ -0,0 +1,59 @@ +#!/usr/bin/perl +use strict; +use warnings; + +use Data::Dumper; +use Getopt::Long qw(GetOptions); +use Pod::Usage qw(pod2usage); + +my %opt; +GetOptions(\%opt, + 'url=s', + 'username=s', + 'password=s', +) or pod2usage(); + +$opt{username} ||= 'admin'; +pod2usage() if not $opt{url} or not $opt{username} or not $opt{password}; + +my %commands = ( + add_user => [qw(uname email password)], +); + +use Dwimmer::Client; + + +my $cmd = shift; + +pod2usage() if not $cmd or $cmd eq 'help'; + +if ($commands{$cmd}) { + my %data; + my @fields = @{ $commands{$cmd} }; + @data{ @fields } = @ARGV; + # TODO check if all the params are available + + if ($cmd eq 'add_user') { + $data{verify} = 'verified'; + } + + my $dw = Dwimmer::Client->new( host => $opt{url} ); + $dw->login( $opt{username}, $opt{password} ); + my $r = $dw->$cmd(%data); + print Dumper $r; +} else { + pod2usage(); +} + +=head1 SYNOPSIS + +REQUIRED PARAMETERS: + + add_user USERNAME EMAIL PASSWORD + + --username OF_CURRENT_USER (admin by default) + --password OF_CURRENT_USER + --url OF_DWIMMER_SITE + +=cut +