elastic / makelogs

109 stars 44 forks source link

Exception when specifying custom date range #17

Closed itayw closed 8 years ago

itayw commented 8 years ago

When specifying a custom date range using --days switch I hit an exception:

$ makelogs --days "-10,+10"

  throw new TypeError('Unable to determine the starting and end dates.');
        ^
TypeError: Unable to determine the starting and end dates.

When digging into the code I noticed that the above is translated by optimist into:

{
  ...
  days: true,
  d: true
  ...
}

I tried several different conventions for specifying lower/upper bound, like 10,10, -10,10, 10,+10 and all resulted with the above exception.

Is there a reason for requiring the -days,+days format or can we assume the first element will always we the lower bound to subtract from the base date?

Here's a small change for your review: https://github.com/itayw/makelogs/commit/522e6057d202df8611bc70efd6d468c340a4711e

Thanks for this great tool!

spalger commented 8 years ago

Thanks for the feedback @itayw. I used your change as the starting point for a simplification of the argv/_parseDays.js file. Now the --days flag accepts two numbers, like you set it up to do, but it uses a / as the delimiter instead because the , implies to me that it was a list rather than simply a pair of values.

Thanks again!