Sha256: be37797c2615264991f3f15d586af7700775b29506788e077cd6be65223ce7c4

Contents?: true

Size: 1.04 KB

Versions: 17

Compression:

Stored size: 1.04 KB

Contents

module Brightbox
  command [:users] do |cmd|
    cmd.desc I18n.t("users.update.desc")
    cmd.arg_name "user-id..."
    cmd.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 I18n.t("options.name.desc")
      c.flag %i[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

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

        user.save

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

        render_table([user], table_opts)
      end
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
brightbox-cli-5.0.0.rc2 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-5.0.0.rc1 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-5.0.0.alpha lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.8.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.7.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.6.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.5.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.5.0.rc1 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.4.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.3.2 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.3.1 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.3.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.2.1 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.2.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.1.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.0.0 lib/brightbox-cli/commands/users/update.rb
brightbox-cli-4.0.0.rc2 lib/brightbox-cli/commands/users/update.rb