+
Skip to content
This repository was archived by the owner on Sep 28, 2021. It is now read-only.
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
2 changes: 2 additions & 0 deletions docs/corectl_remove.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ Remove one or mores generic entities (connections, dimensions, measures, objects
### Options

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
-h, --help help for remove
--suppress Suppress all confirmation dialogues
--ttl string Engine session time to live in seconds (default "30")
```

Expand Down
2 changes: 2 additions & 0 deletions docs/corectl_remove_app.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ corectl remove app APP-ID
### Options inherited from parent commands

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
--suppress Suppress all confirmation dialogues
-t, --traffic Log JSON websocket traffic to stdout
--ttl string Engine session time to live in seconds (default "30")
-v, --verbose Logs extra information
Expand Down
7 changes: 4 additions & 3 deletions docs/corectl_remove_connection.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,18 @@ corectl remove connection CONNECTION-ID
### Options

```
-a, --app string App name, if no app is specified a session app is used instead.
-h, --help help for connection
--no-save Do not save the app
-h, --help help for connection
--no-save Do not save the app
```

### Options inherited from parent commands

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
--suppress Suppress all confirmation dialogues
-t, --traffic Log JSON websocket traffic to stdout
--ttl string Engine session time to live in seconds (default "30")
-v, --verbose Logs extra information
Expand Down
7 changes: 4 additions & 3 deletions docs/corectl_remove_dimensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ corectl remove dimensions <dimension-id>... [flags]
### Options

```
-a, --app string App name, if no app is specified a session app is used instead.
-h, --help help for dimensions
--no-save Do not save the app
-h, --help help for dimensions
--no-save Do not save the app
```

### Options inherited from parent commands

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
--suppress Suppress all confirmation dialogues
-t, --traffic Log JSON websocket traffic to stdout
--ttl string Engine session time to live in seconds (default "30")
-v, --verbose Logs extra information
Expand Down
7 changes: 4 additions & 3 deletions docs/corectl_remove_measures.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ corectl remove measures <measure-id>... [flags]
### Options

```
-a, --app string App name, if no app is specified a session app is used instead.
-h, --help help for measures
--no-save Do not save the app
-h, --help help for measures
--no-save Do not save the app
```

### Options inherited from parent commands

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
--suppress Suppress all confirmation dialogues
-t, --traffic Log JSON websocket traffic to stdout
--ttl string Engine session time to live in seconds (default "30")
-v, --verbose Logs extra information
Expand Down
7 changes: 4 additions & 3 deletions docs/corectl_remove_objects.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,18 @@ corectl remove objects <object-id>... [flags]
### Options

```
-a, --app string App name, if no app is specified a session app is used instead.
-h, --help help for objects
--no-save Do not save the app
-h, --help help for objects
--no-save Do not save the app
```

### Options inherited from parent commands

```
-a, --app string App name, if no app is specified a session app is used instead.
-c, --config string path/to/config.yml where parameters can be set instead of on the command line
-e, --engine string URL to engine (default "localhost:9076")
--headers stringToString Headers to use when connecting to qix engine (default [])
--suppress Suppress all confirmation dialogues
-t, --traffic Log JSON websocket traffic to stdout
--ttl string Engine session time to live in seconds (default "30")
-v, --verbose Logs extra information
Expand Down
58 changes: 49 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package main

import (
"bufio"
"fmt"
"log"
"net/http"
"os"
"strings"
Expand Down Expand Up @@ -610,8 +612,11 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,

PersistentPreRun: func(ccmd *cobra.Command, args []string) {
corectlCommand.PersistentPreRun(corectlCommand, args)
viper.BindPFlag("app", ccmd.PersistentFlags().Lookup("app"))
viper.BindPFlag("engine", ccmd.PersistentFlags().Lookup("engine"))
viper.BindPFlag("ttl", ccmd.PersistentFlags().Lookup("ttl"))
viper.BindPFlag("headers", ccmd.PersistentFlags().Lookup("headers"))
viper.BindPFlag("suppress", ccmd.PersistentFlags().Lookup("suppress"))
},
}

Expand All @@ -624,12 +629,23 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,
removeCmd.PersistentPreRun(removeCmd, args)
},
Run: func(ccmd *cobra.Command, args []string) {
if len(args) != 1 {
app := viper.GetString("app")

if len(args) != 1 && app == "" {
fmt.Println("Expected an identifier of the app to delete.")
ccmd.Usage()
os.Exit(1)
}
internal.DeleteApp(rootCtx, viper.GetString("engine"), args[0], viper.GetString("ttl"), headers)

if len(args) == 1 {
app = args[0]
}

confirmed := askForConfirmation(fmt.Sprintf("Do you really want to delete the app: %s?", app))

if confirmed {
internal.DeleteApp(rootCtx, viper.GetString("engine"), app, viper.GetString("ttl"), headers)
}
},
}

