Code Monkey home page Code Monkey logo

Comments (11)

ohler55 avatar ohler55 commented on June 14, 2024 1

So far it only aligns members of array that fit on a single line. I'll look into aligning map/object members.

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024 1

Release v1.12.0 has the alignment of map members.

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024

The align option is available in the align branch. Let know what you think.

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024

Now on develop branch. Slated for release this weekend with a few other extras added.

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024

OjG v1.8.0 has the align option. Similar to what you proposed but numbers are right aligned and other are left aligned.

from ojg.

eugenesvk avatar eugenesvk commented on June 14, 2024

Is it possible to achieve vertical alignment with your pretty tool in a simpler structure?

input json

{
"PersonA": 30,
"PersonB longer name": 40
}

preferred output

{
"PersonA"            : 30,
"PersonB longer name": 40
}

from ojg.

eugenesvk avatar eugenesvk commented on June 14, 2024

Thank you for looking into it, that would be a great formatting win for displaying simple config files

from ojg.

eugenesvk avatar eugenesvk commented on June 14, 2024

Thanks @ohler55 for implementing this feature and even remembering to add a notification to this closed issue!!!

Just as a further (albeit minor vs. the already implemented!) step to further perfection, would you feel like making the : colon separators aligned and/or separate?

I think these SEN outputs look more neat...
New1: with separators separated and aligned

applescript_enabled 	: ""
bundle_executable   	: Karabiner-VirtualHIDDevice-Manager
bundle_identifier   	: org.pqrs.Karabiner-VirtualHIDDevice-Manager
bundle_name         	: Karabiner-VirtualHIDDevice-Manager
bundle_package_type 	: APPL
bundle_short_version	: "1.22.0"
bundle_version      	: "1.22.0"

New2: with separators aligned, but not separated (maybe this would be better for more compact layouts not to have an extra separator)

applescript_enabled : ""
bundle_executable   : Karabiner-VirtualHIDDevice-Manager
bundle_identifier   : org.pqrs.Karabiner-VirtualHIDDevice-Manager
bundle_name         : Karabiner-VirtualHIDDevice-Manager
bundle_package_type : APPL
bundle_short_version: "1.22.0"
bundle_version      : "1.22.0"

...than this current output
Old:

applescript_enabled: 	""
bundle_executable:   	Karabiner-VirtualHIDDevice-Manager
bundle_identifier:   	org.pqrs.Karabiner-VirtualHIDDevice-Manager
bundle_name:         	Karabiner-VirtualHIDDevice-Manager
bundle_package_type: 	APPL
bundle_short_version:	"1.22.0"
bundle_version:      	"1.22.0"

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024

I toyed with "New2" and "Old" but settled on Old more consistency with other non-aligned maps. I suppose consistency is in the eye of the beholder but my thinking was that all other map entries had the : immediately after the key so keeping it there assures that there is no question about whether there is a space in the key. Maybe not really an issue but the second reason was that it was easier to implement. Not by a lot but a little.

I'd like to take this to the discussion section (see the top of this page or just #65). I don't want to fall into the trap of providing too many options for different display format preferences. You can never satisfy everyone. I haven't thought it through yet but I think there might be some options to somehow use custom formatters without changing the underlying code in OjG. Something like a pipeline or maybe some plug-ins or something. Getting more folks involved in the discussion might help narrow down how that night be done.

from ojg.

eugenesvk avatar eugenesvk commented on June 14, 2024

there is no question about whether there is a space in the key

wouldn't the extra space require quotes just like so:

oj -p 80.1.1 -c -sen people.json
{
  PersonA:               30
  "PersonB longer name": 35
  PersonClongername:     40
}

I mean, it's the same question: "Is there a space at the beginning of the value?", to which the same answer "No, if there were, you'd see quotes" applies, no?

...easier to implement. Not by a lot but a little.

sure thing

I don't want to fall into the trap of providing too many options for different display format preferences.

Well, for my narrow use case of using your awesome cli tool to pretty-print json files in a terminal, that's a non-trap as long as I can stuff most of these options in a config file/env var (basically, also a config shell file)/or, worst case, in a shell alias function: I'll just put most of the formatting I'll always need (like pretty formatting with colors in a SEN format) and "forget" about them, only maybe adding 1 extra option manually from time to time when I need to adjust the width/depth values in the -p option

Of course, if you have grander plans that require more simplicity wouldn't want to entrap your project :)

from ojg.

ohler55 avatar ohler55 commented on June 14, 2024

You are right about the space in names.

The trap I was referring to is trying to keep up with requests for formatting variations. Since each would require an option variable somewhere it makes configuration imposing and the code more complicated and hence slower. On the other hand it would be nice to have someway of giving everyone what they want. I do have some ideas about how to do that but would like to discuss it with others such as yourself hence the discussion topic #65 .

from ojg.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.