Unibeautify/cli

Option --dump-config-json

Open

#19 opened on Jun 27, 2018

View on GitHub
 (3 comments) (1 reaction) (0 assignees)TypeScript (8 forks)github user discovery
enhancementgood first issuehelp wanted

Repository metrics

Stars
 (36 stars)
PR merge metrics
 (No merged PRs in 30d)

Description

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.

Contributor guide