Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modd escaping values in terminal (configuration struct) #19

Closed
brenol opened this issue Mar 28, 2016 · 3 comments
Closed

modd escaping values in terminal (configuration struct) #19

brenol opened this issue Mar 28, 2016 · 3 comments

Comments

@brenol
Copy link

brenol commented Mar 28, 2016

@brenol commented on Mon Mar 28 2016

Hello!

I have a JSON that is shown in the terminal with MarshalIndent and it's not looking good with modd, because of escaping. It's shown because its application configuration, for instance:

{\n\t\t\"Host\": \"http://localhost:8086\",\n\t\t\"Username\": \"user\",\n\t\t\"Password\": \"user\",\n\t\t\"BatchSize\": 1000\n\t}\n}"

I looked at the cli --help and I did not find any solution: Is there any way to disable escaping nowadays?

Thanks!

@cortesi
Copy link
Owner

cortesi commented Mar 30, 2016

Hey there. This sounds like an issue that's been fixed in master - could you please confirm that you still see this with a current checkout?

@brenol
Copy link
Author

brenol commented Mar 30, 2016

Hi @cortesi!

Just looked at the issue and it seems to be only happening with the logrus library. Its because it's not identifying moddas a terminal:

package logrus

import (
    "os"

    "golang.org/x/sys/unix"
)

// IsTerminal returns true if the given file descriptor is a terminal.
func IsTerminal() bool {
    _, err := unix.IoctlGetTermios(int(os.Stdout.Fd()), unix.TCGETA)
    return err == nil
}

Is this a expected behavior? (i.e. modd not be identified as a valid terminal)

Thanks!

@cortesi
Copy link
Owner

cortesi commented Mar 31, 2016

Ah, this clarifies things. I looked at ways of pretending to be a terminal to invoked processes, and it turns out it's not possible without a lot of fragile machinery and portability paraphernalia. Most pieces of software give you some way to over-ride the terminal detection - a quick read of the logrus code seems to show that ForceColor might do what you want (despite the fact that the escaped values here are not ANSI colour codes).

@cortesi cortesi closed this as completed Mar 31, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants