Skip to content
Snippets Groups Projects
Commit d882ecc0 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

Resolve "Change structure of user related requests in CLI to fit other schemes"

See merge request !953
parent b03c8b46
Branches
No related tags found
1 merge request!953Resolve "Change structure of user related requests in CLI to fit other schemes"
Pipeline #216095 passed
...@@ -35,9 +35,7 @@ import ( ...@@ -35,9 +35,7 @@ import (
"github.com/spf13/cobra" "github.com/spf13/cobra"
) )
//var duid string // roleCmd represents the role command.
// networkElementCmd represents the network element command.
var roleCmd = &cobra.Command{ var roleCmd = &cobra.Command{
Use: "role", Use: "role",
Short: "the role command contains all sub-commands for role management", Short: "the role command contains all sub-commands for role management",
......
/*
Copyright © 2021 da/net Research Group <danet@h-da.de>
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
package cmd
import (
"github.com/spf13/cobra"
)
// userCmd represents the user command.
var userCmd = &cobra.Command{
Use: "user",
Short: "the user command contains all sub-commands for user management",
Long: `The user command contains all sub-commands for user management. It has no functionality in itself.`,
}
func init() {
rootCmd.AddCommand(userCmd)
}
...@@ -42,9 +42,9 @@ import ( ...@@ -42,9 +42,9 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// loginCmd represents the login command. // userCreateCmd represents the user creation command.
var userCreateCmd = &cobra.Command{ var userCreateCmd = &cobra.Command{
Use: "userCreate", Use: "create",
Short: "Creates a user with provided data", Short: "Creates a user with provided data",
Long: `Creates a user with provided data. Long: `Creates a user with provided data.
User name and password hashed with (add hash method here!) required, User name and password hashed with (add hash method here!) required,
...@@ -82,7 +82,7 @@ var userCreateCmd = &cobra.Command{ ...@@ -82,7 +82,7 @@ var userCreateCmd = &cobra.Command{
var nbUserRole string var nbUserRole string
func init() { func init() {
rootCmd.AddCommand(userCreateCmd) userCmd.AddCommand(userCreateCmd)
userCreateCmd.Flags().StringVar(&nbUserName, "u", "", "username for login") userCreateCmd.Flags().StringVar(&nbUserName, "u", "", "username for login")
userCreateCmd.Flags().StringVar(&nbUserPwd, "p", "", "pwd for login") userCreateCmd.Flags().StringVar(&nbUserPwd, "p", "", "pwd for login")
......
...@@ -41,9 +41,9 @@ import ( ...@@ -41,9 +41,9 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// loginCmd represents the login command. // userDeleteCmd represents the user delete command.
var userDeleteCmd = &cobra.Command{ var userDeleteCmd = &cobra.Command{
Use: "userDelete", Use: "delete",
Short: "Deletes a user with provided data", Short: "Deletes a user with provided data",
Long: `Deletes a user with provided data. Long: `Deletes a user with provided data.
Requires the user name of the user which should be deleted.`, Requires the user name of the user which should be deleted.`,
...@@ -68,7 +68,7 @@ var userDeleteCmd = &cobra.Command{ ...@@ -68,7 +68,7 @@ var userDeleteCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(userDeleteCmd) userCmd.AddCommand(userDeleteCmd)
userDeleteCmd.Flags().StringVar(&nbUserName, "u", "", "username to delete") userDeleteCmd.Flags().StringVar(&nbUserName, "u", "", "username to delete")
} }
...@@ -40,9 +40,9 @@ import ( ...@@ -40,9 +40,9 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// loginCmd represents the login command. // userGetCmd represents the get one user command.
var userGetCmd = &cobra.Command{ var userGetCmd = &cobra.Command{
Use: "userGet", Use: "get",
Short: "Requests one user", Short: "Requests one user",
Long: `Requests one user using the provided name to search for it in the stored users.`, Long: `Requests one user using the provided name to search for it in the stored users.`,
...@@ -71,7 +71,7 @@ var userGetCmd = &cobra.Command{ ...@@ -71,7 +71,7 @@ var userGetCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(userGetCmd) userCmd.AddCommand(userGetCmd)
userGetCmd.Flags().StringVar(&nbUserName, "u", "", "username to find") userGetCmd.Flags().StringVar(&nbUserName, "u", "", "username to find")
} }
...@@ -39,9 +39,9 @@ import ( ...@@ -39,9 +39,9 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// loginCmd represents the login command. // userListCmd represents the get all users command.
var userGetAllCmd = &cobra.Command{ var userListCmd = &cobra.Command{
Use: "userGetAll", Use: "list",
Short: "Requests all the available users", Short: "Requests all the available users",
Long: `Requests all the available users.`, Long: `Requests all the available users.`,
...@@ -62,5 +62,5 @@ var userGetAllCmd = &cobra.Command{ ...@@ -62,5 +62,5 @@ var userGetAllCmd = &cobra.Command{
} }
func init() { func init() {
rootCmd.AddCommand(userGetAllCmd) userCmd.AddCommand(userListCmd)
} }
...@@ -43,9 +43,9 @@ import ( ...@@ -43,9 +43,9 @@ import (
"github.com/spf13/viper" "github.com/spf13/viper"
) )
// loginCmd represents the login command. // userUpdateCmd represents the update command.
var userUpdateCmd = &cobra.Command{ var userUpdateCmd = &cobra.Command{
Use: "userUpdate", Use: "update",
Short: "Updates a user with provided data", Short: "Updates a user with provided data",
Long: `Updates a user with provided data. Long: `Updates a user with provided data.
User name and password hashed with (add hash method here!) required, User name and password hashed with (add hash method here!) required,
...@@ -95,7 +95,7 @@ var userUpdateCmd = &cobra.Command{ ...@@ -95,7 +95,7 @@ var userUpdateCmd = &cobra.Command{
var nbUserID string var nbUserID string
func init() { func init() {
rootCmd.AddCommand(userUpdateCmd) userCmd.AddCommand(userUpdateCmd)
userUpdateCmd.Flags().StringVar(&nbUserID, "i", "", "id of the user") userUpdateCmd.Flags().StringVar(&nbUserID, "i", "", "id of the user")
userUpdateCmd.Flags().StringVar(&nbUserName, "u", "", "username for login") userUpdateCmd.Flags().StringVar(&nbUserName, "u", "", "username for login")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment