Sha256: 2b5c50330f3d3725e135a7cf992299438fad1dd3224c2d15861fbea6310f56e6

Contents?: true

Size: 894 Bytes

Versions: 7

Compression:

Stored size: 894 Bytes

Contents

desc 'Update user details'
arg_name 'user-id...'
command [:update] do |c|
  c.desc "Path to public ssh key file"
  c.long_desc "This is the path to the public ssh key that you'd like to use for new servers. You can specify '-' to read from stdin"
  c.flag [:f, "ssh-key"]

  c.desc "Name"
  c.flag [:n, "name"]

  c.action do |global_options, options, args|

    raise "You must specify the user id as the first argument" if args.empty?

    user = User.find args.first
      
    if options[:f] == '-'
      user.ssh_key = STDIN.read
    elsif options[:f]
      File.open(File.expand_path(options[:f])) { |f| user.ssh_key = f.read }
    end

    if options[:n]
      user.name = options[:n]
    end

    user.save

    table_opts = global_options.merge({
      :vertical => true,
      :fields => [:id, :name, :email_address, :ssh_key ]
    })

    render_table([user], table_opts)

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bbcloud-0.11.2 lib/bbcloud/commands/users-update.rb
bbcloud-0.11.1 lib/bbcloud/commands/users-update.rb
bbcloud-0.11.0 lib/bbcloud/commands/users-update.rb
bbcloud-0.10.1 lib/bbcloud/commands/users-update.rb
bbcloud-0.9.2 lib/bbcloud/commands/users-update.rb
bbcloud-0.9.1 lib/bbcloud/commands/users-update.rb
bbcloud-0.9 lib/bbcloud/commands/users-update.rb