/*jslint node: true */
"use strict";

var tilelive = require("tilelive");
require("./").registerProtocols(tilelive);
require("mbtiles").registerProtocols(tilelive);

var src = "http://localhost:8080/geoserver/gwc/service/tms/1.0.0/osm@EPSG%3A900913@png8/{z}/{x}/{y}.png";
var dst = "mbtiles://./osm.mbtiles";
var options = {
    minzoom: 0,
    maxzoom: 16,
    bounds: [1.8959314626397201, 41.24712051859019, 2.3140591893595457, 41.53442029978945],
    progress: function report(stats, p) {
        process.stdout.write("\r" + (p.percentage).toFixed(1) + " % - ETA " + p.eta % 60 + " s          ");
        if (p.percentage == 100) process.stdout.write("\r\nDone!\r\n");
    }
};

tilelive.copy(src, dst, options);

@@ -1,42 +1,4 @@
-/*jslint node: true */%0A%22use strict%22;%0A%0A
 var 
@@ -71,16 +71,46 @@
 lelive);
+      // Register tms protocol
 %0Arequire
@@ -149,17 +149,156 @@
 lelive);
-%0A
+ // Register mbtiles protocol%0A%0A// A tms url starts with %22tms:%22, followed by an URL template, which must contain %7Bz%7D %7Bx%7D and %7By%7D placeholders
 %0Avar src
@@ -301,16 +301,20 @@
  src = %22
+tms:
 http://l
@@ -436,16 +436,101 @@
 btiles%22;
+%0A%0A// Indicate zoom levels and bbox in geographic coordinates %5Bxmin, ymin, xmax, ymax%5D
 %0Avar opt
@@ -705,16 +705,55 @@
 s, p) %7B%0A
+        // Write a progress indication%0A
         
@@ -934,16 +934,24 @@
   %7D%0A%7D;%0A%0A
+// Run!%0A
 tilelive
@@ -973,11 +973,90 @@
  options
+, function(error) %7B%0A    // Handle errors%0A    if (error) console.error(error);%0A%7D
 );%0A

Use tms: protocol; error handling