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

Option --dump-config-json #19

Open
lassik opened this issue Jun 27, 2018 · 3 comments
Open

Option --dump-config-json #19

lassik opened this issue Jun 27, 2018 · 3 comments

Comments

@lassik
Copy link
Contributor

lassik commented Jun 27, 2018

I thought about what would be needed to implement full Unibeautify support in Emacs, and this kind of option would be needed in the cli program:

unibeautify --language c --dump-config-json source-file.c

The process exit status would be as follows:

  • Exit code 0 - settings found and successfully printed to stdout
  • Exit code 1 - no settings found
  • Exit code 2 and bigger - some other error encountered

This would serve two purposes:

  1. To configure the indentation and other settings of Emacs (or another editor) to match the beautifier settings in the .unibeautifyrc file.
  2. To signal that there is in fact a corresponding .unibeautifyrc and hence that Unibeautify should be called automatically on save. (There could be another, faster option only for this purpose that doesn't parse or dump anything, but only uses exit code 0/1/2 as above to tell whether .unibeautifyrc exists.)

The config dump should only have the beautifier options pertinent to the file given, so that the editor plugin will have an easy job translating them to the editor's native options 😄 The source file is not necessarily in the current directory, it could be anywhere (and the pathname can be an absolute or relative).

The config dump could be in any format, but I guess JSON is a natural choice. And matches the existing --config-json option.

@lassik
Copy link
Contributor Author

lassik commented Jun 27, 2018

It would also be awesome if unibeautify validated the config before dumping it so that the editor plugins don't need to do their own validation (which would amount to a non-trivial amount of duplicate code across editors).

I guess invalid options should have their own exit code. Maybe any valid options should be dumped even if there were some invalid ones, so that the editor can at least use some of them, instead of getting a completely different coding style from its own default settings.

@Glavin001
Copy link
Member

which would amount to a non-trivial amount of duplicate code across editors

Absolutely. Anything we can do to reduce duplicate code 👍.

I've been developing out helper functions in various projects which use Unibeautify. Once I see something happen often enough we migrate the functions into Unibeautify core and de-duplicate it across the other projects.

@lassik
Copy link
Contributor Author

lassik commented Jun 28, 2018

Great to hear, sounds like exactly the right approach 👍

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

2 participants