Search.java revision 38115c792a2142d264ca2617b11962301f079c0a
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * CDDL HEADER START
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * The contents of this file are subject to the terms of the
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * Common Development and Distribution License (the "License").
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * You may not use this file except in compliance with the License.
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * See LICENSE.txt included in this distribution for the specific
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * language governing permissions and limitations under the License.
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * When distributing Covered Code, include this CDDL HEADER in each
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * file and include the License file at LICENSE.txt.
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * If applicable, add the following below this CDDL HEADER, with the
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * fields enclosed by brackets "[]" replaced with your own identifying
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * information: Portions Copyright [yyyy] [name of copyright owner]
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * CDDL HEADER END
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * Use is subject to license terms.
38115c792a2142d264ca2617b11962301f079c0aTrond Norbyeimport org.opensolaris.opengrok.configuration.RuntimeEnvironment;
38115c792a2142d264ca2617b11962301f079c0aTrond Norbyeimport org.opensolaris.opengrok.search.scope.SearchEngine;
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * Search and list the matching files
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye * usage Search index "query" prunepath
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye String usage = "USAGE: Search -R <configuration.xml> [-d | -r | -p | -h | -f] 'query string' ..\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -R <configuration.xml> Read configuration from the specified file\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -d Symbol Definitions\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -r Symbol References\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -p Path\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -h History\n"
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye + "\t -f Full text";
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye boolean config = false;
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye Getopt getopt = new Getopt(argv, "R:d:r:p:h:f:");
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye RuntimeEnvironment.getInstance().readConfiguration(new File(getopt.getOptarg()));
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.err.println("Failed to read config file: ");
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.err.println("Unknown option: " + (char) cmd);
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.err.println("You must specify a configuration file");
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.err.println("You did not specify a valid query");
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.err.println("Your search \"" + engine.getQuery() + "\" did not match any files.");
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye String root = RuntimeEnvironment.getInstance().getSourceRootPath();
38115c792a2142d264ca2617b11962301f079c0aTrond Norbye System.out.println(file.getAbsolutePath() + ": [" + hit.getLine() + "]");