summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/scripts/context/ruby/base/switch.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/scripts/context/ruby/base/switch.rb')
-rw-r--r--Master/texmf-dist/scripts/context/ruby/base/switch.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/Master/texmf-dist/scripts/context/ruby/base/switch.rb b/Master/texmf-dist/scripts/context/ruby/base/switch.rb
index 5187a795f03..19eced42495 100644
--- a/Master/texmf-dist/scripts/context/ruby/base/switch.rb
+++ b/Master/texmf-dist/scripts/context/ruby/base/switch.rb
@@ -86,7 +86,7 @@ module CommandBase
def initialize(commandline,logger,banner)
@commandline, @logger, @banner = commandline, logger, banner
- @forcenewline, @versiondone = false, false
+ @forcenewline, @versiondone, @error = false, false, false
version if @commandline.option('version')
end
@@ -117,6 +117,23 @@ module CommandBase
initlogger ; @logger.report(str)
end
+ def seterror
+ @error = true
+ end
+
+ def error?
+ return @error
+ end
+
+ def exit
+ if @error then Kernel.exit(1) else Kernel.exit(0) end
+ end
+
+ def execute(str=nil)
+ send(str || action || 'main')
+ exit
+ end
+
def debug(*str)
initlogger ; @logger.debug(str)
end