Sha256: 656ad5e54a0054b9f86cd36d1bf01f98dc6a2caff13389692b4f4e574a1172ac

Contents?: true

Size: 1.54 KB

Versions: 66

Compression:

Stored size: 1.54 KB

Contents

module TreasureData
module Command

  def password_change(op)
    op.cmd_parse

    old_password = nil
    password = nil

    begin
      system "stty -echo"  # TODO termios
      print "Old password (typing will be hidden): "
      old_password = STDIN.gets || ""
      old_password = old_password[0..-2]  # strip \n
    rescue Interrupt
      $stderr.print "\ncanceled."
      exit 1
    ensure
      system "stty echo"   # TODO termios
      print "\n"
    end

    if old_password.empty?
      $stderr.puts "canceled."
      exit 0
    end

    3.times do
      begin
        system "stty -echo"  # TODO termios
        print "New password (typing will be hidden): "
        password = STDIN.gets || ""
        password = password[0..-2]  # strip \n
      rescue Interrupt
        $stderr.print "\ncanceled."
        exit 1
      ensure
        system "stty echo"   # TODO termios
        print "\n"
      end

      if password.empty?
        $stderr.puts "canceled."
        exit 0
      end

      begin
        system "stty -echo"  # TODO termios
        print "Retype new password: "
        password2 = STDIN.gets || ""
        password2 = password2[0..-2]  # strip \n
      rescue Interrupt
        $stderr.print "\ncanceled."
        exit 1
      ensure
        system "stty echo"   # TODO termios
        print "\n"
      end

      if password == password2
        break
      end

      puts "Doesn't match."
    end

    client = get_client(:ssl => true)

    client.change_my_password(old_password, password)

    $stderr.puts "Password changed."
  end

end
end

Version data entries

66 entries across 66 versions & 1 rubygems

Version Path
td-0.11.9 lib/td/command/password.rb
td-0.11.8.2 lib/td/command/password.rb
td-0.11.8.1 lib/td/command/password.rb
td-0.11.8 lib/td/command/password.rb
td-0.11.7 lib/td/command/password.rb
td-0.11.6 lib/td/command/password.rb
td-0.11.5 lib/td/command/password.rb
td-0.11.4 lib/td/command/password.rb
td-0.11.3 lib/td/command/password.rb
td-0.11.2 lib/td/command/password.rb
td-0.11.1 lib/td/command/password.rb
td-0.10.99 lib/td/command/password.rb
td-0.10.98 lib/td/command/password.rb
td-0.10.97 lib/td/command/password.rb
td-0.10.96 lib/td/command/password.rb
td-0.10.95 lib/td/command/password.rb
td-0.10.94 lib/td/command/password.rb
td-0.10.93 lib/td/command/password.rb
td-0.10.92 lib/td/command/password.rb
td-0.10.91 lib/td/command/password.rb