Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improvement: better command line API #13

Open
vaab opened this issue Mar 6, 2015 · 1 comment
Open

Improvement: better command line API #13

vaab opened this issue Mar 6, 2015 · 1 comment

Comments

@vaab
Copy link
Member

vaab commented Mar 6, 2015

The current command line API has lots of thing left to be desired.

  • Name are not easy to remember
    • does it start with get- (get-values and values) ?
    • does it take a "s" (get-value and get-values) ?
  • Which ACTION can I use on which type ?
  • The final -0 seems like a bad smell, why not a separate option ? -0

Some others concerns raised:

  • Would be nice to have more choice that stdin as input and stdout as output. it would be a great idea if you pass a file as parameter... #11
  • order of KEY and ACTION could be inverted, as we first browse, then think to
    what we'd like to do with the target.
    • get-value ACTION could then be the default action and be removed.
    • and a separate optional [--get-keys | --get-values | --get-key-values | --get-type] could be
      enough for all remaining ACTIONs.

Some deeper reflection on these subject might help to get further:

  • . (dot) is the get-value action in some ways. Why not put all in the KEY and remove the need of
    ACTION. KEY would be a way to map a YAML entry into a list of YAML (possibly a list of 1 element).
    • This would require special chars to map to meanings as current keys, values.
    • how to differentiate between a list in one YAML entry and a list of YAML separated entries ?
@vaab
Copy link
Member Author

vaab commented Mar 6, 2015

I'm inclined to go towards these changements::

shyaml KEY [--get-keys | --get-values | --get-key-values | --get-type] [-0] [--default DEFAULT]

With these rules:

  • all the --get-* are mutually exclusive and optional (choose one of them or none of them), and
    • they work on the YAML value currently targetted by KEY
    • if they finish with a s, then they'll output a list of values that requires a separator, by default
      this separator is \n, but can be changed to \0 thanks to -0 option.
    • if it mentions key then it works only on struct. --get-values on struct only return list of values.

Optionally we could also have:

Any comments ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant