swi_main.pl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. #!/usr/bin/perl
  2. #
  3. # Software Index, Copyright 2010, Software Index Project Team
  4. # Link: http://swi.sourceforge.net
  5. #
  6. # This file is part of Software Index Tool.
  7. #
  8. # Software Index is free software: you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation, version 3 of the License.
  11. #
  12. # Software Index is distributed in the hope that it will be useful,
  13. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. # GNU General Public License for more details.
  16. #
  17. # You should have received a copy of the GNU General Public License
  18. # along with Software Index. If not, see <http://www.gnu.org/licenses/>.
  19. #
  20. =head1 OVERVIEW
  21. Software Index measures, reports and validates software statistic,
  22. searches for duplications, scans for errors, 'coding style' violations
  23. and occasions of broken design patterns which are defined by your design team.
  24. More information available at 'http://swi.sourceforge.net'.
  25. =head1 SYNOPSIS
  26. In order to get the context help (this text):
  27. perl swi_main.pl -h
  28. perl swi_main.pl -help
  29. perl swi_main.pl --help
  30. In order to get the sample configuration file and it's description:
  31. perl swi_main.pl -s
  32. perl swi_main.pl -sample
  33. perl swi_main.pl --sample
  34. In order to launch the tool with the prepared configuration file:
  35. perl swi_main.pl </path/to/configuration/file.xml>
  36. =head1 OPTIONS
  37. =over 4
  38. =item -h, -help, --help
  39. Prints this help page.
  40. =item -s, -sample, --sample
  41. Prints the example of configuration file and it's description.
  42. The sample explains every section in details and gives several usage examples.
  43. Use this as a start up framework for your initial configs.
  44. For example:
  45. > perl swi_main.pl -sample > my_config.xml
  46. =item </path/to/configuration/file.xml>
  47. Full or relative path to the configuration file for the tool.
  48. =back
  49. =head1 ENVIRONMENT
  50. The tool requires Perl Runtime Environment. Required Perl version is 5.6.x or later.
  51. =head1 COPYRIGHT
  52. Software Index, Copyright 2009, 2010, Software Index Project Team,
  53. Link: http://swi.sourceforge.net
  54. =head1 LICENSE
  55. Software Index is free software: you can redistribute it and/or modify
  56. it under the terms of the GNU General Public License as published by
  57. the Free Software Foundation, version 3 of the License.
  58. Software Index is distributed in the hope that it will be useful,
  59. but WITHOUT ANY WARRANTY; without even the implied warranty of
  60. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  61. GNU General Public License for more details.
  62. You should have received a copy of the GNU General Public License
  63. along with Software Index. If not, see <http://www.gnu.org/licenses/>.
  64. =cut
  65. use strict;
  66. use Cwd qw(abs_path);
  67. use Pod::Usage;
  68. $0 =~ m/(.*)swi_main.pl$/;
  69. my $globalRootDirectory = abs_path($1);
  70. push( @INC, "$globalRootDirectory/lib" );
  71. require SWI::Launcher;
  72. if ( !defined( $ARGV[0] )
  73. || $ARGV[0] eq "-help"
  74. || $ARGV[0] eq "--help"
  75. || $ARGV[0] eq "-h" )
  76. {
  77. pod2usage( -exitstatus => 0, -verbose => 2 );
  78. exit 0;
  79. }
  80. if ( $ARGV[0] eq "-sample"
  81. || $ARGV[0] eq "--sample"
  82. || $ARGV[0] eq "-s" )
  83. {
  84. my $fh = new FileHandle( "$globalRootDirectory/swi_config_sample.xml", "r" )
  85. or die(
  86. "Can not open input file '$globalRootDirectory/swi_config_sample.xml'!"
  87. );
  88. while (<$fh>)
  89. {
  90. print $_;
  91. }
  92. exit 0;
  93. }
  94. exit swiLaunch( $globalRootDirectory, @ARGV );