| 1 | package WebService::Moodle::Simple::CLI; | ||
| 2 | $WebService::Moodle::Simple::CLI::VERSION = '0.06'; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use OptArgs; | ||
| 6 | |||
| 7 | # ABSTRACT: CLI for WebService::Moodle::Simple | ||
| 8 | |||
| 9 | opt help => ( | ||
| 10 | isa => 'Bool', | ||
| 11 | comment => 'print a help message and exit', | ||
| 12 | ishelp => 1, | ||
| 13 | ); | ||
| 14 | |||
| 15 | |||
| 16 | arg command => ( | ||
| 17 | isa => 'SubCmd', | ||
| 18 | comment => 'sub command to run', | ||
| 19 | required => 1, | ||
| 20 | ); | ||
| 21 | |||
| 22 | opt domain => ( | ||
| 23 | isa => 'Str', | ||
| 24 | alias => 'd', | ||
| 25 | comment => 'something like moodle.server.name.com', | ||
| 26 | default => sub { die '--domain [-d] - the moodle server like moodle.example.com is required' }, | ||
| 27 | ); | ||
| 28 | |||
| 29 | opt port => ( | ||
| 30 | isa => 'Int', | ||
| 31 | comment => '--port - The port on which the Moodle service listens', | ||
| 32 | default => 443, | ||
| 33 | ); | ||
| 34 | |||
| 35 | opt timeout => ( | ||
| 36 | isa => 'Int', | ||
| 37 | comment => '--timeout - Seconds we wait for the server to respond', | ||
| 38 | ); | ||
| 39 | |||
| 40 | opt target => ( | ||
| 41 | isa => 'Str', | ||
| 42 | alias => 't', | ||
| 43 | comment => '--target [-t] - The name of the target Moodle service to access', | ||
| 44 | ); | ||
| 45 | |||
| 46 | opt token => ( | ||
| 47 | isa => 'Str', | ||
| 48 | alias => 'o', | ||
| 49 | comment => '--token [-o] - token (required)', | ||
| 50 | ); | ||
| 51 | |||
| 52 | opt scheme => ( | ||
| 53 | isa => 'Str', | ||
| 54 | comment => '--scheme - The uri scheme - defaults to "https"', | ||
| 55 | ); | ||
| 56 | |||
| 57 | subcmd ( | ||
| 58 | cmd => 'add_user', | ||
| 59 | comment => 'Create a Moodle user account', | ||
| 60 | ); | ||
| 61 | |||
| 62 | opt username => ( | ||
| 63 | isa => 'Str', | ||
| 64 | alias => 'u', | ||
| 65 | comment => '--username [-u] - The Moodle username being created', | ||
| 66 | default => sub { die '--username [-u] - username is required' }, | ||
| 67 | ); | ||
| 68 | |||
| 69 | opt firstname => ( | ||
| 70 | isa => 'Str', | ||
| 71 | alias => 'f', | ||
| 72 | comment => '--firstname [-f] - user firstname', | ||
| 73 | default => sub { die '--firstname [-f] - firstname is required' }, | ||
| 74 | ); | ||
| 75 | |||
| 76 | opt lastname => ( | ||
| 77 | isa => 'Str', | ||
| 78 | alias => 'l', | ||
| 79 | comment => '--lastname [-l] - user lastname', | ||
| 80 | default => sub { die '--lastname [-l] - lastname required' }, | ||
| 81 | ); | ||
| 82 | |||
| 83 | opt email => ( | ||
| 84 | isa => 'Str', | ||
| 85 | alias => 'e', | ||
| 86 | comment => '--email [-e] - email (required)', | ||
| 87 | default => sub { die '--email [-e] - email required' }, | ||
| 88 | ); | ||
| 89 | |||
| 90 | |||
| 91 | opt password => ( | ||
| 92 | isa => 'Str', | ||
| 93 | alias => 'p', | ||
| 94 | comment => '--password [-p] - user password (required)', | ||
| 95 | default => sub { die '--password [-p] - user password required' }, | ||
| 96 | ); | ||
| 97 | |||
| 98 | subcmd ( | ||
| 99 | cmd => 'enrol', | ||
| 100 | comment => 'Enrol student into a course', | ||
| 101 | ); | ||
| 102 | |||
| 103 | opt username => ( | ||
| 104 | isa => 'Str', | ||
| 105 | alias => 'u', | ||
| 106 | comment => '--username [-u] - username being enrolled', | ||
| 107 | default => sub { die '--username [-u] - username required' }, | ||
| 108 | ); | ||
| 109 | |||
| 110 | opt course => ( | ||
| 111 | isa => 'Str', | ||
| 112 | alias => 'c', | ||
| 113 | comment => '--course [-c] - The Moodle course being enrolled in', | ||
| 114 | default => sub { die '--course required' }, | ||
| 115 | ); | ||
| 116 | |||
| 117 | |||
| 118 | subcmd ( | ||
| 119 | cmd => 'set_password', | ||
| 120 | comment => 'Update a user account password', | ||
| 121 | ); | ||
| 122 | |||
| 123 | opt username => ( | ||
| 124 | isa => 'Str', | ||
| 125 | alias => 'u', | ||
| 126 | comment => '--username [-u] - username requiring a password reset', | ||
| 127 | default => sub { die '--username [-u] - username required' }, | ||
| 128 | ); | ||
| 129 | |||
| 130 | opt password => ( | ||
| 131 | isa => 'Str', | ||
| 132 | alias => 'p', | ||
| 133 | comment => '--password [-p] - user password', | ||
| 134 | default => sub { die '--password [-p] - password required' }, | ||
| 135 | ); | ||
| 136 | |||
| 137 | subcmd ( | ||
| 138 | cmd => 'suspend', | ||
| 139 | comment => 'Suspend a user account', | ||
| 140 | ); | ||
| 141 | |||
| 142 | opt username => ( | ||
| 143 | isa => 'Str', | ||
| 144 | alias => 'u', | ||
| 145 | comment => '--username [-u] - username of account to be suspended', | ||
| 146 | default => sub { die '--username [-u] - username required' }, | ||
| 147 | ); | ||
| 148 | |||
| 149 | opt undo => ( | ||
| 150 | isa => 'Bool', | ||
| 151 | comment => '--undo un-suspend a user', | ||
| 152 | default => 0, | ||
| 153 | ); | ||
| 154 | |||
| 155 | subcmd ( | ||
| 156 | cmd => 'check_password', | ||
| 157 | comment => 'Check that the username/password is a correct combination', | ||
| 158 | ); | ||
| 159 | |||
| 160 | opt username => ( | ||
| 161 | isa => 'Str', | ||
| 162 | alias => 'u', | ||
| 163 | comment => '--username [-u] - the user of the password', | ||
| 164 | default => sub { die '--username [-u] - username required' }, | ||
| 165 | ); | ||
| 166 | |||
| 167 | opt password => ( | ||
| 168 | isa => 'Str', | ||
| 169 | alias => 'p', | ||
| 170 | comment => '--password [-p] - user password', | ||
| 171 | default => sub { die '--password [-p] - password required' }, | ||
| 172 | ); | ||
| 173 | |||
| 174 | subcmd ( | ||
| 175 | cmd => 'get_user', | ||
| 176 | comment => 'Get data about username', | ||
| 177 | ); | ||
| 178 | |||
| 179 | opt username => ( | ||
| 180 | isa => 'Str', | ||
| 181 | alias => 'u', | ||
| 182 | comment => '--username [-u] - the user of the password', | ||
| 183 | default => sub { die '--username [-u] - username required' }, | ||
| 184 | ); | ||
| 185 | |||
| 186 | |||
| 187 | 1; | ||
| 188 | |||
| 189 | __END__ |