GithubHelp home page GithubHelp logo

Comments (9)

k0kubun avatar k0kubun commented on May 24, 2024 2

If we stop deprecating pp.ColoringEnabled = false, would you use it?

As to this problem, now there's an officially blessed API: https://github.com/k0kubun/pp/releases/tag/v3.2.0

from pp.

jlearman avatar jlearman commented on May 24, 2024 2

Looks great, thanks!

Sorry I never followed up on the original request. @KEINOS is correct about what I was asking for, and I bet that dd would have been best for me at the time. I had been using pp for other purposes and came on a new case where I didn't want color (for logging, which needed to be readable when logged to file.)

from pp.

KEINOS avatar KEINOS commented on May 24, 2024 1

As to this problem, now there's an officially blessed API: https://github.com/k0kubun/pp/releases/tag/v3.2.0

Wow!

package main

import (
	"fmt"

	"github.com/Code-Hex/dd"
	"github.com/k0kubun/pp/v3"
)

func main() {
	sample := []string{
		"foo",
		"bar",
	}

	// pp
	{
		pp.Default.SetColoringEnabled(false)
		pp.Println(sample)
	}
	// dd
	{
		fmt.Println(dd.Dump(sample))
	}

	// Output:
	//
	// []string{
	//     "foo",
	//     "bar",
	// }
	// []string{
	//     "foo",
	//     "bar",
	// }
}

For my purposes this is simple and sufficient. How about you @jlearman?

@k0kubun Thank you very much! From now on, I will stick to pp 😉

from pp.

k0kubun avatar k0kubun commented on May 24, 2024

Same as #66 (comment), please show us an example code you want to use. Otherwise, this issue is not actionable for anybody besides you.

from pp.

k0kubun avatar k0kubun commented on May 24, 2024

Let's reopen this after your further clarification.

from pp.

KEINOS avatar KEINOS commented on May 24, 2024

@jlearman You mean something like below, don't you?

package main

import (
	"fmt"

	"github.com/Code-Hex/dd"
	"github.com/k0kubun/pp/v3"
)

func main() {
	sample := []string{
		"foo",
		"bar",
	}

	pp.Println(sample)
	fmt.Println(dd.Dump(sample))
}
// Output:
// []�[32mstring�[0m{
//   �[31m�[1m"�[0m�[31mfoo�[0m�[31m�[1m"�[0m,
//   �[31m�[1m"�[0m�[31mbar�[0m�[31m�[1m"�[0m,
// }
// []string{
//   "foo",
//   "bar",
// }

As described in the repository description, the pp package is dedicated to color text printing prettily. Therefore, for CUI purposes, pp is nice and simple.

However, when used as a dump in print-debug or GoPlayground, I recommend to use dd instead. I use them both though.

from pp.

k0kubun avatar k0kubun commented on May 24, 2024

when used as a dump in print-debug

Any problem in pp for print debugging? It's the primary purpose of this library.

from pp.

KEINOS avatar KEINOS commented on May 24, 2024

@k0kubun
Any problem in pp for print debugging?

No. Not at all.

But the issue is "a simple way to disable all color". And the answer seemed a bit mean to me, so I wanted to provoke and ask what kind of use cases @jlearman had in mind. That's why I posted "an example code that we want to use" as you mentioned. That's all. 😉

Even though pp is great and nice for printing debug-infos "in color", I believe there's no function that prints with no-color, out of the box. Such like dd.Dump does.

... ... or does it?

from pp.

k0kubun avatar k0kubun commented on May 24, 2024

If we stop deprecating pp.ColoringEnabled = false, would you use it?

If it doesn't work, WDYT about each of the following options?

  1. pp.WithColor(false).Println(...)
  2. p.Println(...) (k0kubun/pp/p will be a package for non-colored output)
  3. pp.Println(...) does not colorize outputs when the destination IO is not TTY (Sprint* should be kept colored, or just check stdout for convenience?)

from pp.

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.