mirror of
https://github.com/passbolt/go-passbolt-cli.git
synced 2025-05-12 10:58:21 +00:00
modify user/create.go to display only ID when created
This commit is contained in:
parent
6a4fc45132
commit
b5905cf88b
1 changed files with 14 additions and 15 deletions
|
@ -6,7 +6,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/passbolt/go-passbolt-cli/util"
|
"github.com/passbolt/go-passbolt-cli/util"
|
||||||
"github.com/passbolt/go-passbolt/api"
|
"github.com/passbolt/go-passbolt/helper"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -60,31 +60,30 @@ func UserCreate(cmd *cobra.Command, args []string) error {
|
||||||
defer client.Logout(context.TODO())
|
defer client.Logout(context.TODO())
|
||||||
cmd.SilenceUsage = true
|
cmd.SilenceUsage = true
|
||||||
|
|
||||||
user, err := client.CreateUser(
|
id, err := helper.CreateUser(
|
||||||
ctx,
|
ctx,
|
||||||
api.User{
|
client,
|
||||||
Username: username,
|
role,
|
||||||
Profile: &api.Profile{
|
username,
|
||||||
FirstName: firstname,
|
firstname,
|
||||||
LastName: lastname,
|
lastname,
|
||||||
},
|
|
||||||
Role: &api.Role{
|
|
||||||
Name: role,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("Creating User: %w", err)
|
return fmt.Errorf("Creating User: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if jsonOutput {
|
if jsonOutput {
|
||||||
jsonUser, err := json.MarshalIndent(user, "", " ")
|
jsonId, err := json.MarshalIndent(
|
||||||
|
map[string]string{"id": id},
|
||||||
|
"",
|
||||||
|
" ",
|
||||||
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
fmt.Println(string(jsonUser))
|
fmt.Println(string(jsonId))
|
||||||
} else {
|
} else {
|
||||||
fmt.Printf("UserID: %v\n", user.ID)
|
fmt.Printf("UserID: %v\n", id)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue