diff --git a/plugins/adduser b/plugins/adduser new file mode 100755 index 0000000..15a07de --- /dev/null +++ b/plugins/adduser @@ -0,0 +1,32 @@ +#!perl + +HELP "adduser " => "Create an account"; + +sub command :Tab(adduser) { + my ($self, $cart, $command) = @_; + + $command eq 'adduser' or return NEXT; + + if ($cart->size) { + return REJECT, "Create the account *before* scanning things."; + } + + return "Name for the new account", \&username; +} + +sub username { + my ($self, $cart, $name) = @_; + + return REJECT, "Sorry, whitespace is not allowed." + if $name =~ /\s/; + + return REJECT, "That's too numeric to be a user name." + if defined parse_amount($name); + + return REJECT, "That name already exists." + if defined parse_user($name); + + RevBank::Users::create( $name ); + + return ACCEPT; +} diff --git a/revbank.plugins b/revbank.plugins index c3442c3..ac08ca5 100644 --- a/revbank.plugins +++ b/revbank.plugins @@ -11,13 +11,16 @@ undo give grandtotal take -nyan # fun, but not compatible with dumb terminals pfand # makes little sense in a self service environment stock +unlisted +#warnings +adduser beep_terminal -game # Scan-foo game +#nyan # fun, but not compatible with dumb terminals +#game # Scan-foo game # Then, plugins that apply heuristics @@ -26,3 +29,5 @@ market # also matches product IDs withdraw # matches amounts users # matches usernames deposit # wants to be after 'users' +#deposit_methods # Extra options for 'deposit'. Edit/configure first! +repeat