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

Enhance message output #32

Open
desyncr opened this issue Feb 16, 2017 · 11 comments
Open

Enhance message output #32

desyncr opened this issue Feb 16, 2017 · 11 comments
Assignees
Milestone

Comments

@desyncr
Copy link
Member

desyncr commented Feb 16, 2017

Related Trello card: https://trello.com/c/fZHPQp8q/9-fancy-output

Probably [ZPM] to start every line except for list. Maybe green for standard message and red for error. Also plugin name should be bold.

@desyncr desyncr added this to the v0.2.0 milestone Feb 16, 2017
@fennecdjay
Copy link
Member

fennecdjay commented Feb 16, 2017

what about usage?
Does it need [ZPM] header?
I think the whole usage string should be defined as static const char*.


Also do we have to ouput errors to stderr?

@desyncr
Copy link
Member Author

desyncr commented Feb 16, 2017

Also do we have to ouput errors to stderr?

Sure thing about this.

what about usage?

I think we can have a wrapper/lib around message/output handling. This is particularly useful when trying to debug and you need extended output. So I'm thinking on a logging library, probably there's one out there that fits our needs.

@fennecdjay
Copy link
Member

So I'm thinking on a logging library

Well, i think enums and a simple function could do, so I do not see the benefit of a logging library.

@fennecdjay
Copy link
Member

enum ZPM_MSG_TYPE {
    ZPM_MSG,
    ZPM_ERR,
    ZPM_NONE
};

void zpm_msg(enum ZPM_MSG_TYPE type, const char* format, ...) {
    char msg[PATH_MAX];
    FILE* f = type = ZPM_ERR ? stderr : stdout;
    va_list arg;
    va_start(arg, fmt);
    vsnprintf(msg, 256, fmt, arg);
    if (type != ZPM_NONE) {
        fprintf(f, "[ZPM] ");
    }
    fprintf(f, "%s\n", msg);
    va_end(arg);

}

Do we need coloration? I'd quite like that.

    if (type != ZPM_NONE {
        int color = type == ZPM_ERR : 31 : 32;
        fprintf(f, "\033[1m[\033[0m\033[%imZPM\033[0m\033[1m]\033[0m", color);
    }

also

printf("\033[1m%s\033[0m", plugin_name);

in plugin_print_list would make plugin_name bold, which, in my opinion, is nice 😄

@desyncr
Copy link
Member Author

desyncr commented Feb 16, 2017

Well, having different error levels (debug, info, error, etc) would be nice. If we can have that in a couple of lines it's welcome! :D

@fennecdjay
Copy link
Member

Would you like me to give it a try based on what I posted before (thus renaming ZPM_NONE to ZPM_INFO) ?

@desyncr
Copy link
Member Author

desyncr commented Feb 16, 2017

Yeah sure, it will be great to tell zpm what to log:

zpm "zsh-users/zsh-syntax-highlighting" --log=info
[INFO] Installing plugin from "https://github.com/zsh-users/zsh-syntax-highlighting.git"
[INFO] ... 

zpm "zsh-users/zsh-syntax-highlighting" --log=debug
[DEBUG] Parting argument: "zsh-users/zsh-syntax-highlighting"
[DEBUG] No host provided. Using default "github.com"
[DEBUG] Converting FQ URL: "https://github.com/zsh-users/zsh-syntax-highlighting.git"
[INFO] Installing plugin from "https://github.com/zsh-users/zsh-syntax-highlighting.git"
...

@fennecdjay
Copy link
Member

We migth need to make color optionnal, maybe depending on wther or not it is running in a pipe, as it mess with cram.

@desyncr
Copy link
Member Author

desyncr commented Feb 16, 2017

Yep a --color flag would also be useful.

@fennecdjay
Copy link
Member

fennecdjay commented Feb 16, 2017

I have trouble finding info on check the process is running in a pipe in C 😕
But I was thinking on having a ZPM_COLOR environment variable.

@fennecdjay
Copy link
Member

fennecdjay commented Feb 16, 2017

see #33.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants