diff --git a/cli/cli.go b/cli/cli.go index 7099f57f99..e87ea8dec9 100644 --- a/cli/cli.go +++ b/cli/cli.go @@ -129,10 +129,16 @@ func NewDefraCommand() *cobra.Command { MakeKeyringExportCommand(), ) + identity := MakeIdentityCommand() + identity.AddCommand( + MakeIdentityNewCommand(), + ) + root := MakeRootCommand() root.AddCommand( client, keyring, + identity, MakeStartCommand(), MakeServerDumpCmd(), MakeVersionCommand(), diff --git a/cli/identity.go b/cli/identity.go new file mode 100644 index 0000000000..66efcec098 --- /dev/null +++ b/cli/identity.go @@ -0,0 +1,25 @@ +// Copyright 2024 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package cli + +import ( + "github.com/spf13/cobra" +) + +func MakeIdentityCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "identity", + Short: "Interact with identity features of DefraDB instance", + Long: `Interact with identity features of DefraDB instance`, + } + + return cmd +} diff --git a/cli/identity_new.go b/cli/identity_new.go new file mode 100644 index 0000000000..cd903979fc --- /dev/null +++ b/cli/identity_new.go @@ -0,0 +1,40 @@ +// Copyright 2024 Democratized Data Foundation +// +// Use of this software is governed by the Business Source License +// included in the file licenses/BSL.txt. +// +// As of the Change Date specified in that file, in accordance with +// the Business Source License, use of this software will be governed +// by the Apache License, Version 2.0, included in the file +// licenses/APL.txt. + +package cli + +import ( + "github.com/spf13/cobra" + + "github.com/sourcenetwork/defradb/acp/identity" +) + +func MakeIdentityNewCommand() *cobra.Command { + var cmd = &cobra.Command{ + Use: "new", + Short: "Generate a new identity", + Long: `Generate a new identity + +Example: generate a new identity: + defradb identity new + +`, + RunE: func(cmd *cobra.Command, args []string) error { + newIdentity, err := identity.Generate() + if err != nil { + return err + } + + return writeJSON(cmd, newIdentity) + }, + } + + return cmd +}