bin/gitauth in brownbeagle-gitauth-0.0.4.0 vs bin/gitauth in brownbeagle-gitauth-0.0.4.1
- old
+ new
@@ -72,16 +72,17 @@
end
end
- a.controller! :web_app, "Starts the gitauth frontend using the default sintra runner"
+ a.controller!(:web_app, "Starts the gitauth frontend using the default sintra runner", :skip_path => true)
a.option(:force, "Skip the verification / confirmation part of adding the permissions")
a.option(:type, "The type of permissions - one of all, read, write or none. Defaults to all")
- full_desc = "Gives a specific user or group the specified permissions to a given repository - pass '-h' for more information"
+ full_desc = "Gives a specific user or group the specified permissions to a given repository"
a.add("permissions REPOSITORY USER-OR-GROUP", full_desc) do |repo, target, options|
+ GitAuth.prepare
permissions = options[:type] || 'all'
if !%w(all read write none).include? permissions
die! "'#{permissions}' is not a valid permission type. It must be all, read, write or none"
end
@@ -98,11 +99,11 @@
puts "Permissions updated."
else
puts "Permissions not added, exiting."
end
end
-
+
a.option(:admin, "Makes a user an admin user")
a.add("add-user NAME PATH-TO-PUBLIC-KEY", "Creates a user with a given public key") do |name, ssh_key, options|
GitAuth.prepare
die! "'#{ssh_key}' is not a valid path to a public key" if !File.file?(ssh_key)
admin = !!options[:admin]
@@ -188,8 +189,47 @@
a.add("usage", "Prints out the sample usage instructions") do |options|
File.open(GitAuth::BASE_DIR.join("USAGE")) do |f|
f.each_line { |line| puts line }
end
+ end
+
+ a.add("show-repo NAME", "Shows information for a repository with a given name") do |name, options|
+ GitAuth.prepare
+ repo = GitAuth::Repo.get(name)
+ die! "Unknown repository '#{repo}'" if repo.blank?
+ puts "Repository Name: #{repo.name}"
+ puts "Repository Path: #{repo.path}"
+ puts "Actual Path: #{repo.real_path}"
+ puts "\nRead Permissions:"
+ read_perms = repo.permissions.fetch(:read, [])
+ read_perms.each { |item| puts " - #{item}" }
+ puts " - No read permissions" if read_perms.blank?
+ puts "\nWrite Permissions:"
+ write_perms = repo.permissions.fetch(:write, [])
+ write_perms.each { |item| puts " - #{item}" }
+ puts " - No write permissions" if write_perms.blank?
+ end
+
+ a.add("show-group NAME", "Shows information for a group with a given name") do |name, options|
+ GitAuth.prepare
+ group = GitAuth::Group.get(name)
+ die! "Unable to find a group named '#{name}'" if group.blank?
+ puts "Group Name: #{group.name}"
+ puts "Reference Name: #{group.to_s}"
+ puts "\nGroup Members:"
+ group.members.each { |member| puts " - #{member}" }
+ puts " - This group has no members" if group.members.blank?
+ end
+
+ a.add("show-user NAME", "Shows details for a user with a specific name") do |name, options|
+ GitAuth.prepare
+ user = GitAuth::User.get(name)
+ die! "Unable to find a user named '#{name}'" if user.blank?
+ puts "User Name: #{user.name}"
+ groups = user.groups
+ puts "\nGroups:"
+ puts " - This user isn't a member of any groups" if groups.blank?
+ groups.each { |g| puts " - #{g.to_s}" }
end
end
\ No newline at end of file