danielshahaf / parseable-dash-dash-help

There should be a --help switch that outputs formal grammar that multiple consumers parse
0 stars 0 forks source link

Are static .grammar files sufficient? #3

Open danielshahaf opened 8 years ago

danielshahaf commented 8 years ago

Are there commands for which static grammars would be insufficient? For example, commands whose acceptable syntaxes depend on time of day, configuration files, disk contents, phase of the moon...?

Strategies for dealing with these:

  1. Decorate syntax elements as "not valid in all circumstances". Consumers can then decide what to do with that information. Tab completion would offer them [perhaps secondarily]; static analyzers would mark them as "caution" / "dubious".
  2. Support some limited amount of logic through a predicates DSL. For example, decorate an option with validity-predicate: "only on Tuesdays".
  3. Generate grammars dynamically: some sort of rsync --parseable-help switch that emits a grammar on stdout. Then it's rsync's problem to check whether today is a Tuesday.
okapia commented 8 years ago

A combination of these. We can't predict all possible predicates. Some are obvious like conditional on the OS type. I'd prefer to avoid dynamically generating grammars in favour of simpler options that list values one per-line. e.g rsync --list=disabled-options. That's more flexible and easier to parse and use for other things.