/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.karaf.features.command;

import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.features.Repository;
import org.apache.felix.gogo.commands.Command;

@Command(scope = "features", name = "listUrl", description = "Displays a list of all defined repository URLs.")
public class ListUrlCommand extends FeaturesCommandSupport {

    protected void doExecute(FeaturesService admin) throws Exception {
        Repository[] repos = admin.listRepositories();
        if ((repos != null) && (repos.length > 0)) {
            for (int i = 0; i < repos.length; i++) {
            	String status = repos[i].isValid() ? "    valid" : "    invalid";
            	System.out.println(repos[i].getURI().toString() + status);
            }
        } else {
            System.out.println("No repository URLs are set.");
        }
    }
}

@@ -840,16 +840,131 @@
 mmand;%0A%0A
+import java.net.URI;%0A%0Aimport org.apache.felix.gogo.commands.Command;%0Aimport org.apache.felix.gogo.commands.Option;%0A
 import o
@@ -1054,55 +1054,57 @@
 ry;%0A
-import org.apache.felix.gogo.commands.Command;%0A
+%0A/**%0A * Command which lists feature URLs.%0A * %0A */
 %0A@Co
@@ -1282,384 +1282,1564 @@
     
-protected void doExecute(FeaturesService admin) throws Exception %7B%0A        Repository%5B%5D repos = admin.listRepositories();%0A        if ((repos != null) && (repos.length %3E 0)) %7B%0A            for (int i = 0; i %3C repos.length; i++) %7B%0A            %09String status = repos%5Bi%5D.isValid() ? %22    valid%22 : %22    invalid%22;%0A            %09System.out.println(repos%5Bi%5D.getURI().toString() + status
+@Option(name = %22-v%22, aliases = %22-validate%22, description = %22Validate current version of descriptors%22, required = false, multiValued = false)%0A    boolean validation = false;%0A%0A    @Option(name = %22-vo%22, aliases = %22-verbose%22, description = %22Shows validation output%22, required = false, multiValued = false)%0A    boolean verbose = false;%0A%0A    protected void doExecute(FeaturesService admin) throws Exception %7B%0A        Repository%5B%5D repos = admin.listRepositories();%0A%0A        String header;%0A        if (validation) %7B%0A            header = %22 Loaded   Now valid   URI %22;%0A        %7D else %7B%0A            header = %22 Loaded   URI %22;%0A        %7D%0A%0A        session.getConsole().println(header);%0A%0A        String verboseOutput = %22%22;%0A%0A        if ((repos != null) && (repos.length %3E 0)) %7B%0A            for (int i = 0; i %3C repos.length; i++) %7B%0A                URI uri = repos%5Bi%5D.getURI();%0A%0A                String line = %22%22;%0A                line += repos%5Bi%5D.isValid() ? %22  true %22 : %22  false%22;%0A%0A                try %7B%0A                    admin.validateRepository(uri);%0A                    // append valid flag if validation mode is tuned on%0A                    line += !validation ? %22%22 : %22     true   %22;%0A                %7D catch (Exception e) %7B%0A                    line += !validation ? %22%22 : %22     false  %22;%0A                    verboseOutput += uri + %22:%22 + e.getMessage() + %22%5Cn%22;%0A                %7D%0A%0A                session.getConsole().println(line + %22   %22 + uri);%0A            %7D%0A%0A            if (verbose) %7B%0A                session.getConsole().println(%22Validation output:%5Cn%22 + verboseOutput
 );%0A 
@@ -2884,18 +2884,28 @@
     
-System.out
+session.getConsole()
 .pri

KARAF-369 Validation state in features:listUrl command output.