Expand All @@ -640,7 +656,6 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,
Example: "corectl remove connection CONNECTION-ID",
PersistentPreRun: func(ccmd *cobra.Command, args []string) {
removeCmd.PersistentPreRun(removeCmd, args)
viper.BindPFlag("app", ccmd.PersistentFlags().Lookup("app"))
viper.BindPFlag("no-save", ccmd.PersistentFlags().Lookup("no-save"))
},
Run: func(ccmd *cobra.Command, args []string) {
Expand Down Expand Up @@ -669,7 +684,6 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,

PersistentPreRun: func(ccmd *cobra.Command, args []string) {
removeCmd.PersistentPreRun(removeCmd, args)
viper.BindPFlag("app", ccmd.PersistentFlags().Lookup("app"))
viper.BindPFlag("no-save", ccmd.PersistentFlags().Lookup("no-save"))
},

Expand Down Expand Up @@ -701,7 +715,6 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,

PersistentPreRun: func(ccmd *cobra.Command, args []string) {
removeCmd.PersistentPreRun(removeCmd, args)
viper.BindPFlag("app", ccmd.PersistentFlags().Lookup("app"))
viper.BindPFlag("no-save", ccmd.PersistentFlags().Lookup("no-save"))
},

Expand Down Expand Up @@ -733,7 +746,6 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,

PersistentPreRun: func(ccmd *cobra.Command, args []string) {
removeCmd.PersistentPreRun(removeCmd, args)
viper.BindPFlag("app", ccmd.PersistentFlags().Lookup("app"))
viper.BindPFlag("no-save", ccmd.PersistentFlags().Lookup("no-save"))
},

Expand Down Expand Up @@ -771,7 +783,6 @@ corectl eval by "Region" // Returns the values for dimension "Region"`,
viper.BindPFlag("engine", ccmd.PersistentFlags().Lookup("engine"))
viper.BindPFlag("no-save", ccmd.PersistentFlags().Lookup("no-save"))
viper.BindPFlag("ttl", ccmd.PersistentFlags().Lookup("ttl"))

},
}

Expand Down Expand Up @@ -984,12 +995,12 @@ func init() {
command.PersistentFlags().String("ttl", "30", "Engine session time to live in seconds")
}

for _, command := range []*cobra.Command{buildCmd, evalCmd, getCmd, reloadCmd, removeCmd, setCmd} {
for _, command := range []*cobra.Command{buildCmd, evalCmd, getCmd, reloadCmd, setCmd, removeCmd} {
//not binding to viper since binding a map does not seem to work.
command.PersistentFlags().StringToStringVar(&headersMap, "headers", nil, "Headers to use when connecting to qix engine")
}

for _, command := range []*cobra.Command{buildCmd, catwalkCmd, evalCmd, getAssociationsCmd, getConnectionsCmd, getConnectionCmd, getDimensionsCmd, getDimensionCmd, getFieldsCmd, getKeysCmd, getFieldCmd, getMeasuresCmd, getMeasureCmd, getMetaCmd, getObjectsCmd, getObjectCmd, getScriptCmd, getStatusCmd, getTablesCmd, reloadCmd, removeConnectionCmd, removeDimensionsCmd, removeMeasuresCmd, removeObjectsCmd, setCmd} {
for _, command := range []*cobra.Command{buildCmd, catwalkCmd, evalCmd, getAssociationsCmd, getConnectionsCmd, getConnectionCmd, getDimensionsCmd, getDimensionCmd, getFieldsCmd, getKeysCmd, getFieldCmd, getMeasuresCmd, getMeasureCmd, getMetaCmd, getObjectsCmd, getObjectCmd, getScriptCmd, getStatusCmd, getTablesCmd, reloadCmd, removeCmd, setCmd} {
command.PersistentFlags().StringP("app", "a", "", "App name, if no app is specified a session app is used instead.")
}

Expand Down Expand Up @@ -1030,6 +1041,10 @@ func init() {
command.PersistentFlags().Bool("json", false, "Prints the information in json format")
}

for _, command := range []*cobra.Command{removeCmd} {
command.PersistentFlags().Bool("suppress", false, "Suppress all confirmation dialogues")
}

catwalkCmd.PersistentFlags().String("catwalk-url", "https://catwalk.core.qlik.com", "Url to an instance of catwalk, if not provided the qlik one will be used.")

// commands
Expand Down Expand Up @@ -1160,3 +1175,28 @@ func build(ccmd *cobra.Command, args []string) {
internal.Save(ctx, state.Doc, state.AppID)
}
}

func askForConfirmation(s string) bool {
if viper.GetString("suppress") == "true" {
return true
}

reader := bufio.NewReader(os.Stdin)

for {
fmt.Printf("%s [y/n]: ", s)

response, err := reader.ReadString('\n')
if err != nil {
log.Fatal(err)
}

response = strings.ToLower(strings.TrimSpace(response))

if response == "y" || response == "yes" {
return true
} else if response == "n" || response == "no" {
return false
}
}
}
Loading
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载