Sha256: d04a8e943c6c2bf2e6e3657a9d418a9b5002140d0207cf2efa2f6852cf20672d
Contents?: true
Size: 954 Bytes
Versions: 5
Compression:
Stored size: 954 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 raise "Could not find user #{args.first}" if user.nil? 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
5 entries across 5 versions & 1 rubygems