main.tcl 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env tclsh
  2. #
  3. # Copyright (c) 2015-2017 OpenIndex.de
  4. #
  5. # Permission is hereby granted, free of charge, to any person obtaining a copy
  6. # of this software and associated documentation files (the "Software"), to deal
  7. # in the Software without restriction, including without limitation the rights
  8. # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  9. # copies of the Software, and to permit persons to whom the Software is
  10. # furnished to do so, subject to the following conditions:
  11. #
  12. # The above copyright notice and this permission notice shall be included in
  13. # all copies or substantial portions of the Software.
  14. #
  15. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  18. # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  20. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  21. # THE SOFTWARE.
  22. #
  23. # Set application version.
  24. # Make sure to update lib/app-support/pkgIndex.tcl, if the version is changed.
  25. set _APP_VERSION "0.5"
  26. # Set type of application.
  27. # If the starkit namespace is available, we're assuming the application was
  28. # launched from a tclkit.
  29. set _APP_WRAPPED [namespace exists starkit]
  30. # Application is launched with tclkit.
  31. if { $_APP_WRAPPED == 1 } {
  32. #puts "launching application with tclkit"
  33. # Set application root directory.
  34. # The application directory is detected from the starkit environment.
  35. package require starkit
  36. starkit::startup
  37. set _APP_DIR $starkit::topdir
  38. }
  39. # Application is launched without tclkit, e.g. via regular tclsh.
  40. if { $_APP_WRAPPED != 1 } {
  41. #puts "launching application without tclkit"
  42. # Set application root directory.
  43. # The application directory is detected from the executed script.
  44. set _APP_DIR [file dirname [file normalize $argv0]]
  45. # Put lib directory into auto_path variable.
  46. set auto_path [linsert $auto_path 0 [file join $_APP_DIR "lib"]]
  47. }
  48. # Load application package.
  49. package require app-support $_APP_VERSION
  50. ::support::launch $_APP_DIR $_APP_WRAPPED $_APP_VERSION
  51. # Keep global namespace clean.
  52. unset _APP_DIR
  53. unset _APP_VERSION
  54. unset _APP_WRAPPED