commit 00f682c2eb6300baf3ed504767d6983fe5db0010
parent 3dba9d761b8b07e232e127f6f8681db329f28bad
Author: Tyler Clark <tyler.clark@foxide.xyz>
Date: Thu, 8 Jan 2026 16:31:07 -0500
Adds basics checks for required arguments.
This patch adds some basic checks to make sure the required amount of arguments
were passed to the program. If no arguments are passed, it will immediately
fail. If only one is passed, then it will check to make sure it is a valid one
argument flag. If it is not it will fail.
Diffstat:
1 file changed, 14 insertions(+), 0 deletions(-)
diff --git a/main.go b/main.go
@@ -82,6 +82,13 @@ func ArgParser (argument[] string) {
println("Version:", version)
os.Exit(0)
default:
+ /* Fail if less than two arguments are passed */
+ /* Must have at least source and dest for application to work */
+ if (len(argument) < 2) {
+ println("Not enough arguments!")
+ CallHelp()
+ os.Exit(1)
+ }
DirSetup(argument[i], argument[i + 1])
i++
//ValidateFile(argument[i])
@@ -92,6 +99,13 @@ func ArgParser (argument[] string) {
func main() {
arguments := os.Args[1:]
+ /* Fail if no arguments are passed */
+ if (len(arguments) == 0) {
+ println("Not enough arguments!")
+ CallHelp()
+ os.Exit(1)
+ }
+
/* Parse the various options to figure out what we are doing */
ArgParser(arguments)
}