File tree Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Expand file tree Collapse file tree 2 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ package main
5
5
import (
6
6
"fmt"
7
7
"os"
8
+ "strings"
8
9
9
10
"github.com/boyter/scc/v3/processor"
10
11
"github.com/spf13/cobra"
@@ -16,6 +17,23 @@ func main() {
16
17
//pprof.StartCPUProfile(f)
17
18
//defer pprof.StopCPUProfile()
18
19
20
+ if len (os .Args ) == 2 && strings .HasPrefix (os .Args [1 ], "@" ) {
21
+ // handle "scc @flags.txt" syntax
22
+ filepath := strings .TrimPrefix (os .Args [1 ], "@" )
23
+ b , err := os .ReadFile (filepath )
24
+ if err != nil {
25
+ fmt .Printf ("Error reading flags from a file: %s\n " , err )
26
+ os .Exit (1 )
27
+ }
28
+
29
+ args := strings .Split (string (b ), "\n " )
30
+ var newArgs []string
31
+ for _ , x := range args {
32
+ newArgs = append (newArgs , strings .TrimSpace (x ))
33
+ }
34
+ os .Args = append ([]string {os .Args [0 ]}, newArgs ... )
35
+ }
36
+
19
37
rootCmd := & cobra.Command {
20
38
Use : "scc [flags] [files or directories]" ,
21
39
Short : "scc [files or directories]" ,
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
2
3
+ # make sure this script can be executed from any dir
4
+ cd $( dirname $0 )
5
+
3
6
GREEN=' \033[1;32m'
4
7
RED=' \033[0;31m'
5
8
NC=' \033[0m'
@@ -28,6 +31,24 @@ echo '```' > LANGUAGES.md
28
31
./scc --languages >> LANGUAGES.md
29
32
echo ' ```' >> LANGUAGES.md
30
33
34
+
35
+ echo " Running with @file flag parsing syntax"
36
+ # include \n, \r\n and no line terminators
37
+ echo -e " go.mod\ngo.sum\r\nLICENSE" > flags.txt
38
+ if ./scc @flags.txt ; then
39
+ echo -e " ${GREEN} PASSED @file flag syntax"
40
+ # post processing
41
+ rm flags.txt
42
+ else
43
+ echo -e " ${RED} ======================================================="
44
+ echo -e " FAILED Should handle @file flag parsing syntax"
45
+ echo -e " =======================================================${NC} "
46
+ # post processing
47
+ rm flags.txt
48
+ exit
49
+ fi
50
+
51
+
31
52
echo " Building HTML report..."
32
53
33
54
./scc --format html -o SCC-OUTPUT-REPORT.html
You can’t perform that action at this time.
0 commit comments