Skip to content

Commit f07e865

Browse files
committed
Fixed command run
1 parent 918977f commit f07e865

File tree

5 files changed

+22
-6
lines changed

5 files changed

+22
-6
lines changed

cli/cli.go

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import (
2929
"github.com/arduino/arduino-cloud-cli/cli/dashboard"
3030
"github.com/arduino/arduino-cloud-cli/cli/device"
3131
"github.com/arduino/arduino-cloud-cli/cli/ota"
32+
"github.com/arduino/arduino-cloud-cli/cli/template"
3233
"github.com/arduino/arduino-cloud-cli/cli/thing"
3334
"github.com/arduino/arduino-cloud-cli/cli/version"
3435
"github.com/sirupsen/logrus"
@@ -65,6 +66,7 @@ func Execute() {
6566
cli.AddCommand(thing.NewCommand())
6667
cli.AddCommand(dashboard.NewCommand())
6768
cli.AddCommand(ota.NewCommand())
69+
cli.AddCommand(template.NewCommand())
6870

6971
if err := cli.Execute(); err != nil {
7072
fmt.Fprintln(os.Stderr, err)

cli/template/export.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ func initTemplateExportCommand() *cobra.Command {
4646
},
4747
}
4848

49-
uploadCommand.Flags().StringVarP(&flags.templateId, "id", "t", "", "Template file id")
49+
uploadCommand.Flags().StringVarP(&flags.templateId, "template-id", "t", "", "Template file id")
50+
51+
uploadCommand.MarkFlagRequired("template-id")
5052

5153
return uploadCommand
5254
}

cli/template/import.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ type importFlags struct {
3434

3535
func initTemplateImportCommand() *cobra.Command {
3636
flags := &importFlags{}
37-
uploadCommand := &cobra.Command{
37+
downloadCommand := &cobra.Command{
3838
Use: "import",
3939
Short: "Import template",
4040
Long: "Import a template from a file",
@@ -46,9 +46,11 @@ func initTemplateImportCommand() *cobra.Command {
4646
},
4747
}
4848

49-
uploadCommand.Flags().StringVarP(&flags.templateFile, "file", "f", "", "Template file to import")
49+
downloadCommand.Flags().StringVarP(&flags.templateFile, "file", "f", "", "Template file to import")
5050

51-
return uploadCommand
51+
downloadCommand.MarkFlagRequired("file")
52+
53+
return downloadCommand
5254
}
5355

5456
func runTemplateImportCommand(flags *importFlags) error {

cli/template/template.go

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func NewCommand() *cobra.Command {
2929
}
3030

3131
templateCommand.AddCommand(initTemplateImportCommand())
32+
templateCommand.AddCommand(initTemplateExportCommand())
3233

3334
return templateCommand
3435
}

internal/storage-api/client.go

+11-2
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,18 @@ type StorageApiClient struct {
4242
organization string
4343
}
4444

45+
func getArduinoAPIBaseURL() string {
46+
baseURL := "https://api-media.arduino.cc"
47+
if url := os.Getenv("IOT_API_MEDIA_URL"); url != "" {
48+
baseURL = url
49+
}
50+
return baseURL
51+
}
52+
4553
func NewClient(credentials *config.Credentials) *StorageApiClient {
46-
host := iot.GetArduinoAPIBaseURL()
47-
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, host)
54+
host := getArduinoAPIBaseURL()
55+
iothost := iot.GetArduinoAPIBaseURL()
56+
tokenSource := iot.NewUserTokenSource(credentials.Client, credentials.Secret, iothost)
4857
return &StorageApiClient{
4958
client: &http.Client{},
5059
src: tokenSource,

0 commit comments

Comments
 (0)