Mercurial > cgi-bin > hgweb.cgi > ImagePrep
comparison src/name/blackcap/imageprep/Main.kt @ 5:884f1415a330
Rationalized directory management.
author | David Barts <n5jrn@me.com> |
---|---|
date | Fri, 17 Jul 2020 17:11:43 -0700 |
parents | 5234e4500d45 |
children | 5fa5d15b4a7b |
comparison
equal
deleted
inserted
replaced
4:5234e4500d45 | 5:884f1415a330 |
---|---|
32 mainFrame.setVisible(true) | 32 mainFrame.setVisible(true) |
33 } | 33 } |
34 } | 34 } |
35 | 35 |
36 fun main(args: Array<String>) { | 36 fun main(args: Array<String>) { |
37 /* start up */ | |
37 LOGGER.log(Level.INFO, "beginning execution") | 38 LOGGER.log(Level.INFO, "beginning execution") |
38 if (OS.type == OS.MAC) { | 39 if (OS.type == OS.MAC) { |
39 System.setProperty("apple.laf.useScreenMenuBar", "true") | 40 System.setProperty("apple.laf.useScreenMenuBar", "true") |
40 } | 41 } |
41 | 42 |
43 /* parse command line */ | |
42 if (Settings.outputToInputDir) | 44 if (Settings.outputToInputDir) |
43 Settings.outputTo = System.getProperty("user.dir") | 45 Settings.outputTo = System.getProperty("user.dir") |
44 val options = Options().apply { | 46 val options = Options().apply { |
45 addOption(Option<Unit>("?", "help", false, "Print this help message.")) | 47 addOption(Option<Unit>("?", "help", false, "Print this help message.")) |
46 addOption(Option<Int>("m", "maxdim", true, "Maximum dimension (default: ${Settings.maxDimension})").apply { | 48 addOption(Option<Int>("m", "maxdim", true, "Maximum dimension (default: ${Settings.maxDimension})").apply { |
54 } | 56 } |
55 }) | 57 }) |
56 addOption(Option<File>("o", "output", true, "Output directory (default: ${Settings.outputTo})").apply { | 58 addOption(Option<File>("o", "output", true, "Output directory (default: ${Settings.outputTo})").apply { |
57 default = File(Settings.outputTo) | 59 default = File(Settings.outputTo) |
58 interpolater = { | 60 interpolater = { |
59 val ret = File(it) | 61 val ret = File(tilde(it)) |
60 if (!ret.exists()) | 62 if (!ret.exists()) |
61 throw InvalidArgumentException("'${it}' does not exist") | 63 throw InvalidArgumentException("'${it}' does not exist") |
62 if (!ret.isDirectory()) | 64 if (!ret.isDirectory()) |
63 throw InvalidArgumentException("'${it}' is not a directory") | 65 throw InvalidArgumentException("'${it}' is not a directory") |
64 Settings.outputTo = ret.canonicalPath | 66 Settings.outputTo = ret.canonicalPath |
77 }) | 79 }) |
78 } | 80 } |
79 val cmdLine: CommandLine? = try { | 81 val cmdLine: CommandLine? = try { |
80 PromptingParser().parse(options, args) | 82 PromptingParser().parse(options, args) |
81 } catch (e: ParseException) { | 83 } catch (e: ParseException) { |
82 System.err.println("${Application.MYNAME}: syntax error - ${e.message}") | 84 System.err.println("${Application.MYNAME}: Syntax error - ${e.message}") |
83 System.exit(2) | 85 System.exit(2) |
84 null | 86 null |
85 } | 87 } |
86 if (cmdLine!!.hasOption("help")) { | 88 if (cmdLine!!.hasOption("help")) { |
87 val usage = Application.MYNAME + " [--maxdim=integer] [--output=directory] [--quality=integer] file [...]" | 89 val usage = Application.MYNAME + " [--maxdim=integer] [--output=directory] [--quality=integer] file [...]" |
88 HelpFormatter().printHelp(usage, options, false); | 90 HelpFormatter().printHelp(usage, options, false); |
89 System.exit(0); | 91 System.exit(0); |
90 } | 92 } |
91 | 93 |
94 /* launch GUI */ | |
92 inSwingThread { | 95 inSwingThread { |
93 Application.initialize() | 96 Application.initialize() |
94 for (fileName in cmdLine!!.args) | 97 for (fileName in cmdLine!!.args) |
95 RotateDialog.makeDialog(File(fileName)) | 98 RotateDialog.makeDialog(File(fileName)) |
96 } | 99 } |