Skip to content

Commit

Permalink
Merge branch 'hotfix/adduser'
Browse files Browse the repository at this point in the history
  • Loading branch information
szabgab committed Sep 14, 2011
2 parents 13a58e0 + d09a5b2 commit 23eb67b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 0 deletions.
1 change: 1 addition & 0 deletions 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.

Expand Down
1 change: 1 addition & 0 deletions Makefile.PL
Expand Up @@ -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)) {
Expand Down
59 changes: 59 additions & 0 deletions 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

0 comments on commit 23eb67b

Please sign in to comment.