Property definitions

privileges $ OptionUserAndGroup :: defaultinit
# Option to ask for a username and group
class OptionUserAndGroup
	super OptionParameter

	redef type VALUE: nullable UserGroup

	# Create an `OptionUserAndGroup` for dropping privileges
	init for_dropping_privileges
	do
		init("Drop privileges to user:group or simply user", null, ["-u", "--usergroup"])
	end

	redef fun convert(str)
	do
		var words = str.split(":")
		if words.length == 1 then
			return new UserGroup(str, null)
		else if words.length == 2 then
			return new UserGroup(words[0], words[1])
		else
			errors.add("Option {names.join(", ")} expected parameter in the format \"user:group\" or simply \"user\".\n")
			return null
		end
	end
end
lib/privileges/privileges.nit:73,1--97,3