AppID:   test
Name:    Test application
EUIs:
       - 0000000000000000

Access Keys:
       - Name: default key
         Key:  FZYr01cUhdhY1KBiMghUl+/gXyqXhrF6y+1ww7+DzHg=
         Rights: messages:up:r, messages:down:w

Collaborators:
       - Name: yourname
         Rights: settings, delete, collaborators
`,
	Run: func(cmd *cobra.Command, args []string) {
		account := util.GetAccount(ctx)

		var appID string
		if len(args) == 1 {
			appID = args[0]
		} else {
			appID = util.GetAppID(ctx)
		}

		app, err := account.FindApplication(appID)
		if err != nil {
			ctx.WithError(err).Fatal("Could not find application")
		}

		ctx.Info("Found application")
Beispiel #2
0
import (
	"github.com/TheThingsNetwork/ttn/ttnctl/util"
	"github.com/apex/log"
	"github.com/spf13/cobra"
	"github.com/spf13/viper"
)

var devicesCmd = &cobra.Command{
	Use:     "devices",
	Aliases: []string{"device"},
	Short:   "Manage devices",
	Long:    `ttnctl devices can be used to manage devices.`,
	PersistentPreRun: func(cmd *cobra.Command, args []string) {
		RootCmd.PersistentPreRun(cmd, args)
		util.GetAccount(ctx)
		ctx.WithFields(log.Fields{
			"AppID":  util.GetAppID(ctx),
			"AppEUI": util.GetAppEUI(ctx),
		}).Info("Using Application")
	},
}

func init() {
	RootCmd.AddCommand(devicesCmd)
	devicesCmd.PersistentFlags().String("app-id", "", "The app ID to use")
	viper.BindPFlag("app-id", devicesCmd.PersistentFlags().Lookup("app-id"))
	devicesCmd.PersistentFlags().String("app-eui", "", "The app EUI to use")
	viper.BindPFlag("app-eui", devicesCmd.PersistentFlags().Lookup("app-eui"))
}