<commit_before>require_relative 'base'

module WavefrontDisplay
  #
  # Format human-readable output for user management.
  #
  class UserGroup < Base
    def do_list_brief
      multicolumn(:id, :name, :userCount)
    end

    def do_delete
      puts "Deleted user group '#{options[:'<id>']}'."
    end

    def do_add_user
      puts format('Added %s to %s.', options[:'<user>'].join(', '),
                  options[:'<id>']).fold(TW, 0)
    end

    def do_remove_user
      puts format("Removed '%s' from %s.", options[:'<user>'].join(', '),
                  options[:'<id>']).fold(TW, 0)
    end

    def do_grant
      puts format("Granted '%s' permission to %s.",
                  options[:'<permission>'], options[:'<id>'])
    end

    def do_revoke
      puts format("Revoked '%s' permission from %s.",
                  options[:'<permission>'], options[:'<id>'])
    end

    def do_users
      if data.users.empty?
        puts 'No users in group.'
      else
        data.users.each { |u| puts u }
      end
    end

    def do_permissions
      if data.permissions.empty?
        puts 'Group has no permissions.'
      else
        data.permissions.each { |u| puts u }
      end
    end
  end
end<commit_msg>make output quoting more uniform<commit_after>require_relative 'base'

module WavefrontDisplay
  #
  # Format human-readable output for user management.
  #
  class UserGroup < Base
    def do_list_brief
      multicolumn(:id, :name, :userCount)
    end

    def do_delete
      puts "Deleted user group '#{options[:'<id>']}'."
    end

    def do_add_user
      puts format("Added %s to '%s'.", quoted_users,
                  options[:'<id>']).fold(TW, 0)
    end

    def do_remove_user
      puts format("Removed %s from '%s'.", quoted_users,
                  options[:'<id>']).fold(TW, 0)
    end

    def do_grant
      puts format("Granted '%s' permission to '%s'.",
                  options[:'<permission>'], options[:'<id>'])
    end

    def do_revoke
      puts format("Revoked '%s' permission from '%s'.",
                  options[:'<permission>'], options[:'<id>'])
    end

    def do_users
      puts(if ! data.include?(:users) || data[:users].empty?
             "No users in group '#{options[:'<id>']}'."
           else
             data[:users]
           end)
    end

    def do_permissions
      puts(if ! data.include?(:permissions) || data[:permissions].empty?
            "Group '#{options[:'<id>']}' has no permissions."
           else
            data[:permissions]
           end)
    end

    private

    def quoted_users
      options[:'<user>'].map{ |u| "'#{u}'" }.join(', ')
    end
  end
end
{'fraction_non_alphanumeric': 0.14947289156626506, 'fraction_numerical': 0.0015060240963855422, 'mean_word_length': 2.1332547169811322, 'pattern_counts': {'":': 0, '<': 24, '<?xml version=': 0, '>': 22, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6945176', 'n_tokens_mistral': 867, 'n_tokens_neox': 838, 'n_words': 217}