"use strict";var commands,help,run,lengthOfLongestCommand,pad,findCommand,commandNameWithParameters,exampleParameters,appName=require("path").basename(process.argv[1],".js"),syntaxIsCorrect,util=require("./util"),ptp=require("../..");commands=[{name:"capture",parameters:[{name:"host",example:"192.168.1.1"}],description:"initiate capture"},{name:"get_device_property",parameters:[{name:"host",example:"192.168.1.1"},{name:"prop_code",example:"0x5001"}],description:"get value of property"},{name:"set_device_property",parameters:[{name:"host",example:"192.168.1.1"},{name:"prop_code",example:"0x5010"},{name:"value",example:"createWord(1000)"}],description:"set value of property"},{name:"device_prop_codes",description:"device property codes"},{name:"date_time_string",description:"PTP format of current time"},{name:"get_object_handles",parameters:[{name:"host",example:"192.168.1.1"}],description:"handles of files and folders"},{name:"get_object_info",parameters:[{name:"host",example:"192.168.1.1"},{name:"object_handle",example:"6620401"}],description:"description of object"},{name:"get_object",parameters:[{name:"host",example:"192.168.1.1"},{name:"object_handle",example:"6620401"},{name:"filename",example:"photo.jpg"}],description:"download object"},{name:"delete_object",parameters:[{name:"host",example:"192.168.1.1"},{name:"object_handle",example:"6620401"}],description:"delete object"}],commandNameWithParameters=function(e){var t=[e.name];return e.parameters!==undefined&&e.parameters.forEach(function(e){t.push(e.name)}),t.join(" ")},lengthOfLongestCommand=function(){return commands.reduce(function(e,t){return Math.max(e,commandNameWithParameters(t).length)},0)},exampleParameters=function(e){return e.parameters===undefined?"":e.parameters.map(function(e){return e.example}).join(" ")},help=function(){var e=lengthOfLongestCommand();console.log("  Commands:"),console.log(""),commands.forEach(function(t){console.log("    "+util.pad(commandNameWithParameters(t),e)+"  "+t.description)}),console.log(""),console.log("  Examples:"),console.log(""),commands.forEach(function(e){console.log("    "+appName+" "+e.name+" "+exampleParameters(e))})},findCommand=function(e){var t,n;for(t=0;t<commands.length;t+=1){n=commands[t];if(n.name===e)return n}return null},run=function(e){var t=findCommand(e.commandName);if(t===null)return;ptp.loggerOutputIsEnabled=e.verboseOutputIsRequested,require("./"+t.name).apply(this,e.parameters)},syntaxIsCorrect=function(e){var t=findCommand(e.commandName);return t===null?!1:t.parameters!==undefined&&t.parameters.length!==e.parameters.length?!1:!0},module.exports=Object.create(null,{help:{value:help},run:{value:run},syntaxIsCorrect:{value:syntaxIsCorrect}});