Sha256: 572a9bdb749fd5e55ce36c3317a65f032aabb913571dd681279b9d7408a3305d

Contents?: true

Size: 1.04 KB

Versions: 14

Compression:

Stored size: 1.04 KB

Contents

module Brightbox
  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
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
brightbox-cli-0.18.1 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.18.0 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.5 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.4 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.3 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.2 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.1 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.17.0 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.16.0 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.15.0 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.14.1 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.14.0 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.13.1 lib/brightbox-cli/commands/users-update.rb
brightbox-cli-0.13.0 lib/brightbox-cli/commands/users-update.rb