Mercurial > cgi-bin > hgweb.cgi > ImagePrep
annotate src/name/blackcap/imageprep/Settings.kt @ 4:5234e4500d45
Command-line arguments (only partially tested).
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 17 Jul 2020 14:51:41 -0700 |
parents | a6f9b51d5e8d |
children | 884f1415a330 |
rev | line source |
---|---|
0 | 1 /* |
2 * Our settings. Basically just some parsed properties. | |
3 */ | |
4 package name.blackcap.imageprep | |
5 | |
1 | 6 import java.io.File |
7 | |
0 | 8 /* work around name shadowing */ |
9 private val _PROPS = PROPERTIES | |
10 | |
11 object Settings { | |
2 | 12 private val homeDir = System.getProperty("user.home") |
4
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
13 var maxDimension = _PROPS.getProperty("maxDimension").toInt() |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
14 var outputQuality = _PROPS.getProperty("outputQuality").toInt() |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
15 var outputSuffix = _PROPS.getProperty("outputSuffix") |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
16 var outputTo = tilde(_PROPS.getProperty("outputTo")) |
5234e4500d45
Command-line arguments (only partially tested).
David Barts <n5jrn@me.com>
parents:
2
diff
changeset
|
17 var outputToInputDir = strToBool(_PROPS.getProperty("outputToInputDir")) |
0 | 18 |
2 | 19 private fun tilde(s: String?): String { |
0 | 20 if (s.isNullOrEmpty()) |
21 return homeDir | |
22 if (s.startsWith("~/") || s.startsWith("~\\")) | |
1 | 23 return File(homeDir, s.substring(2).trimStart(s[1])).toString() |
0 | 24 else |
25 return s | |
26 } | |
27 | |
28 private fun strToBool(s: String): Boolean { | |
29 if (s.isNullOrEmpty()) | |
30 return false | |
31 val c1 = s[0].toLowerCase() | |
32 return c1 == 't' || c1 == 'y' | |
33 } | |
34 } |