Skip to content

Impossible to parse --version from a script #334

@kevinburke1

Description

@kevinburke1

Say I want to ensure that users are running a given postcss version from a Bash script, or say, ensuring everyone is running a version higher than 6. Normally you would do this by running <binary> --version and parsing the output. However, that's impossible (or much tougher, anyway) with postcss because this is the output that you get.

$ postcss --version

                                      /|\
                                    //   //
                                  //       //
                                //___*___*___//
                              //--*---------*--//
                            /|| *             * ||/
                          // ||*    v7.1.1     *|| //
                        //   || *             * ||   //
                      //_____||___*_________*___||_____//

I could write something that says "look for the fourth token in the sixth line" or something but that's extremely brittle. I also tried piping the output just to see if it would print something sane, but no, that also prints out version pyramid.

$ postcss --version | cat

                                      /|\
                                    //   //
                                  //       //
                                //___*___*___//
                              //--*---------*--//
                            /|| *             * ||/
                          // ||*    v7.1.1     *|| //
                        //   || *             * ||   //
                      //_____||___*_________*___||_____//

This is also frustrating to blind programmers with screen readers. I suggest you paste this output into Text Edit and then turn on VoiceOver for Mac... the output is roughly:

slash vertical bar forward slash slash slash slash slash slash slash slash slash slash slash underscore underscore underscore asterisk underscore underscore underscore asterisk underscore underscore underscore slash slash

and I'm only done with line 3. The version number will eventually print out on line 6.

I understand that it is amusing to print the version string in this way but please consider that users besides humans with working eyesight exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions