From c073ecf0dd10f05b26b904e2d56d22e8fa845126 Mon Sep 17 00:00:00 2001 From: Bill Ferguson Date: Sat, 3 Mar 2018 20:22:47 -0500 Subject: [PATCH] Added check_os to lib/dtutils.lua so that scripts can check compatibility with the current operating system --- lib/dtutils.lua | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/lib/dtutils.lua b/lib/dtutils.lua index 02888a8..abe51d6 100644 --- a/lib/dtutils.lua +++ b/lib/dtutils.lua @@ -32,7 +32,7 @@ local dt = require "darktable" local log = require "lib/dtutils.log" -dt.configuration.check_version(...,{3,0,0},{4,0,0},{5,0,0}) +dt.configuration.check_version(...,{5,0,0}) dtutils.libdoc.functions["split"] = { Name = [[split]], @@ -215,4 +215,37 @@ function dtutils.spairs(_table, order) -- Code copied from http://stackoverflow. end end +dtutils.libdoc.functions["check_os"] = { + Name = [[check_os]], + Synopsis = [[check that the operating system is supported]], + Usage = [[local du = require "lib/dtutils" + + local result = du.check_os(operating_systems) + operating_systems - a table of operating system names such as {"windows","linux","macos","unix"}]], + Description = [[check_os checks a supplied table of operating systems against the operating system the + script is running on and returns true if the OS is in the list, otherwise false]], + Return_Value = [[result - boolean - true if the operating system is supported, false if not.]], + Limitations = [[]], + Example = [[local du = require "lib/dtutils" + if du.check_os({"windows"}) then + -- run the script + else + dt.print("Script