File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed
Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,28 @@ func handleHelpFlag(args []string) {
1616 }
1717}
1818
19+ // ValidateNaturesArgs validates the command line arguments
20+ func ValidateNaturesArgs (args []string ) error {
21+ handleHelpFlag (args )
22+
23+ if len (args ) > 3 {
24+ errMessage := errorBorder .Render (errorColor .Render ("Error!" ), "\n Too many arguments" )
25+ return fmt .Errorf ("%s" , errMessage )
26+ }
27+
28+ // Check if there are exactly 3 arguments and the third argument is neither '-h' nor '--help'
29+ // If true, return an error message since only '-h' and '--help' are allowed after 'types'
30+ if len (args ) == 3 && (args [2 ] != "-h" && args [2 ] != "--help" ) {
31+ errorTitle := errorColor .Render ("Error!" )
32+ errorString := "\n The only currently available options\n after [natures] command are '-h' or '--help'"
33+ finalErrorMessage := errorTitle + errorString
34+ renderedError := errorBorder .Render (finalErrorMessage )
35+ return fmt .Errorf ("%s" , renderedError )
36+ }
37+
38+ return nil
39+ }
40+
1941// ValidatePokemonArgs validates the command line arguments
2042func ValidatePokemonArgs (args []string ) error {
2143 handleHelpFlag (args )
You can’t perform that action at this time.
0 commit comments