XAMPPRocky / tokei

Count your code, quickly.
Other
11.17k stars 534 forks source link

Tokei looks ugly for terminal too long or too short #277

Closed pickfire closed 5 years ago

pickfire commented 6 years ago

When the terminal is too long (340 columns), the output is not easily readable without highlighting line by line.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Language                                                                                                                                                                                                                                                                                 Files        Lines         Code     Comments       Blanks
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Ada                                                                                                                                                                                                                                                                                        209        24453        17387         3797         3269
 Assembly                                                                                                                                                                                                                                                                                   346        53977        43740         2487         7750
 Autoconf                                                                                                                                                                                                                                                                                    13         1699         1103          175          421
 BASH                                                                                                                                                                                                                                                                                         2         1367         1048          134          185
 C                                                                                                                                                                                                                                                                                         7304      1876340      1202924       447957       225459
 C Header                                                                                                                                                                                                                                                                                  5237      1445241       837509       467371       140361
 C++                                                                                                                                                                                                                                                                                          2         2647         2255           94          298
 CSS                                                                                                                                                                                                                                                                                          1           19            8            8            3
 Device Tree                                                                                                                                                                                                                                                                                 14         4090         2735          927          428
 Dockerfile                                                                                                                                                                                                                                                                                   5          226          166           34           26
 Go                                                                                                                                                                                                                                                                                          17         4664         3799          214          651
 Happy                                                                                                                                                                                                                                                                                        4         1526         1314            0          212
 HEX                                                                                                                                                                                                                                                                                        218         7904         7904            0            0
 HTML                                                                                                                                                                                                                                                                                        10         2492         2300            0          192
 JSON                                                                                                                                                                                                                                                                                         5          144          144            0            0
 LD Script                                                                                                                                                                                                                                                                                    1          116           87            6           23
 Makefile                                                                                                                                                                                                                                                                                   258        18134        11182         3590         3362
 Markdown                                                                                                                                                                                                                                                                                   156        12171        12171            0            0
 Module-Definition                                                                                                                                                                                                                                                                            2          464          464            0            0
 Perl                                                                                                                                                                                                                                                                                         8        11324         8939          843         1542
 Python                                                                                                                                                                                                                                                                                      65        20375        14335         2635         3405
 ReStructuredText                                                                                                                                                                                                                                                                            35        17483        17483            0            0
 Shell                                                                                                                                                                                                                                                                                      193        20532        13332         4206         2994
 SVG                                                                                                                                                                                                                                                                                          8          524          522            0            2
 TCL                                                                                                                                                                                                                                                                                          3          257          149           64           44
 TeX                                                                                                                                                                                                                                                                                          5         1229          967           42          220
 Plain Text                                                                                                                                                                                                                                                                                 312        17362        17362            0            0
 XML                                                                                                                                                                                                                                                                                          2         2933         2858           21           54
 YAML                                                                                                                                                                                                                                                                                        10          748          597           91           60
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 Total                                                                                                                                                                                                                                                                                    14445      3550441      2224784       934696       390961
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Suggestion:

When the terminal is too small (80 columns), error message (tokei -o json when json feature is not enabled) looks weird.

Error:
This version of tokei was compiled without any 'json' serialization support, to
enable serialization, reinstall tokei with the features flag.

    cargo install tokei --features json

If you want to enable all supported serialization formats, you can use the 'all'
 feature.

    cargo install tokei --features all

Further more, the help is hard to read as compared to error messages which is readable.

tokei 8.0.1 compiled without serialization formats.
Aaron P. <theaaronepower@gmail.com> + Contributors
A utility that allows you to count code, quickly.

USAGE:
    tokei [FLAGS] [OPTIONS] [--] [input]...

FLAGS:
    -f, --files        Will print out statistics on individual files.
    -h, --help         Prints help information
    -l, --languages    Prints out supported languages and their extensions.
    -V, --version      Prints version information
    -v, --verbose      Set log output level:
                                1: to show unknown file extensions,
                                2: reserved for future debugging,
                                3: enable file level trace. Not recommended on m
ultiple files

OPTIONS:
    -e, --exclude <exclude>...    Ignore all files & directories containing the
word.
    -i, --input <file_input>      Gives statistics from a previous tokei run. Ca
n be given a file path, or "stdin" to
                                  read from stdin.
    -o, --output <output>         Outputs Tokei in a specific format. Compile wi
th additional features for more format
                                  support. [possible values: cbor, json, yaml, t
oml]
    -s, --sort <sort>             Sort languages based on column [possible value
s: files, lines, blanks, code, comments]
    -t, --type <types>            Filters output by language type, seperated by
a comma. i.e. -t=Rust,Markdown

ARGS:
    <input>...    The input file(s)/directory(ies) to be counted.

Suggestion:

Note: I agree that everyone could buy a bigger monitor if the screen is small or reduce the width and font size of terminal is the screen is big. But I just hope that tokei could look the best no matter the terminal or screen size. In a nutshell, readability matters.

XAMPPRocky commented 6 years ago

Thank you for your issue! There are plans to add a column width argument so that you can set the width of the output yourself, that error message should not and does not come up when I run tokei at 80 column width. The help message text formatting is not up to tokei as it isn't generated by tokei it is generated using clap.rs

pickfire commented 6 years ago

@Aaronepower Thanks a lot for the quick response. :smile:

Sorry, I forgot to mention the error message are generated by tokei -o json where I did not enable the feature json.

matklad commented 5 years ago

Thank you for your issue! There are plans to add a column width argument so that you can set the width of the output yourself,

Limiting, by default, to something like 80 might be easier and more useful then a user-configurable option.

matklad commented 5 years ago

Hm, perhaps even limiting is not required? All output is known upfront, so it should be possible to calculate the desired width and just use that?

pickfire commented 5 years ago

@matklad Yes, it would be even cooler if we do it in compile time (but I am not sure how that works). Still, I prefer to keep it below 80.

XAMPPRocky commented 5 years ago

Sorry I haven't replied to this issue, I do actually have a working implementation for setting a width limit. I will try to release it by the end of the month.

matklad commented 5 years ago

@Aaronepower yep, just saw that. -c options looks great, but I suggest using at most 79 by default as well: https://github.com/Aaronepower/tokei/pull/286

XAMPPRocky commented 5 years ago

So now in 9.0.0 you can add config file so that you can manually specify the width of Tokei whenever it runs. I think this adequately solves this issue, please do provide feedback if you feel it is lacking in a certain aspect.