/*
 * Copyright 2016 Patrick Moor <patrick@moor.ws>
 *
 * Licensed 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 ws.moor.gletscher.commands;

import org.apache.commons.cli.CommandLine;

import java.util.List;

@Command(name = "version", description = "Returns the current Gletscher version.")
class VersionCommand extends AbstractCommand {
  VersionCommand(CommandContext context) {
    super(context);
  }

  @Override
  protected int runInternal(CommandLine commandLine, List<String> args) throws Exception {
    if (!args.isEmpty()) {
      throw new InvalidUsageException(this, "version takes no arguments");
    }
    // TODO(pmoor): Get from pom.xml
    context.getStdOut().println("Gletscher Version 1.0");
    return 0;
  }
}

@@ -703,17 +703,74 @@
 ava.
-util.List
+io.IOException;%0Aimport java.util.List;%0Aimport java.util.Properties
 ;%0A%0A@
@@ -1181,44 +1181,56 @@
   %7D%0A
+%0A
     
-// TODO(pmoor): Get from pom.xml
+String versionString = readVersionString();
 %0A   
@@ -1281,27 +1281,311 @@
 ion 
-1.0%22);%0A    return 0
+%22 + versionString);%0A    return 0;%0A  %7D%0A%0A  private String readVersionString() throws IOException %7B%0A    Properties properties = new Properties();%0A    properties.load(getClass().getResourceAsStream(%22/META-INF/maven/ws.moor.gletscher/gletscher/pom.properties%22));%0A    return (String) properties.get(%22version%22)
 ;%0A  

load version from pom.properties