Merge pull request #838 from nasa/#837-cmd-line

iss #837 make command line arguments position independent
This commit is contained in:
Scott Fennell 2019-07-08 15:53:13 -05:00 committed by GitHub
commit 101ae55bb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 6 deletions

View File

@ -158,9 +158,19 @@ int Trick::CommandLineArguments::process_sim_args(int nargs , char **args) {
if ( argc > 1 ) {
/* First argument is the input file name: '<Run_dir>/<file_name>' */
input_file = argv[1] ;
run_dir = argv[1] ;
/* First occurnance of "RUN_*" is the input file name: '<Run_dir>/<file_name>'.
If not found, defaults to first argument */
input_file = argv[1];
run_dir = argv[1];
for(int ii = 1; ii < argc; ii++) {
if(std::string(argv[ii]).find("RUN_") != std::string::npos) {
input_file = argv[ii];
run_dir = argv[ii];
break;
}
}
found = run_dir.find_last_of("/") ;
if ( found != std::string::npos ) {
@ -176,7 +186,7 @@ int Trick::CommandLineArguments::process_sim_args(int nargs , char **args) {
output_dir = run_dir ;
for (ii = 2; ii < argc; ii++) {
for (ii = 1; ii < argc; ii++) {
if (!strncmp("-OO", argv[ii], (size_t) 3) || !strncmp("-O", argv[ii], (size_t) 2)) {
if (ii == ( argc - 1 )) {
std::cerr << "\nERROR: No directory specified after -O or -OO argument" << std::endl ;

View File

@ -36,7 +36,7 @@ int Trick::InputProcessor::process_sim_args() {
input_file = command_line_args_get_input_file() ;
/* Process all other calling arguments */
for (i = 2; i < argc; i++) {
for (i = 1; i < argc; i++) {
/*
* If there are more than 2 calling arguments

View File

@ -77,7 +77,7 @@ int Trick::MSSocket::process_sim_args() {
/** @par Detailed Design */
/** @li search for the "-p" argument. If found get the master identifier as the next argument */
for (ii = 2; ii < argc; ii++) {
for (ii = 1; ii < argc; ii++) {
if (!strncmp("-p", argv[ii], (size_t) 2)) {
if (argc >= ii + 1) {
sync_port_tag = argv[ii+1] ;