diff --git a/iothub-explorer-create.js b/iothub-explorer-create.js index 4c4a0c81..5d9fc7b2 100644 --- a/iothub-explorer-create.js +++ b/iothub-explorer-create.js @@ -28,7 +28,7 @@ program .option('-k2, --key2 ', 'specify the secondary key for newly created device') .option('-r, --raw', 'use this flag to return raw JSON instead of pretty-printed output') .option('-x, --x509', 'generate an x509 certificate to authenticate the device') - .option('-dv, --daysValid', 'number of days the x509 certificate should be valid for') + .option('-dv, --daysValid', 'number of days the x509 certificate should be valid for', parseInt) .option('-t1, --thumbprint1 ', 'specify the primary thumbprint of the x509 certificate') .option('-t2, --thumbprint2 ', 'specify the secondary thumbprint of the x509 certificate') .parse(process.argv); diff --git a/iothub-explorer-login.js b/iothub-explorer-login.js index 6bd15858..da0b4fbf 100644 --- a/iothub-explorer-login.js +++ b/iothub-explorer-login.js @@ -22,7 +22,7 @@ var SharedAccessSignature = require('azure-iothub').SharedAccessSignature; program .description('Create a temporary session on your IoT hub') - .option('-d, --duration ', 'time to keep the session open for (in seconds): if not specified, the default is one hour') + .option('-d, --duration ', 'time to keep the session open for (in seconds): if not specified, the default is one hour', parseInt) .parse(process.argv); if(!program.args[0]) inputError('You must specify a connection string.'); diff --git a/iothub-explorer-monitor-events.js b/iothub-explorer-monitor-events.js index a17e57d2..8c7e6c5e 100644 --- a/iothub-explorer-monitor-events.js +++ b/iothub-explorer-monitor-events.js @@ -38,7 +38,9 @@ if(!program.raw) { } var consumerGroup = program.consumerGroup || '$Default'; -var startTime = program.startTime ? new Date(program.startTime) : Date.now(); +var startTime = program.startTime ? + isNaN(program.startTime) ? new Date(program.startTime) : new Date(parseInt(program.startTime)) : + Date.now(); var ehClient = EventHubsClient.fromConnectionString(connectionString); ehClient.open() diff --git a/iothub-explorer-sas-token.js b/iothub-explorer-sas-token.js index 56b5e31a..9c58a1c3 100644 --- a/iothub-explorer-sas-token.js +++ b/iothub-explorer-sas-token.js @@ -21,14 +21,14 @@ var Registry = require('azure-iothub').Registry; program .description('Generate a shared access signature token for the given device with an expiry time from now') .option('-l, --login ', 'use the connection string provided as argument to use to authenticate with your IoT hub') - .option('-d, --duration ', 'expiration time (in seconds): if not specified, the default is one hour') + .option('-d, --duration ', 'expiration time (in seconds): if not specified, the default is one hour', parseInt) .parse(process.argv); if(!program.args[0]) inputError('You must specify a device id.'); var deviceId = program.args[0]; var nowInSeconds = Math.floor(Date.now() / 1000); -var expiry = program.duration ? nowInSeconds + parseInt(program.duration) : nowInSeconds + 3600; +var expiry = program.duration ? nowInSeconds + program.duration : nowInSeconds + 3600; if (isNaN(new Date(expiry * 1000))) { inputError('Invalid duration');