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

CLI: Update Display Strings #231

Merged
merged 1 commit into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cli/cmd/cat.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ const (
var catCmd = &cobra.Command{
Use: commandCat + " [flags] [list of detectors]",
Short: "Concatenate and print detectors based on id or name pattern",
Long: `concatenate and print detectors based on pattern, use "" to make sure the name is not matched with pwd lists'`,
Long: fmt.Sprintf("Description:\n " +
`Concatenate and print detectors based on pattern, use "" to make sure the name is not matched with pwd lists'`),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
Expand Down
3 changes: 2 additions & 1 deletion cli/cmd/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ const (
var createCmd = &cobra.Command{
Use: commandCreate + " [list of file-path] [flags]",
Short: "Creates detectors based on configurations",
Long: `Creates detectors based on a configuration specified by a file path`,
Long: fmt.Sprintf("Description:\n " +
`Creates detectors based on a configuration specified by a file path`),
Run: func(cmd *cobra.Command, args []string) {
generate, _ := cmd.Flags().GetBool(generate)
if generate {
Expand Down
5 changes: 3 additions & 2 deletions cli/cmd/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ const commandDelete = "delete"
//default input is name pattern, one can change this format to be id by passing --id flag
var deleteCmd = &cobra.Command{
Use: commandDelete + " [flags] [list of detectors]",
Short: "Deletes detectors",
Long: `Deletes detectors based on a specified value. Use "" to make sure the name does not match with pwd lists'`,
Short: "Deletes detectors based on an id or name pattern",
Long: fmt.Sprintf("Description:\n " +
`Deletes detectors based on a specified value. Use "" to make sure the name does not match with pwd lists'`),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
Expand Down
13 changes: 7 additions & 6 deletions cli/cmd/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,12 @@ const (
//profilesCmd is main command for profile operations like list, create and delete
var profilesCmd = &cobra.Command{
Use: profileBaseCmdName + " [flags] [command] [sub command]",
Short: "A profile is a collection of settings and credentials that you can apply to an ESAD command",
Long: `A named profile is a collection of settings and credentials that you can apply to an ESAD command.
When you specify a profile for a command, its settings and credentials are used to run that command.
To configure a default profile for commands, specify the default profile in an environment variable (ESAD_PROFILE).
The ESAD CLI supports using any of the multiple named profiles that are stored in the configuration and credential files.`,
Short: "Manage collection of settings and credentials that you can apply to an ESAD command",
Long: fmt.Sprintf("Description:\n " +
`A named profile is a collection of settings and credentials that you can apply to an ESAD command.
When you specify a profile for a command, its settings and credentials are used to run that command.
To configure a default profile for commands, specify the default profile in an environment variable (ESAD_PROFILE).
The ESAD CLI supports using any of the multiple named profiles that are stored in the configuration and credential files.`),
}

//createProfilesCmd creates profile interactively by prompting for name (distinct), user, endpoint, password.
Expand Down Expand Up @@ -77,7 +78,7 @@ var deleteProfileCmd = &cobra.Command{
//listProfilesCmd lists profiles from config profile in tabular format.
var listProfilesCmd = &cobra.Command{
Use: listProfileCmdName,
Short: "lists named profiles",
Short: "Lists named profiles",
Long: `A named profile is a collection of settings and credentials that you can apply to an ESAD command.`,
Run: func(cmd *cobra.Command, args []string) {
displayProfiles()
Expand Down
9 changes: 5 additions & 4 deletions cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,10 @@ var password string
var endpoint string

var esadCmd = &cobra.Command{
Use: cliName,
Short: "Use the CLI to interact with the Anomaly Detection plugin in your ES cluster",
Long: `The ESAD CLI is a tool to manage your Anomaly Detection plugin`,
Use: cliName,
Short: "use the CLI to interact with the Anomaly Detection plugin in your ES cluster",
Long: fmt.Sprintf("Description:\n " +
`The ESAD CLI is a tool to manage your Anomaly Detection plugin`),
Version: pkg.VERSION,
}

Expand All @@ -66,7 +67,7 @@ func init() {
esadCmd.PersistentFlags().StringVar(&user, FlagUser, "", "user to use. Overrides config/env settings.")
esadCmd.PersistentFlags().StringVar(&password, FlagPassword, "", "password to use. Overrides config/env settings.")
esadCmd.PersistentFlags().StringVar(&endpoint, FlagEndpoint, "", "endpoint to use. Overrides config/env settings.")
esadCmd.PersistentFlags().StringVar(&profile, FlagProfile, "", "Use a specific profile from your credential file.")
esadCmd.PersistentFlags().StringVar(&profile, FlagProfile, "", "use a specific profile from your credential file.")

}

Expand Down
16 changes: 9 additions & 7 deletions cli/cmd/start_stop.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ const (
//default input is name pattern, one can change this format to be id by passing --id flag
var startCmd = &cobra.Command{
Use: commandStart + " [flags] [list of detectors]",
Short: "Start detectors based on an ID or name pattern",
Long: `Start detectors based on a pattern. Use "" to make sure the name does not match with pwd lists'`,
Short: "Start detectors based on an id or name pattern",
Long: fmt.Sprintf("Description:\n " +
`Start detectors based on a pattern. Use "" to make sure the name does not match with pwd lists'`),
Run: func(cmd *cobra.Command, args []string) {
idStatus, _ := cmd.Flags().GetBool("id")
action := ad.StartAnomalyDetectorByNamePattern
Expand All @@ -50,7 +51,8 @@ var startCmd = &cobra.Command{
var stopCmd = &cobra.Command{
Use: commandStop + " [flags] [list of detectors]",
Short: "Stop detectors based on id or name pattern",
Long: `Stops detectors based on pattern, use "" to make sure the name is not matched with pwd lists'`,
Long: fmt.Sprintf("Description:\n " +
`Stops detectors based on pattern, use "" to make sure the name is not matched with pwd lists'`),
Run: func(cmd *cobra.Command, args []string) {
//If no args, display usage
if len(args) < 1 {
Expand All @@ -74,11 +76,11 @@ var stopCmd = &cobra.Command{

func init() {
esadCmd.AddCommand(startCmd)
startCmd.Flags().BoolP("name", "", true, "Input is name or pattern")
startCmd.Flags().BoolP("id", "", false, "Input is id")
startCmd.Flags().BoolP("name", "", true, "input is name or pattern")
startCmd.Flags().BoolP("id", "", false, "input is id")
esadCmd.AddCommand(stopCmd)
stopCmd.Flags().BoolP("name", "", true, "Input is name or pattern")
stopCmd.Flags().BoolP("id", "", false, "Input is id")
stopCmd.Flags().BoolP("name", "", true, "input is name or pattern")
stopCmd.Flags().BoolP("id", "", false, "input is id")
}

func execute(f func(*ad.Handler, string) error, detectors []string) error {
Expand Down