+ argCount: "?",
+ options: [
+ {
+ names: ["-sort", "-s"],
+ description: "Sort order (see 'downloadsort')",
+ type: CommandOption.LIST,
+ get default() modules.options["downloadsort"],
+ completer: function (context, args) modules.options.get("downloadsort").completer(context, { values: args["-sort"] }),
+ validator: function (value) modules.options.get("downloadsort").validator(value)
+ }
+ ]
+ });
+
+ commands.add(["dlc[lear]"],
+ "Clear completed downloads",
+ function (args) { services.downloadManager.cleanUp(); });
+ },
+ options: function initOptions(dactyl, modules, window) {
+ const { options } = modules;
+
+ if (false)
+ options.add(["downloadcolumns", "dlc"],
+ "The columns to show in the download manager",
+ "stringlist", "filename,state,buttons,progress,percent,time,url",
+ {
+ values: {
+ buttons: "Control buttons",
+ filename: "Target filename",
+ percent: "Percent complete",
+ size: "File size",
+ speed: "Download speed",
+ state: "The download's state",
+ time: "Time remaining",
+ url: "Source URL"
+ }
+ });
+
+ options.add(["downloadsort", "dlsort", "dls"],
+ ":downloads sort order",
+ "stringlist", "-active,+filename",
+ {
+ values: {
+ active: "Whether download is active",
+ complete: "Percent complete",
+ date: "Date and time the download began",
+ filename: "Target filename",
+ size: "File size",
+ speed: "Download speed",
+ time: "Time remaining",
+ url: "Source URL"
+ },
+
+ completer: function (context, extra) {
+ let seen = Set.has(Set(extra.values.map(function (val) val.substr(1))));
+
+ context.completions = iter(this.values).filter(function ([k, v]) !seen(k))
+ .map(function ([k, v]) [["+" + k, [v, " (", _("sort.ascending"), ")"].join("")],
+ ["-" + k, [v, " (", _("sort.descending"), ")"].join("")]])
+ .flatten().array;
+ },
+
+ has: function () Array.some(arguments, function (val) this.value.some(function (v) v.substr(1) == val)),
+
+ validator: function (value) {
+ let seen = {};
+ return value.every(function (val) /^[+-]/.test(val) && Set.has(this.values, val.substr(1))
+ && !Set.add(seen, val.substr(1)),
+ this) && value.length;
+ }