Skip to content

Commit

Permalink
♻️ Update flag.Usage
Browse files Browse the repository at this point in the history
  • Loading branch information
UltiRequiem committed Oct 7, 2021
1 parent 6574d78 commit a248e46
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 3 additions & 1 deletion cmd/parameters.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package cmd

import "flag"

func getParametersAndFlags() (bool, bool, []string) {
func parametersAndFlags() (bool, bool, []string) {
help := flag.Bool("help", false, "Display Help")
helpShort := flag.Bool("h", false, "Display Help")

flag.Usage = printHelp

flag.Parse()

return *help || *helpShort, flag.NArg() > 0, flag.Args()
Expand Down
9 changes: 4 additions & 5 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,15 @@ func Main() {
// Windows Support
defer colorable.EnableColorsStdout(nil)()

help, thereFileArguments, files := getParametersAndFlags()
help, fileArguments, files := parametersAndFlags()

if help {
PrintHelp()
printHelp()
return
}

if thereFileArguments {
text := JoinFilesToString(files)
PrintWithScanner(text)
if fileArguments {
PrintWithScanner(JoinFilesToString(files))
return
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (

const VERSION = "1.0.0"

func PrintHelp() {
func printHelp() {

helpMessage := ` Chigo %s
Expand Down

0 comments on commit a248e46

Please sign in to comment.