Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Remove custom validation
Browse files Browse the repository at this point in the history
Use framework provided validation.
  • Loading branch information
VijayanB committed Mar 26, 2021
1 parent 3e8cd56 commit eef9c89
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 23 deletions.
8 changes: 2 additions & 6 deletions commands/ad_delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package commands

import (
"fmt"
handler "odfe-cli/handler/ad"

"github.com/spf13/cobra"
Expand All @@ -35,12 +34,9 @@ var deleteDetectorsCmd = &cobra.Command{
Short: "Delete detectors based on a list of IDs, names, or name regex patterns",
Long: "Delete detectors based on list of IDs, names, or name regex patterns.\n" +
"Wrap regex patterns in quotation marks to prevent the terminal from matching patterns against the files in the current directory.\nThe default input is detector name. Use the `--id` flag if input is detector ID instead of name",

Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
fmt.Println(cmd.Usage())
return
}
force, _ := cmd.Flags().GetBool(detectorForceDeletionFlagName)
detectorID, _ := cmd.Flags().GetBool(deleteDetectorIDFlagName)
action := handler.DeleteAnomalyDetectorByNamePattern
Expand Down
6 changes: 1 addition & 5 deletions commands/ad_get.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,8 @@ var getDetectorsCmd = &cobra.Command{
Short: "Get detectors based on a list of IDs, names, or name regex patterns",
Long: "Get detectors based on a list of IDs, names, or name regex patterns.\n" +
"Wrap regex patterns in quotation marks to prevent the terminal from matching patterns against the files in the current directory.\nThe default input is detector name. Use the `--id` flag if input is detector ID instead of name",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
fmt.Println(cmd.Usage())
return
}
err := printDetectors(Println, cmd, args)
if err != nil {
DisplayError(err, getDetectorsCommandName)
Expand Down
5 changes: 1 addition & 4 deletions commands/ad_start_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,8 @@ var startDetectorsCmd = &cobra.Command{
Long: "Start detectors based on a list of IDs, names, or name regex patterns.\n" +
"Wrap regex patterns in quotation marks to prevent the terminal from matching patterns against the files in the current directory.\n" +
"The default input is detector name. Use the `--id` flag if input is detector ID instead of name",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
if len(args) < 1 {
fmt.Println(cmd.Usage())
return
}
idStatus, _ := cmd.Flags().GetBool(idFlagName)
action := ad.StartAnomalyDetectorByNamePattern
if idStatus {
Expand Down
9 changes: 1 addition & 8 deletions commands/ad_update.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package commands

import (
"fmt"
handler "odfe-cli/handler/ad"

"github.com/spf13/cobra"
Expand All @@ -35,14 +34,8 @@ var updateDetectorsCmd = &cobra.Command{
Long: "Update detectors based on JSON files.\n" +
"To begin, use `odfe-cli ad get detector-name > detector_to_be_updated.json` to download the detector. " +
"Modify the file, and then use `odfe-cli ad update file-path` to update the detector.",
Args: cobra.MinimumNArgs(1),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
if err := cmd.Usage(); err != nil {
fmt.Println(err)
}
return
}
force, _ := cmd.Flags().GetBool(forceFlagName)
start, _ := cmd.Flags().GetBool(startFlagName)
err := updateDetectors(args, force, start)
Expand Down

0 comments on commit eef9c89

Please sign in to comment.