Class: GridCLI::SignupCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- GridCLI::SignupCommand
- Defined in:
- lib/gridcli/commands/signup.rb
Instance Attribute Summary
Attributes inherited from BaseCommand
Instance Method Summary collapse
-
#initialize ⇒ SignupCommand
constructor
A new instance of SignupCommand.
- #run(args) ⇒ Object
- #usage ⇒ Object
Methods inherited from BaseCommand
#add_format_option, #add_option, #error, #log, #output_format, #parse_dates, #parse_opts, #pop_arg, #pprint
Constructor Details
#initialize ⇒ SignupCommand
Returns a new instance of SignupCommand.
3 4 5 |
# File 'lib/gridcli/commands/signup.rb', line 3 def initialize super "signup", "Create an account on the grid" end |
Instance Method Details
#run(args) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/gridcli/commands/signup.rb', line 11 def run(args) # handle options usage if args.length == 0 username = args.shift parse_opts args username = GridCLI.hooker.invoke :before_signup, username @config["username"] = username @config.save begin log "Trying to create new user with name '#{username}'" User.new(:username => username, :token => @config['token']).save puts "New user created. You are now known as '#{username}'" rescue ActiveResource::ClientError puts "Sorry, username '#{username}' already exists or contains non-alphanumeric characters." end end |
#usage ⇒ Object
7 8 9 |
# File 'lib/gridcli/commands/signup.rb', line 7 def usage super "<username>" end |