Skip to content

Commit

Permalink
fix(info) #1
Browse files Browse the repository at this point in the history
  • Loading branch information
anhgelus committed Mar 24, 2023
1 parent b7ea85f commit 099e772
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ var staticContent embed.FS
func main() {
args.GenerateLicenseMap()
arg := args.ParseCliArgs()
if arg.Info {
os.Exit(0)
}
arg.HandleArgs()

l := findLicense(arg.LicenseType)
Expand Down
1 change: 1 addition & 0 deletions src/args/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type Arguments struct {
Year string
Authors []string
Question bool
Info bool
}

type License string
Expand Down
23 changes: 22 additions & 1 deletion src/args/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,44 @@ func ParseCliArgs() *Arguments {
if len(args) < 2 {
return &Arguments{Question: true}
}
arguments := Arguments{}
arguments := Arguments{Info: false}
l := 0
tb := false

ar:
for i, arg := range args {
if i == 0 {
continue
}
if arg == "-h" {
println(HelpArg.textGenerator())
tb = true
}
for _, av := range argLists {
if arg != av.GenerateParameter() {
continue
}
arguments.assignValueToArguments(&av, args[i+1])
l++
}
for _, av := range infoArgLists {
if arg != av.GenerateParameter() {
continue
}
println(av.textGenerator())
l++
tb = true
}
if tb {
break ar
}
}
if l != 4 {
arguments.Question = true
}
if tb {
arguments.Info = true
}
return &arguments
}

Expand Down

0 comments on commit 099e772

Please sign in to comment.