pp icon indicating copy to clipboard operation
pp copied to clipboard

[Proposal] Add a simple way to add internal padding, for hash-displayed output

Open rubyFeedback opened this issue 3 years ago • 0 comments

Currently if you pp a more complex object such as:

#<RBT::Cookbooks::SanitizeCookbook:0x000055e84af39ac0
 @array_show_these_entries=[],
 @be_verbose=true,
 @commandline_arguments=["htop"],
 @dataset={},
 @debug=false,
 @found=true,
 @internal_hash=
  {:make_use_of_aliases_kept_in_the_file_cookbook_aliases=>true,
   :use_this_connective_token=>"-",
   :wrap_result=>true,
   :shall_we_display_the_md5sum=>false,
   :try_to_truncate_too_long_output=>true,
   :replace_plus_with_long_name=>false,
   :report_how_many_programs_are_registered=>false},

It becomes quite hard to read the output. Would it be useful to add a ' ' each before the "=>" of a Hash? The other parts I don't care as much, but " => " would be more readable.

Example: @internal_hash= {:make_use_of_aliases_kept_in_the_file_cookbook_aliases=>true, :use_this_connective_token => "-", :wrap_result => true, :shall_we_display_the_md5sum => false, :try_to_truncate_too_long_output => true, :replace_plus_with_long_name => false, :report_how_many_programs_are_registered => false},

API I don't mind really. Could be:

pp obj, padding: 1

Or anything else. Should ideally be simple to type though. Or perhaps toggle PP. I did not find any documented option for this at:

https://ruby-doc.org/stdlib-3.0.1/libdoc/pp/rdoc/PP.html

I understand that we can customize this already, but I was hoping this be sufficiently useful to be added in general. The name could be :padding but it could be anything else, like :internal_spacing or :spacing or anything like that.

Thanks for reading - please proceed in any way you see fit about this short proposal.

rubyFeedback avatar Apr 24 '21 03:04 rubyFeedback