Check libs
Program that allows you to manage your libraries, check their versions and update them!

Usage

Use checklibs -h or checklibs -help to get all optional parameters of this program, you can use multiple parameters at once!
Usage

Reusable Code

  • You can use TableHandler and LibHandler modules.
  • parse_parameters is a useful function that parses params and gives you parameters list with needed data
parse_parameters = function(parameters, allowed_flags, data_flags, optional_data_flags)
	is_flag = function(parameter)
		if parameter[0] == "-" then 
			return true
		else
			return false
		end if
	end function
	
	is_allowed = function(flag)
		if allowed_flags.indexOf(flag) != null then 
			return true
		else
			return false
		end if
	end function

	is_data = function(flag)
		if data_flags.hasIndex(flag) != null then
			return true
		else
			return false
		end if
	end function

	is_optional_data = function(flag)
		if optional_data_flags.indexOf(flag) != null then
			return true
		else
			return false
		end if
	end function

	invalid_option = function(flag, flag_help)
		exit("<color=red>Wrong argument. Usage: ""<b>" + flag + " " + flag_help + "</b>""")
	end function
	
	output = []
	if parameters.len == 0 then return output
	for i in range(0, parameters.len - 1)
		parameter = parameters[i]
		if is_flag(parameter) then
			print(is_data(parameter) + " " + is_optional_data(parameter))
			if not is_allowed(parameter) then exit("<color=red>Flag ""<b>" + parameter + "</b>"" is not allowed!")
			if not is_data(parameter) and not is_optional_data(parameter) then
				output.push({"data_flag": false, "flag": parameter})
			else if is_data(parameter) and not is_optional_data(parameter) then
				if not parameters.hasIndex(i+1) or is_flag(parameters[i+1]) then invalid_option(parameter, data_flags[parameter])
				output.push({"data_flag": true, "flag": parameter, "data": parameters[i+1]})
			else
				if parameters.hasIndex(i+1) and not is_flag(parameters[i+1]) then
					output.push({"data_flag": true, "flag": parameter, "data": parameters[i+1]})
				else
					output.push({"data_flag": false, "flag": parameter})
				end if
			end if
		end if
	end for
	return output
end function
Usage:
parameters = parse_parameters(params, ["-h, -d, -p"], {"-d": "[data]"}, ["-p"]) 
*first argument is parameters reserved variable, second is all allowed flags, third is only data flags and fourth is only optional data flags
print(parameters)
CMD:
test -h -d some_useful_data -p
-> [{"data_flag": 0, "flag": "-h"}, {"data_flag": 1, "flag": "-d", "data": "some_useful_data"}, {"data_flag": 0, "flag": "-p"}]
Files
Builds
check-libs_checklibs
Download build

Post's comments

post does not have comments.

You need to log in to write a comment.