Browse Source

Added a license flag

main
Unbewohnte 3 years ago
parent
commit
00729e0f26
  1. 22
      main.go

22
main.go

@ -1,6 +1,7 @@
package main package main
import ( import (
_ "embed"
"flag" "flag"
"fmt" "fmt"
"os" "os"
@ -11,15 +12,26 @@ import (
) )
// flags // flags
var PORT *int = flag.Int("port", 8080, "Specifies a port for a sender|port to connect to") var (
var SENDERADDR *string = flag.String("addr", "", "Specifies an address to connect to") PORT *int = flag.Int("port", 8080, "Specifies a port for a sender|port to connect to")
var DOWNLOADSFOLDER *string = flag.String("downloadto", ".", "Specifies where the receiver will store downloaded file") SENDERADDR *string = flag.String("addr", "", "Specifies an address to connect to")
var SHAREDFILE *string = flag.String("sharefile", "", "Specifies what file sender will send") DOWNLOADSFOLDER *string = flag.String("downloadto", ".", "Specifies where the receiver will store downloaded file")
SHAREDFILE *string = flag.String("sharefile", "", "Specifies what file sender will send")
LICENSE *bool = flag.Bool("license", false, "Prints a license text")
var SENDING bool SENDING bool
//go:embed LICENSE
LicenseText string
)
// Input-validation // Input-validation
func validateFlags() { func validateFlags() {
if *LICENSE {
fmt.Println(LicenseText)
os.Exit(0)
}
// port validation // port validation
if *PORT < 0 { if *PORT < 0 {
fmt.Println("Invalid port !") fmt.Println("Invalid port !")

Loading…
Cancel
Save