From 8ecb1d61f509d58f3d908b61522ea240422db56a Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Wed, 20 May 2026 22:32:52 +0700 Subject: [PATCH 1/7] Changed output of scount to not show file table by default, only summary. Added two options to show individual and all files in results. Option `--show-files` and option `--show-all-files` for scount. Modified output functions to conditionally display file tables based on new options. Added tests for new functionality to ensure correct output. Changed existing functionality tests to include the '--show-files' option when invoking scount under test so that the expected output stays the same and the test assertion is not invalidated by this change. [CL]: Added scount CLI --show-files option to control file table display in output. [CL]: Added scount CLI --show-all-files option to control file table display in output. [CL]: Changed scount output behaviour to not show file table by default. Signed-off-by: Phil Gaiser --- src/scount/c/arguments.c | 12 +++- src/scount/c/print.c | 14 +++-- src/scount/c/scount.h | 4 ++ src/scount/c/statistics.c | 2 + .../functionality/res/expected/mixed.txt | 37 ----------- .../res/expected/mixedWithAllFiles.txt | 62 +++++++++++++++++++ .../res/expected/mixedWithFiles.txt | 62 +++++++++++++++++++ .../tests/functionality/sh/test_scount.sh | 34 +++++++--- .../functionality/sh/test_scount_misc.sh | 2 +- src/scount/tests/unit/c/test_print.c | 3 +- 10 files changed, 176 insertions(+), 56 deletions(-) create mode 100644 src/scount/tests/functionality/res/expected/mixedWithAllFiles.txt create mode 100644 src/scount/tests/functionality/res/expected/mixedWithFiles.txt diff --git a/src/scount/c/arguments.c b/src/scount/c/arguments.c index 3a43d43..ca08384 100644 --- a/src/scount/c/arguments.c +++ b/src/scount/c/arguments.c @@ -33,6 +33,10 @@ AppArgs parseArgs(int argc, char** argv) { } else if (strcmp(argv[i], "--lines") == 0 || strcmp(argv[i], "-l") == 0) { args.linesOnly = true; + } else if (strcmp(argv[i], "--show-files") == 0) { + args.showFiles = true; + } else if (strcmp(argv[i], "--show-all-files") == 0) { + args.showAllFiles = true; } else if (strcmp(argv[i], "--stop-on-error") == 0) { args.stopOnError = true; } else if (strcmp(argv[i], "--strict") == 0) { @@ -76,7 +80,7 @@ AppArgs parseArgs(int argc, char** argv) { } void showUsage(void) { - logI("Usage: scount [--verbose] [--annotate-counts] [-l|--lines] [--stop-on-error] [--strict] "); + logI("Usage: scount [--verbose] [--annotate-counts] [-l|--lines] [--show-files|--show-all-files] [--stop-on-error] [--strict] "); } void showVersion(AppArgs args) { @@ -119,6 +123,12 @@ void showHelpText(void) { logI(" [-l|--lines] Compute and display only line-specific metrics."); logI(" This includes logical and physical lines."); logI(" "); + logI(" [--show-files] Show a table of individual files in the result."); + logI(" For large results, a condensed view with an ellipsis is used."); + logI(" "); + logI(" [--show-all-files] Show a table of all individual files in the result."); + logI(" All files are listed regardless of how many there are."); + logI(" "); logI(" [--stop-on-error] Stop processing immediately when an error is encountered."); logI(" "); logI(" [--strict] Use strict syntax checking when parsing source code."); diff --git a/src/scount/c/print.c b/src/scount/c/print.c index 5d6334d..5cbefd9 100644 --- a/src/scount/c/print.c +++ b/src/scount/c/print.c @@ -555,7 +555,8 @@ static size_t getIndexLastProcessedFile(const RcnCountStatistics* stats) { static void prFileRows(PrintBuffer* buffer, const RcnCountStatistics* stats) { const bool isLargeResult = ( - stats->count.sizeProcessed > LARGE_RESULT_THRESHOLD + !buffer->showAllFileRows + && stats->count.sizeProcessed > LARGE_RESULT_THRESHOLD ); bool ellipsisRowPrinted = false; const size_t nFiles = stats->count.size; @@ -817,11 +818,12 @@ void printResultsMultiple( prFileWarnings(buffer, stats); } - prTableTop(buffer, "File"); - prFileRows(buffer, stats); - prTableBottom(buffer, TABLE_BORDER_HORIZONTAL_NORMAL); - - prStr(buffer, "\nSummary:\n\n"); + if (buffer->showFileTable) { + prTableTop(buffer, "File"); + prFileRows(buffer, stats); + prTableBottom(buffer, TABLE_BORDER_HORIZONTAL_NORMAL); + prStr(buffer, "\nSummary:\n\n"); + } prTableTop(buffer, "Language"); prSummaryRows(buffer, stats); diff --git a/src/scount/c/scount.h b/src/scount/c/scount.h index cd14d56..38ef596 100644 --- a/src/scount/c/scount.h +++ b/src/scount/c/scount.h @@ -52,6 +52,8 @@ typedef struct AppArgs { bool readFromStdin; // True when 'inputPath' is '-' or '-.ext' bool annotateCounts; // Option: `--annotate-counts` bool linesOnly; // Option: `-l|--lines` + bool showFiles; // Option: `--show-files` + bool showAllFiles; // Option: `--show-all-files` bool stopOnError; // Option: `--stop-on-error` bool strict; // Option: `--strict` bool verbose; // Option: `--verbose` @@ -106,6 +108,8 @@ typedef struct PrintBuffer { bool showWords; bool showCharacters; bool showSourceSize; + bool showFileTable; + bool showAllFileRows; bool showWarnings; bool fileIsStdin; } PrintBuffer; diff --git a/src/scount/c/statistics.c b/src/scount/c/statistics.c index 85800e1..615495a 100644 --- a/src/scount/c/statistics.c +++ b/src/scount/c/statistics.c @@ -181,6 +181,8 @@ ExitStatus outputStatistics(AppArgs args) { .showWords = !args.linesOnly, .showCharacters = !args.linesOnly, .showSourceSize = !args.linesOnly, + .showFileTable = args.showFiles || args.showAllFiles, + .showAllFileRows = args.showAllFiles, .fileIsStdin = args.readFromStdin }; diff --git a/src/scount/tests/functionality/res/expected/mixed.txt b/src/scount/tests/functionality/res/expected/mixed.txt index 3a5759d..adb4056 100644 --- a/src/scount/tests/functionality/res/expected/mixed.txt +++ b/src/scount/tests/functionality/res/expected/mixed.txt @@ -1,43 +1,6 @@ Directory: mixed Scanned files: 32 - o---------- File ----------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o - | CMakeLists.txt | n/a | 10 | 21 | 250 | 250 | - | Sample1.cmake | n/a | 5 | 12 | 134 | 134 | - | Sample1.java | 3 | 12 | 34 | 233 | 233 | - | Sample2.java | 4 | 13 | 38 | 286 | 286 | - | sample1.R | n/a | 4 | 9 | 28 | 28 | - | sample1.c | 4 | 10 | 29 | 180 | 180 | - | sample1.css | n/a | 8 | 17 | 98 | 98 | - | sample1.html | n/a | 9 | 14 | 121 | 121 | - | sample1.js | 5 | 10 | 22 | 184 | 184 | - | sample1.json | n/a | 19 | 29 | 250 | 250 | - | sample1.md | n/a | 1 | 8 | 52 | 52 | - | sample1.py | 6 | 12 | 28 | 229 | 229 | - | sample1.sh | 3 | 7 | 16 | 97 | 97 | - | sample1.sql | n/a | 6 | 17 | 95 | 95 | - | sample1.ts | 5 | 14 | 27 | 216 | 216 | - | sample1.txt | n/a | 1 | 9 | 52 | 52 | - | sample1.xml | n/a | 9 | 18 | 204 | 204 | - | sample1.yaml | n/a | 6 | 11 | 73 | 73 | - | sample2.bash | 5 | 11 | 25 | 153 | 153 | - | sample2.c | 5 | 11 | 33 | 219 | 219 | - | sample2.css | n/a | 11 | 21 | 136 | 136 | - | sample2.html | n/a | 11 | 16 | 151 | 151 | - | sample2.js | 5 | 9 | 15 | 147 | 147 | - | sample2.json | n/a | 23 | 35 | 311 | 311 | - | sample2.md | n/a | 1 | 8 | 53 | 53 | - | sample2.py | 7 | 13 | 32 | 264 | 264 | - | sample2.r | n/a | 4 | 9 | 58 | 58 | - | sample2.sql | n/a | 11 | 31 | 170 | 170 | - | sample2.ts | 6 | 13 | 24 | 220 | 220 | - | sample2.txt | n/a | 2 | 13 | 75 | 75 | - | sample2.xml | n/a | 10 | 21 | 237 | 237 | - | sample2.yml | n/a | 7 | 13 | 93 | 93 | - o--------------------------o-----------o-----------o-----------o-----------o-----------o - -Summary: - o-------- Language --------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o | Plain Text | n/a | 3 | 22 | 127 | 127 | | Markdown | n/a | 2 | 16 | 105 | 105 | diff --git a/src/scount/tests/functionality/res/expected/mixedWithAllFiles.txt b/src/scount/tests/functionality/res/expected/mixedWithAllFiles.txt new file mode 100644 index 0000000..3a5759d --- /dev/null +++ b/src/scount/tests/functionality/res/expected/mixedWithAllFiles.txt @@ -0,0 +1,62 @@ +Directory: mixed +Scanned files: 32 + + o---------- File ----------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o + | CMakeLists.txt | n/a | 10 | 21 | 250 | 250 | + | Sample1.cmake | n/a | 5 | 12 | 134 | 134 | + | Sample1.java | 3 | 12 | 34 | 233 | 233 | + | Sample2.java | 4 | 13 | 38 | 286 | 286 | + | sample1.R | n/a | 4 | 9 | 28 | 28 | + | sample1.c | 4 | 10 | 29 | 180 | 180 | + | sample1.css | n/a | 8 | 17 | 98 | 98 | + | sample1.html | n/a | 9 | 14 | 121 | 121 | + | sample1.js | 5 | 10 | 22 | 184 | 184 | + | sample1.json | n/a | 19 | 29 | 250 | 250 | + | sample1.md | n/a | 1 | 8 | 52 | 52 | + | sample1.py | 6 | 12 | 28 | 229 | 229 | + | sample1.sh | 3 | 7 | 16 | 97 | 97 | + | sample1.sql | n/a | 6 | 17 | 95 | 95 | + | sample1.ts | 5 | 14 | 27 | 216 | 216 | + | sample1.txt | n/a | 1 | 9 | 52 | 52 | + | sample1.xml | n/a | 9 | 18 | 204 | 204 | + | sample1.yaml | n/a | 6 | 11 | 73 | 73 | + | sample2.bash | 5 | 11 | 25 | 153 | 153 | + | sample2.c | 5 | 11 | 33 | 219 | 219 | + | sample2.css | n/a | 11 | 21 | 136 | 136 | + | sample2.html | n/a | 11 | 16 | 151 | 151 | + | sample2.js | 5 | 9 | 15 | 147 | 147 | + | sample2.json | n/a | 23 | 35 | 311 | 311 | + | sample2.md | n/a | 1 | 8 | 53 | 53 | + | sample2.py | 7 | 13 | 32 | 264 | 264 | + | sample2.r | n/a | 4 | 9 | 58 | 58 | + | sample2.sql | n/a | 11 | 31 | 170 | 170 | + | sample2.ts | 6 | 13 | 24 | 220 | 220 | + | sample2.txt | n/a | 2 | 13 | 75 | 75 | + | sample2.xml | n/a | 10 | 21 | 237 | 237 | + | sample2.yml | n/a | 7 | 13 | 93 | 93 | + o--------------------------o-----------o-----------o-----------o-----------o-----------o + +Summary: + + o-------- Language --------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o + | Plain Text | n/a | 3 | 22 | 127 | 127 | + | Markdown | n/a | 2 | 16 | 105 | 105 | + | XML | n/a | 19 | 39 | 441 | 441 | + | JSON | n/a | 42 | 64 | 561 | 561 | + | CSS | n/a | 19 | 38 | 234 | 234 | + | HTML | n/a | 20 | 30 | 272 | 272 | + | SQL | n/a | 17 | 48 | 265 | 265 | + | CMake | n/a | 15 | 33 | 384 | 384 | + | YAML | n/a | 13 | 24 | 166 | 166 | + | C | 9 | 21 | 62 | 399 | 399 | + | Java | 7 | 25 | 72 | 519 | 519 | + | Python | 13 | 25 | 60 | 493 | 493 | + | JavaScript | 10 | 19 | 37 | 331 | 331 | + | TypeScript | 11 | 27 | 51 | 436 | 436 | + | R | n/a | 8 | 18 | 86 | 86 | + | Shell | 8 | 18 | 41 | 250 | 250 | + o==========================o===========o===========o===========o===========o===========o + | Total: | 58 | 293 | 655 | 5069 | 5069 | + o==========================o===========o===========o===========o===========o===========o + + diff --git a/src/scount/tests/functionality/res/expected/mixedWithFiles.txt b/src/scount/tests/functionality/res/expected/mixedWithFiles.txt new file mode 100644 index 0000000..3a5759d --- /dev/null +++ b/src/scount/tests/functionality/res/expected/mixedWithFiles.txt @@ -0,0 +1,62 @@ +Directory: mixed +Scanned files: 32 + + o---------- File ----------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o + | CMakeLists.txt | n/a | 10 | 21 | 250 | 250 | + | Sample1.cmake | n/a | 5 | 12 | 134 | 134 | + | Sample1.java | 3 | 12 | 34 | 233 | 233 | + | Sample2.java | 4 | 13 | 38 | 286 | 286 | + | sample1.R | n/a | 4 | 9 | 28 | 28 | + | sample1.c | 4 | 10 | 29 | 180 | 180 | + | sample1.css | n/a | 8 | 17 | 98 | 98 | + | sample1.html | n/a | 9 | 14 | 121 | 121 | + | sample1.js | 5 | 10 | 22 | 184 | 184 | + | sample1.json | n/a | 19 | 29 | 250 | 250 | + | sample1.md | n/a | 1 | 8 | 52 | 52 | + | sample1.py | 6 | 12 | 28 | 229 | 229 | + | sample1.sh | 3 | 7 | 16 | 97 | 97 | + | sample1.sql | n/a | 6 | 17 | 95 | 95 | + | sample1.ts | 5 | 14 | 27 | 216 | 216 | + | sample1.txt | n/a | 1 | 9 | 52 | 52 | + | sample1.xml | n/a | 9 | 18 | 204 | 204 | + | sample1.yaml | n/a | 6 | 11 | 73 | 73 | + | sample2.bash | 5 | 11 | 25 | 153 | 153 | + | sample2.c | 5 | 11 | 33 | 219 | 219 | + | sample2.css | n/a | 11 | 21 | 136 | 136 | + | sample2.html | n/a | 11 | 16 | 151 | 151 | + | sample2.js | 5 | 9 | 15 | 147 | 147 | + | sample2.json | n/a | 23 | 35 | 311 | 311 | + | sample2.md | n/a | 1 | 8 | 53 | 53 | + | sample2.py | 7 | 13 | 32 | 264 | 264 | + | sample2.r | n/a | 4 | 9 | 58 | 58 | + | sample2.sql | n/a | 11 | 31 | 170 | 170 | + | sample2.ts | 6 | 13 | 24 | 220 | 220 | + | sample2.txt | n/a | 2 | 13 | 75 | 75 | + | sample2.xml | n/a | 10 | 21 | 237 | 237 | + | sample2.yml | n/a | 7 | 13 | 93 | 93 | + o--------------------------o-----------o-----------o-----------o-----------o-----------o + +Summary: + + o-------- Language --------o--- LLC ---o--- PHL ---o--- WRD ---o--- CHR ---o--- SZE ---o + | Plain Text | n/a | 3 | 22 | 127 | 127 | + | Markdown | n/a | 2 | 16 | 105 | 105 | + | XML | n/a | 19 | 39 | 441 | 441 | + | JSON | n/a | 42 | 64 | 561 | 561 | + | CSS | n/a | 19 | 38 | 234 | 234 | + | HTML | n/a | 20 | 30 | 272 | 272 | + | SQL | n/a | 17 | 48 | 265 | 265 | + | CMake | n/a | 15 | 33 | 384 | 384 | + | YAML | n/a | 13 | 24 | 166 | 166 | + | C | 9 | 21 | 62 | 399 | 399 | + | Java | 7 | 25 | 72 | 519 | 519 | + | Python | 13 | 25 | 60 | 493 | 493 | + | JavaScript | 10 | 19 | 37 | 331 | 331 | + | TypeScript | 11 | 27 | 51 | 436 | 436 | + | R | n/a | 8 | 18 | 86 | 86 | + | Shell | 8 | 18 | 41 | 250 | 250 | + o==========================o===========o===========o===========o===========o===========o + | Total: | 58 | 293 | 655 | 5069 | 5069 | + o==========================o===========o===========o===========o===========o===========o + + diff --git a/src/scount/tests/functionality/sh/test_scount.sh b/src/scount/tests/functionality/sh/test_scount.sh index 592a010..9a41ef2 100644 --- a/src/scount/tests/functionality/sh/test_scount.sh +++ b/src/scount/tests/functionality/sh/test_scount.sh @@ -25,7 +25,7 @@ function test_scount_prints_correct_output_for_single_file_input() { } function test_scount_prints_correct_output_for_directory_input() { - run_app "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; + run_app --show-files "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multiple_files.txt"; assert_stderr_is_empty; @@ -39,7 +39,7 @@ function test_scount_with_relative_file_path_input() { } function test_scount_with_relative_directory_input() { - run_app "src/lib/tests/res/java"; + run_app --show-files "src/lib/tests/res/java"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multiple_files.txt"; assert_stderr_is_empty; @@ -74,7 +74,7 @@ function test_scount_prints_only_line_metrics_with_long_option() { } function test_scount_prints_only_line_metrics_with_short_option() { - run_app -l "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; + run_app -l --show-files "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multiple_files_lines_only.txt"; assert_stderr_is_empty; @@ -88,7 +88,7 @@ function test_scount_prints_correct_output_for_single_file_no_llc() { } function test_scount_prints_correct_output_for_multiple_files_no_llc() { - run_app "${TEST_PROJECT_DIR}/src/lib/tests/res/txt"; + run_app --show-files "${TEST_PROJECT_DIR}/src/lib/tests/res/txt"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multiple_files_no_llc.txt"; assert_stderr_is_empty; @@ -153,6 +153,20 @@ function test_scount_directory_input_with_trailing_path_separator() { assert_stderr_is_empty; } +function test_scount_with_show_files_option() { + run_app --show-files "${TEST_RES_DIR}/mixed"; + assert_exit_status $EXIT_SUCCESS; + assert_stdout_equals_file "expected/mixedWithFiles.txt"; + assert_stderr_is_empty; +} + +function test_scount_with_show_all_files_option() { + run_app --show-all-files "${TEST_RES_DIR}/mixed"; + assert_exit_status $EXIT_SUCCESS; + assert_stdout_equals_file "expected/mixedWithAllFiles.txt"; + assert_stderr_is_empty; +} + function test_scount_prints_verbose_output() { local test_path="${TEST_PROJECT_DIR}/src/lib/tests/res/java"; run_app --verbose "$test_path"; @@ -167,14 +181,14 @@ function test_scount_prints_verbose_output() { } function test_scount_with_directory_that_contains_file_with_syntax_error() { - run_app "${TEST_RES_DIR}/mixedWithSyntaxError"; + run_app --show-files "${TEST_RES_DIR}/mixedWithSyntaxError"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/mixedWithSyntaxErrorLenient.txt"; assert_stderr_is_empty; } function test_scount_with_strict_option_directory_that_contains_file_with_syntax_error() { - run_app --strict "${TEST_RES_DIR}/mixedWithSyntaxError"; + run_app --strict --show-files "${TEST_RES_DIR}/mixedWithSyntaxError"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/mixedWithSyntaxErrorStrict.txt"; assert_stderr_is_empty; @@ -190,7 +204,7 @@ function test_scount_with_file_that_has_syntax_error() { function test_scount_with_strict_option_file_that_has_syntax_error() { local file="${TEST_RES_DIR}/mixedWithSyntaxError/02_has_syntax_error.c"; - run_app --strict "$file"; + run_app --strict --show-files "$file"; assert_exit_status $EXIT_INVALID_INPUT; assert_stdout_is_empty; assert_stderr_contains "An error has occurred for: "; @@ -199,14 +213,14 @@ function test_scount_with_strict_option_file_that_has_syntax_error() { } function test_scount_with_stop_on_error_option() { - run_app --stop-on-error "${TEST_RES_DIR}/mixedWithSyntaxError"; + run_app --stop-on-error --show-files "${TEST_RES_DIR}/mixedWithSyntaxError"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/mixedWithSyntaxErrorLenient.txt"; assert_stderr_is_empty; } function test_scount_with_strict_and_stop_on_error_option() { - run_app --strict --stop-on-error "${TEST_RES_DIR}/mixedWithSyntaxError"; + run_app --strict --stop-on-error --show-files "${TEST_RES_DIR}/mixedWithSyntaxError"; assert_exit_status $EXIT_INVALID_INPUT; assert_stdout_is_empty; assert_stderr_contains "An error has occurred"; @@ -216,7 +230,7 @@ function test_scount_with_strict_and_stop_on_error_option() { } function test_scount_with_valid_directory_input_and_stop_on_error_option() { - run_app --stop-on-error "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; + run_app --stop-on-error --show-files "${TEST_PROJECT_DIR}/src/lib/tests/res/java"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multiple_files.txt"; assert_stderr_is_empty; diff --git a/src/scount/tests/functionality/sh/test_scount_misc.sh b/src/scount/tests/functionality/sh/test_scount_misc.sh index 3872f51..e4f44c2 100755 --- a/src/scount/tests/functionality/sh/test_scount_misc.sh +++ b/src/scount/tests/functionality/sh/test_scount_misc.sh @@ -49,7 +49,7 @@ function test_exit_status_when_std_streams_are_closed() { } function test_multi_byte_chars_in_filenames_are_handled_correctly() { - run_app "${TEST_PROJECT_DIR}/src/scount/tests/functionality/res/special"; + run_app --show-files "${TEST_PROJECT_DIR}/src/scount/tests/functionality/res/special"; assert_exit_status $EXIT_SUCCESS; assert_stdout_equals_file "expected/output_multi_byte_char_in_filename.txt"; assert_stderr_is_empty; diff --git a/src/scount/tests/unit/c/test_print.c b/src/scount/tests/unit/c/test_print.c index 9a4aac1..582105c 100644 --- a/src/scount/tests/unit/c/test_print.c +++ b/src/scount/tests/unit/c/test_print.c @@ -34,7 +34,8 @@ static PrintBuffer mkBufferAllMetrics(void) { .showPhysicalLines = true, .showWords = true, .showCharacters = true, - .showSourceSize = true + .showSourceSize = true, + .showFileTable = true }; } From e9bad627c034a3713a5e58f835c8205bcf27a3d4 Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Thu, 21 May 2026 22:32:18 +0700 Subject: [PATCH 2/7] Updated man page. Added documentation for --show-files and --show-all-files options. Signed-off-by: Phil Gaiser --- man/scount.1 | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/man/scount.1 b/man/scount.1 index d09f736..3124ffe 100644 --- a/man/scount.1 +++ b/man/scount.1 @@ -6,6 +6,7 @@ scount \- A tool to count logical lines of code and other metrics [\fB\-\-verbose\fR] [\fB\-\-annotate\-counts\fR] [\fB\-l\fR|\fB\-\-lines\fR] +[\fB\-\-show\-files\fR|\fB\-\-show\-all\-files\fR] [\fB\-\-stop\-on\-error\fR] [\fB\-\-strict\fR] .I @@ -61,6 +62,16 @@ Compute and display only line-specific metrics. .br This includes logical and physical lines. .TP +.B \-\-show\-files +Show a table of individual files in the result. +.br +For large results, a condensed view with an ellipsis is used. +.TP +.B \-\-show\-all\-files +Show a table of all individual files in the result. +.br +All files are listed regardless of how many there are. +.TP .B \-\-stop\-on\-error Stop the processing on the first encountered error, even for non\-critical errors. Without this option (the default), From 1bc9e07c8b419b9f7bdea8b3f1178bfbea0ff70b Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Sat, 23 May 2026 11:35:23 +0700 Subject: [PATCH 3/7] Improved scount usage text. Changed options indication to be shorter. Signed-off-by: Phil Gaiser --- src/scount/c/arguments.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/scount/c/arguments.c b/src/scount/c/arguments.c index ca08384..a7ea017 100644 --- a/src/scount/c/arguments.c +++ b/src/scount/c/arguments.c @@ -80,7 +80,7 @@ AppArgs parseArgs(int argc, char** argv) { } void showUsage(void) { - logI("Usage: scount [--verbose] [--annotate-counts] [-l|--lines] [--show-files|--show-all-files] [--stop-on-error] [--strict] "); + logI("Usage: scount [options] "); } void showVersion(AppArgs args) { From ac568072ffffe7d57d95ee7d6685cc0229575a49 Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Sat, 23 May 2026 11:37:34 +0700 Subject: [PATCH 4/7] Improved scount help text. Signed-off-by: Phil Gaiser --- src/scount/c/arguments.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/scount/c/arguments.c b/src/scount/c/arguments.c index a7ea017..80f2676 100644 --- a/src/scount/c/arguments.c +++ b/src/scount/c/arguments.c @@ -124,10 +124,10 @@ void showHelpText(void) { logI(" This includes logical and physical lines."); logI(" "); logI(" [--show-files] Show a table of individual files in the result."); - logI(" For large results, a condensed view with an ellipsis is used."); + logI(" For large results, a condensed view is shown."); logI(" "); logI(" [--show-all-files] Show a table of all individual files in the result."); - logI(" All files are listed regardless of how many there are."); + logI(" All files are listed without any limitation."); logI(" "); logI(" [--stop-on-error] Stop processing immediately when an error is encountered."); logI(" "); From b794a6e804f5346df826510ea31bcd2d7ca34ac0 Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Sat, 23 May 2026 11:38:36 +0700 Subject: [PATCH 5/7] Improved scount man page. Signed-off-by: Phil Gaiser --- man/scount.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/man/scount.1 b/man/scount.1 index 3124ffe..ad0d6e6 100644 --- a/man/scount.1 +++ b/man/scount.1 @@ -65,7 +65,7 @@ This includes logical and physical lines. .B \-\-show\-files Show a table of individual files in the result. .br -For large results, a condensed view with an ellipsis is used. +For large results, a condensed view is shown. .TP .B \-\-show\-all\-files Show a table of all individual files in the result. From 41936a61eaf71002f1af4e3202c7c83cc5be5cc9 Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Sat, 23 May 2026 11:49:06 +0700 Subject: [PATCH 6/7] Improved readability of prFileRows() function. Signed-off-by: Phil Gaiser --- src/scount/c/print.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/scount/c/print.c b/src/scount/c/print.c index 5cbefd9..2cc0e50 100644 --- a/src/scount/c/print.c +++ b/src/scount/c/print.c @@ -555,9 +555,9 @@ static size_t getIndexLastProcessedFile(const RcnCountStatistics* stats) { static void prFileRows(PrintBuffer* buffer, const RcnCountStatistics* stats) { const bool isLargeResult = ( - !buffer->showAllFileRows - && stats->count.sizeProcessed > LARGE_RESULT_THRESHOLD + stats->count.sizeProcessed > LARGE_RESULT_THRESHOLD ); + const bool checkTableSize = !buffer->showAllFileRows; bool ellipsisRowPrinted = false; const size_t nFiles = stats->count.size; const size_t indexLastProcessed = getIndexLastProcessedFile(stats); @@ -572,7 +572,7 @@ static void prFileRows(PrintBuffer* buffer, const RcnCountStatistics* stats) { rowsPrinted >= LARGE_RESULT_THRESHOLD - 1 && i != indexLastProcessed ); - if (isLargeResult && isInSkipRange) { + if (checkTableSize && isLargeResult && isInSkipRange) { if (ellipsisRowPrinted) { continue; } From 4b3406e32cbd609089148a80a6895361bb98ba66 Mon Sep 17 00:00:00 2001 From: Phil Gaiser Date: Sun, 24 May 2026 09:56:39 +0700 Subject: [PATCH 7/7] Changed test file mixedWithFiles to show condensed view. Test case for --show-files should be different than --show-all-files. Signed-off-by: Phil Gaiser --- src/scount/c/print.c | 2 +- src/scount/tests/functionality/res/expected/mixedWithFiles.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/scount/c/print.c b/src/scount/c/print.c index 2cc0e50..8b3a251 100644 --- a/src/scount/c/print.c +++ b/src/scount/c/print.c @@ -31,7 +31,7 @@ #define MAX_DIGITS_INT64 22ULL static const size_t BUFFER_CAPACITY_INIT = 1024; -static const size_t LARGE_RESULT_THRESHOLD = 32; +static const size_t LARGE_RESULT_THRESHOLD = 30; static const int WIDTH_COL0 = 26; // File static const int WIDTH_COL1 = 11; // LLC diff --git a/src/scount/tests/functionality/res/expected/mixedWithFiles.txt b/src/scount/tests/functionality/res/expected/mixedWithFiles.txt index 3a5759d..49178a7 100644 --- a/src/scount/tests/functionality/res/expected/mixedWithFiles.txt +++ b/src/scount/tests/functionality/res/expected/mixedWithFiles.txt @@ -31,8 +31,7 @@ Scanned files: 32 | sample2.r | n/a | 4 | 9 | 58 | 58 | | sample2.sql | n/a | 11 | 31 | 170 | 170 | | sample2.ts | 6 | 13 | 24 | 220 | 220 | - | sample2.txt | n/a | 2 | 13 | 75 | 75 | - | sample2.xml | n/a | 10 | 21 | 237 | 237 | + | .. | ... | ... | ... | ... | ... | | sample2.yml | n/a | 7 | 13 | 93 | 93 | o--------------------------o-----------o-----------o-----------o-----------o-----------o