Atom-beautify: Run atom-beautify from command line

Created on 16 Nov 2015  路  7Comments  路  Source: Glavin001/atom-beautify

I'm interested in being able to leverage the abstraction atom-beautify offers to access multiple beautifiers/de-crufters from the command line so I could use the wonderful functionality via scripts.

enhancement

Most helpful comment

When you are ready to jump into CLI just let me know how I can help. I have some experience integrating functionality to CLI via Node.

All 7 comments

I have been thinking of this as well and have been trying to implement the internal code in a way that should allow easier separation of Atom Beautify from its individual beautifiers.

The beautifiers and languages directories inside of the src/ directory could be separated from this Atom Beautify repository into a separate Node.js package.

Usage of this package would be similar to the following:

// Create a generalized Beautifier
Beautifiers = require("./beautifiers")
beautifier = new Beautifiers()
// Beautify
beautifier.beautify(text, allOptions, grammarName, editedFilePath, onSave : onSave)
    .then(beautifyCompleted)
    .catch(beautifyCompleted)

See https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L9-L10 and https://github.com/Glavin001/atom-beautify/blob/master/src/beautify.coffee#L181-L183

This package could then be turned into a command line interface that you could call from scripts.

I also want to look into support Sublime, along with CLI usage. The beautification core should be completely separate from Atom.

When you are ready to jump into CLI just let me know how I can help. I have some experience integrating functionality to CLI via Node.

Thanks, @prettydiff !

@prettydiff : what do you think the core should be called? I'm currently thinking Unibeautify.
The name Atom-Beautify obviously will not work once we expand to support much more than just Atom.

My current plan for v1 is to support the following:

  • Atom
  • Sublime
  • CLI
  • Core (Node.js API)

Build tools like Grunt or Gulp can also have packages using the Core/Node.js API. The CLI will allow users to beautify their code immediately as other packages are developed.

Update: Core repository can be found at https://github.com/Glavin001/unibeautify

Yeah, I am fine that name. For the command line operation two work the beautifier will need to be either JavaScript or executable from the command line (using a Node child process). Running the code is the easy part (provided we are beautifying only one file at a time). The hard part is keeping everything uniform and making API decisions. We can beautify multiple files (directory or directory tree) from the command line as well, but we should save that as a later enhancement.

I can write a preliminary CLI module next week in a pull request. I should be able to take quite a bit from Pretty Diff and just reconfigure it.

This is possible as of moments ago: https://github.com/Unibeautify/unibeautify-cli
I have currently only implemented Pretty Diff beautifier: https://github.com/Unibeautify/beautifier-prettydiff
More to come! Please provide your feedback in Issues of the new repositories!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

seanoldfield picture seanoldfield  路  5Comments

jasonivers picture jasonivers  路  4Comments

philippelesaux picture philippelesaux  路  4Comments

CorentinAndre picture CorentinAndre  路  4Comments

kuzyn picture kuzyn  路  3Comments