check for unsupported flags while running uplink (#316)

* uplink handle invalid or more than needed arguments

* updated the error reporting

* rebase from master

* check for unsupported flags
This commit is contained in:
aligeti 2018-09-06 12:43:08 -04:00 committed by GitHub
parent f168e19fb4
commit 75110cf2da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -54,10 +54,16 @@ func init() {
}
func cmdRun(cmd *cobra.Command, args []string) (err error) {
if len(args) > 0x00 {
fmt.Println("Invalid arguments. Rerun with 'uplink run'")
return nil
/* check for the supported flags */
flagsupported := cmd.Flags()
for _, flagname := range args {
f := flagsupported.Lookup(flagname)
if f == nil {
fmt.Println(flagname + " - Invalid flag. try 'uplink run'")
return nil
}
}
return runCfg.Run(process.Ctx(cmd))
}
@ -67,6 +73,16 @@ func cmdSetup(cmd *cobra.Command, args []string) (err error) {
return err
}
/* check for the supported flags */
flagsupported := cmd.Flags()
for _, flagname := range args {
f := flagsupported.Lookup(flagname)
if f == nil {
fmt.Println(flagname + " - Invalid flag. Supported list use --help")
return nil
}
}
_, err = os.Stat(setupCfg.BasePath)
if !setupCfg.Overwrite && err == nil {
fmt.Println("An uplink configuration already exists. Rerun with --overwrite")