/* This file is part of GNU Rush.
   Copyright (C) 2008-2024 Sergey Poznyakoff

   GNU Rush is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 3, or (at your option)
   any later version.

   GNU Rush is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with GNU Rush.  If not, see <http://www.gnu.org/licenses/>. */

#include <error.h>

OPTIONS_BEGIN(gnu, "rush",
	      [<rush - restricted user shell.>],
	      [<[FILE]>])

OPTION(debug,d,NUMBER,
       [<Set debugging level.>])
BEGIN
	debug_level = atoi(optarg);
	debug_option = 1;
END

OPTION(test,t,,
       [<Run in test mode.>])
ALIAS(lint)
BEGIN
	lint_option = 1;
END

OPTION(,T,,
       [<Scanner test.>])
BEGIN
       scanner_test = 1;
END

OPTION(trace,x,,
       [<Print grammar and lexical analyzer traces>])
BEGIN
       parser_traces++;
END

OPTION(user,u,NAME,
       [<Supply user name in test mode.>])
BEGIN
	lint_option = 1;
	if (getuid())
		die(usage_error,
		    NULL,
		    _("the --user option is allowed "
		      "for the superuser only"));
	test_user_name = optarg;
END

OPTION(,c,COMMAND,
       [<Execute COMMAND.>])
BEGIN
	command = optarg;
END

OPTION(,i,,
       [<Force interactive shell.>])
BEGIN
	lint_option = 1;
	interactive = 1;
END

OPTION(dump,D,KEYWORDS,
       [<Dump final request in test mode.>])
BEGIN
	dump_option = optarg;
	lint_option = 1;
END

OPTION(security-check,C,CHECK,
       [<Add or remove configuration security check.>])
BEGIN
	if (cfck_keyword(optarg))
		die(usage_error, NULL,
		    _("unknown keyword: %s"), optarg);
END

OPTION(show-default,,,
       [<Show default configuration.>])
BEGIN
#ifdef RUSH_DEFAULT_CONFIG
	printf("%s\n", RUSH_DEFAULT_CONFIG);
	exit(0);
#else
	error(1, 0, _("No default configuration"));
#endif
END

OPTIONS_END

void
get_options(int argc, char *argv[])
{
    GETOPT(argc, argv)
}
