swi_main.pl 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. =head1 SYNOPSIS
  25. In order to get the context help (this text):
  26. perl swi_main.pl -h
  27. perl swi_main.pl -help
  28. perl swi_main.pl --help
  29. In order to get the sample configuration file and it's description:
  30. perl swi_main.pl -s
  31. perl swi_main.pl -sample
  32. perl swi_main.pl --sample
  33. In order to launch the tool with the prepared configuration file:
  34. perl swi_main.pl </path/to/configuration/file.xml>
  35. =head1 OPTIONS
  36. =over 4
  37. =item -h, -help, --help
  38. Prints this help page.
  39. =item -s, -sample, --sample
  40. Prints the example of configuration file and it's description.
  41. The sample explains every section in details and gives several usage examples.
  42. Use this as a start up framework for your initial configs.
  43. For example:
  44. > perl swi_main.pl -sample > my_config.xml
  45. =item </path/to/configuration/file.xml>
  46. Full or relative path to the configuration file for the tool.
  47. =back
  48. =head1 ENVIRONMENT
  49. The tool requires Perl Runtime Environment. Required Perl version is 5.6.x or later.
  50. =head1 COPYRIGHT
  51. Software Index, Copyright 2009, 2010, Software Index Project Team,
  52. Link: http://swi.sourceforge.net
  53. =head1 LICENSE
  54. Software Index is free software: you can redistribute it and/or modify
  55. it under the terms of the GNU General Public License as published by
  56. the Free Software Foundation, version 3 of the License.
  57. Software Index is distributed in the hope that it will be useful,
  58. but WITHOUT ANY WARRANTY; without even the implied warranty of
  59. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  60. GNU General Public License for more details.
  61. You should have received a copy of the GNU General Public License
  62. along with Software Index. If not, see <http://www.gnu.org/licenses/>.
  63. =cut
  64. use strict;
  65. use Cwd qw(abs_path);
  66. use Pod::Usage;
  67. $0 =~ m/(.*)swi_main.pl$/;
  68. my $globalRootDirectory = abs_path($1);
  69. push( @INC, "$globalRootDirectory/lib" );
  70. require SWI::Launcher;
  71. if ( !defined( $ARGV[0] )
  72. || $ARGV[0] eq "-help"
  73. || $ARGV[0] eq "--help"
  74. || $ARGV[0] eq "-h" )
  75. {
  76. pod2usage( -exitstatus => 0, -verbose => 2 );
  77. exit 0;
  78. }
  79. if ( !defined( $ARGV[0] )
  80. || $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 );