From 95e4bb31cb32d684dfdafaf3f0e76fb17541fe26 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Mon, 1 Oct 2018 17:00:56 +0200 Subject: cell_tool: Improve option processing --- src/cell_tool.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src') diff --git a/src/cell_tool.c b/src/cell_tool.c index beb03597..8453c9f7 100644 --- a/src/cell_tool.c +++ b/src/cell_tool.c @@ -378,10 +378,25 @@ int main(int argc, char *argv[]) } + /* If there's a parameter left over, we assume it's the unit cell */ + if ( (argc > optind) && (cell_file == NULL) ) { + cell_file = strdup(argv[optind++]); + } + + /* If there's STILL a parameter left over, complain*/ + if ( argc > optind ) { + ERROR("Excess command-line arguments:\n"); + do { + ERROR("'%s'\n", argv[optind++]); + } while ( argc > optind ); + return 1; + } + if ( cell_file == NULL ) { ERROR("You must give a filename for the unit cell PDB file.\n"); return 1; } + STATUS("Input unit cell: %s\n", cell_file); cell = load_cell_from_file(cell_file); if ( cell == NULL ) { ERROR("Failed to load cell from '%s'\n", cell_file); -- cgit v1.2.3