String sourceHost = args.getArg("-source-host");
if (sourceHost == null)
sourceHost = "default";
CommitBuilder source = new CommitBuilder();
source.type("webapp");
String sourceStage = args.getArg("-source-stage");
if (sourceStage != null)
source.stage(sourceStage);
source.tagKey(sourceHost + "/" + sourceContext);
String version = args.getArg("-source-version");
if (version != null)
fillInVersion(source, version);
String targetContext = args.getArg("-target");
String targetHost = args.getArg("-target-host");
if (targetHost == null)
targetHost = sourceHost;
CommitBuilder target = new CommitBuilder();
target.type("webapp");
String targetStage = args.getArg("-target-stage");
if (targetStage != null)
target.stage(targetStage);
target.tagKey(targetHost + "/" + targetContext);
String message = args.getArg("-m");
if (message == null)
message = args.getArg("-message");
if (message == null)
message = L.l("copy '{0}' to '{1}'", source.getTagKey(), target.getTagKey());
target.message(message);
target.attribute("user", System.getProperty("user.name"));
String targetVersion = args.getArg("-target-version");
if (targetVersion != null)
fillInVersion(target, targetVersion);
deployClient.copyTag(target, source);
System.out.println(L.l("copied {0} to {1}",
source.getId(), target.getId()));
}