Sha256: a4f64683fafa304b120d1d2ae676a344e57b63ec37638f6bedcb770559a8e9f3

Contents?: true

Size: 978 Bytes

Versions: 6

Compression:

Stored size: 978 Bytes

Contents

namespace :user do
  desc 'Add a new user. rake user:create <username>'
  task :create, [:username] do |_t, args|
    puts DH.useradd(args[:username])[:key]
  end

  desc 'Rename a user. rake user:rename <oldname> <newname>'
  task :rename, [:oldname, :newname] do |_t, args|
    user = DH.user(args[:oldname])
    abort("Unknown user #{args[:oldname]}") if user.nil?
    DH.userdel(user[:username])
    DH.useradd(args[:newname], user[:key])
    puts "User #{args[:oldname]} renamed to #{args[:newname]}"
  end

  desc 'Delete a user. rake user:delete <username>'
  task :delete, [:username] do |_t, args|
    DH.userdel(args[:username])
  end

  desc 'Set user key. rake user:setkey <username> <key>'
  task :setkey, [:username, :key] do |_t, args|
    user = DH.user(args[:username])
    abort("Unknown user #{args[:username]}") if user.nil?
    puts DH.useradd(args[:username], args[:key])
  end
end

desc 'List users'
task :user do
  puts DH.users.keys.sort.join("\n")
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
gaptool-server-0.8.5 tasks/user.rb
gaptool-server-0.8.4 tasks/user.rb
gaptool-server-0.8.3 tasks/user.rb
gaptool-server-0.8.2 tasks/user.rb
gaptool-server-0.8.1 tasks/user.rb
gaptool-server-0.8.0 tasks/user.rb