#! perl -w
##
## Name:
##
## cfx5help
##
## Purpose:
##
## Start CFX on-line help system.
##
## Synopsis:
#S
#S cfx5help [-display <display>] [-help] [-verbose]
#S
## []  denotes an optional argument.
## |   separates mutually exclusive arguments.
## ... following an argument indicates that it may be repeated.
## <>  denotes that substitution of a suitable value is required. All other
##     arguments are keywords, some of which may have a short form.
##
## Arguments:
##
## -display <display>
##     Display the help on the X11 server <display> instead of using the X11
##     server defined by the DISPLAY environment variable.
##
## -help
## -h
##     Print this message.
##
## -verbose
## -v
##     Specifying this option may result in additional output being sent to
##     the standard output file (normally the screen).
##

=head1 NAME

cfx5help - Fire up the CFX-5 help system

=cut

# get the standard CFX-5 library directory
BEGIN {
 if ($0 =~ m!^([a-z]:)?[\\/]!i) {
    # it's an absolute path, use it as-is
    (my $nd=$0) =~ s!(perllib[\\/])?[^\\/]*$!!i;
    unshift @INC, "$nd/perllib";
  } else {
    # wrap this in an eval, and if it fails, pray ... for example,
    # this can fail on Windows if we're running off a share.
    eval {
      require FindBin;
      FindBin->import();
      unshift @INC, "$FindBin::Bin/perllib";
      my $dummy=$FindBin::Bin; # kill used only once warning
    };
    warn $@ if $@;
  }
  if (defined $ENV{CFX_LOCAL_PERLLIB}) {
     unshift @INC, $ENV{CFX_LOCAL_PERLLIB};
  }

}

use CFX5::Init;
CFX5::Init::init();

use vars qw($CVSVersion);
sub BEGIN {
  $CVSVersion='@(#) $Id$\n';
}

use strict;

use CFX5::Output qw(:all);
use CFX5::Config qw(%Config export_conf check_gui_support);
use CFX5::PrintConfig;

use CFX5::CmdLine qw(:util parse_cmdline);

use CFX5::System qw(assert_can_window);
use CFX5::PLAPI;

#
# read the configuration
#
CFX5::Config::read_config();

#
# parse the command line
#

parse_cmdline
  ( \@ARGV,
    'INCLUDE_STD',
    # -pdf, -search and -Launcher are ignored, for compatibility
    '-pdf' => sub { 1; },
    '-search' => sub { 1; },
    '-launcher' => sub { 1; },
  );

exit_if_error();

_error("GUIs are not supported on this platform") unless check_gui_support();

exit_if_error();

#
# Check we've got somewhere to display the GUI.
#
CFX5::System::assert_can_window();

my $plapi=CFX5::PLAPI->new();

# do the setup now so the variables are listed
# JPV is the following required?
# $plapi->setup('errors are fatal');

exit_if_error();

CFX5::PrintConfig::show_vars_by_verbosity();

exit_if_error();

$plapi->show_help('Master Contents');


exit_if_error();

exit(0);
